Commit f8181b91 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Consolidate print_backend_cups_{linux|mac}_unittest.cc into one file

The tests are similar enough that differences can reasonably be
handled by build flags.

Change-Id: I257fb4aebf47cc7e5c67a2965e64dbb90d8a7007
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097557
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749194}
parent 31cab864
......@@ -329,13 +329,10 @@ test("printing_unittests") {
if (is_chromeos) {
sources += [ "backend/cups_ipp_helper_unittest.cc" ]
} else {
sources += [ "backend/cups_helper_unittest.cc" ]
if (is_linux) {
sources += [ "backend/print_backend_cups_linux_unittest.cc" ]
}
if (is_mac) {
sources += [ "backend/print_backend_cups_mac_unittest.cc" ]
}
sources += [
"backend/cups_helper_unittest.cc",
"backend/print_backend_cups_unittest.cc",
]
}
}
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cups/cups.h>
#include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_cups.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
TEST(PrintBackendCupsLinuxTest, PrinterBasicInfoFromCUPS) {
const char kName[] = "printer";
cups_dest_t* printer = nullptr;
ASSERT_EQ(1, cupsAddDest(kName, nullptr, 0, &printer));
int num_options = 0;
cups_option_t* options = nullptr;
num_options =
cupsAddOption("printer-info", "description", num_options, &options);
printer->num_options = num_options;
printer->options = options;
PrinterBasicInfo printer_info;
PrintBackendCUPS::PrinterBasicInfoFromCUPS(*printer, &printer_info);
cupsFreeDests(1, printer);
EXPECT_EQ("printer", printer_info.printer_name);
EXPECT_EQ("printer", printer_info.display_name);
EXPECT_EQ("description", printer_info.printer_description);
}
} // namespace printing
// Copyright 2019 The Chromium Authors. All rights reserved.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "printing/backend/print_backend_cups.h"
#include <cups/cups.h>
#include "build/build_config.h"
#include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_cups.h"
#include "printing/backend/print_backend_consts.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
TEST(PrintBackendCupsMacTest, PrinterBasicInfoFromCUPS) {
const char kName[] = "printer";
TEST(PrintBackendCupsTest, PrinterBasicInfoFromCUPS) {
constexpr char kName[] = "printer";
cups_dest_t* printer = nullptr;
ASSERT_EQ(1, cupsAddDest(kName, nullptr, 0, &printer));
ASSERT_EQ(
1, cupsAddDest(kName, /*instance=*/nullptr, /*num_dests=*/0, &printer));
int num_options = 0;
cups_option_t* options = nullptr;
num_options = cupsAddOption("printer-info", "name", num_options, &options);
num_options = cupsAddOption("printer-make-and-model", "description",
#if defined(OS_MACOSX)
num_options =
cupsAddOption(kCUPSOptPrinterInfo, "info", num_options, &options);
num_options = cupsAddOption(kCUPSOptPrinterMakeAndModel, "description",
num_options, &options);
#else
num_options =
cupsAddOption(kCUPSOptPrinterInfo, "description", num_options, &options);
#endif
printer->num_options = num_options;
printer->options = options;
PrinterBasicInfo printer_info;
PrintBackendCUPS::PrinterBasicInfoFromCUPS(*printer, &printer_info);
cupsFreeDests(1, printer);
EXPECT_EQ("printer", printer_info.printer_name);
EXPECT_EQ("name", printer_info.display_name);
EXPECT_TRUE(
PrintBackendCUPS::PrinterBasicInfoFromCUPS(*printer, &printer_info));
cupsFreeDests(/*num_dests=*/1, printer);
EXPECT_EQ(kName, printer_info.printer_name);
#if defined(OS_MACOSX)
EXPECT_EQ("info", printer_info.display_name);
#else
EXPECT_EQ(kName, printer_info.display_name);
#endif
EXPECT_EQ("description", printer_info.printer_description);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment