#include "printing/backend/test_print_backend.h"
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/scoped_refptr.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "printing/backend/mojom/print_backend.mojom.h"
#include "printing/backend/print_backend.h"
#include "printing/mojom/print.mojom.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/size.h"
#if BUILDFLAG(IS_WIN)
#include "base/test/gmock_expected_support.h"
#endif
namespace printing {
namespace {
constexpr char kDefaultPrinterName[] = …;
constexpr char kAlternatePrinterName[] = …;
constexpr char kNullDataPrinterName[] = …;
constexpr char kAccessDeniedPrinterName[] = …;
constexpr char kInvalidPrinterName[] = …;
constexpr char kInvalidDataPrinterName[] = …;
constexpr int kDefaultPrinterStatus = …;
constexpr int kAlternatePrinterStatus = …;
const PrinterBasicInfo kDefaultPrinterInfo(
kDefaultPrinterName,
"default test printer",
"Default printer for testing.",
kDefaultPrinterStatus,
true,
PrinterBasicInfoOptions{ … });
const PrinterBasicInfo kAlternatePrinterInfo(
kAlternatePrinterName,
"alternate test printer",
"Alternate printer for testing.",
kAlternatePrinterStatus,
false,
PrinterBasicInfoOptions{ … });
constexpr int32_t kDefaultCopiesMax = …;
constexpr int32_t kAlternateCopiesMax = …;
}
class TestPrintBackendTest : public testing::Test { … };
TEST_F(TestPrintBackendTest, EnumeratePrinters) { … }
TEST_F(TestPrintBackendTest, EnumeratePrintersNoneFound) { … }
TEST_F(TestPrintBackendTest, DefaultPrinterName) { … }
TEST_F(TestPrintBackendTest, PrinterBasicInfo) { … }
TEST_F(TestPrintBackendTest, PrinterBasicInfoAccessDenied) { … }
TEST_F(TestPrintBackendTest, PrinterBasicInfoInvalidData) { … }
TEST_F(TestPrintBackendTest, GetPrinterSemanticCapsAndDefaults) { … }
TEST_F(TestPrintBackendTest, GetPrinterSemanticCapsAndDefaultsAccessDenied) { … }
TEST_F(TestPrintBackendTest, IsValidPrinter) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(TestPrintBackendTest, GetXmlPrinterCapabilitiesForXpsDriver) {
EXPECT_THAT(GetPrintBackend()->GetXmlPrinterCapabilitiesForXpsDriver(
kDefaultPrinterName),
base::test::ErrorIs(mojom::ResultCode::kFailed));
AddPrinters();
ASSERT_TRUE(GetPrintBackend()
->GetXmlPrinterCapabilitiesForXpsDriver(kDefaultPrinterName)
.has_value());
EXPECT_THAT(GetPrintBackend()->GetXmlPrinterCapabilitiesForXpsDriver(
kInvalidPrinterName),
base::test::ErrorIs(mojom::ResultCode::kFailed));
EXPECT_THAT(GetPrintBackend()->GetXmlPrinterCapabilitiesForXpsDriver(
kNullDataPrinterName),
base::test::ErrorIs(mojom::ResultCode::kFailed));
}
#endif
}