#include "chrome/browser/printing/print_job.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/printing/print_job_worker.h"
#include "chrome/browser/printing/printer_query.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/test/browser_task_environment.h"
#include "printing/mojom/print.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
namespace {
class TestPrintJobWorker : public PrintJobWorker { … };
class TestQuery : public PrinterQuery { … };
class TestPrintJob : public PrintJob { … };
}
TEST(PrintJobTest, SimplePrint) { … }
TEST(PrintJobTest, SimplePrintLateInit) { … }
#if BUILDFLAG(IS_WIN)
TEST(PrintJobTest, PageRangeMapping) {
content::BrowserTaskEnvironment task_environment;
int page_count = 4;
std::vector<uint32_t> input_full = {0, 1, 2, 3};
std::vector<uint32_t> expected_output_full = {0, 1, 2, 3};
EXPECT_EQ(expected_output_full,
PrintJob::GetFullPageMapping(input_full, page_count));
std::vector<uint32_t> input_12 = {1, 2};
std::vector<uint32_t> expected_output_12 = {kInvalidPageIndex, 1, 2,
kInvalidPageIndex};
EXPECT_EQ(expected_output_12,
PrintJob::GetFullPageMapping(input_12, page_count));
std::vector<uint32_t> input_03 = {0, 3};
std::vector<uint32_t> expected_output_03 = {0, kInvalidPageIndex,
kInvalidPageIndex, 3};
EXPECT_EQ(expected_output_03,
PrintJob::GetFullPageMapping(input_03, page_count));
std::vector<uint32_t> input_0 = {0};
std::vector<uint32_t> expected_output_0 = {
0, kInvalidPageIndex, kInvalidPageIndex, kInvalidPageIndex};
EXPECT_EQ(expected_output_0,
PrintJob::GetFullPageMapping(input_0, page_count));
std::vector<uint32_t> input_invalid = {4, 100};
std::vector<uint32_t> expected_output_invalid = {
kInvalidPageIndex, kInvalidPageIndex, kInvalidPageIndex,
kInvalidPageIndex};
EXPECT_EQ(expected_output_invalid,
PrintJob::GetFullPageMapping(input_invalid, page_count));
}
#endif
}