Commit 09eba089 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Verify color models in PrintBackendCupsHelperTest.

Make sure color models are color, and B&W models are not. Since
PrintBackendCupsHelperTest has to deal with enum ColorModel anyway, it
is a convenient spot to also exercise IsColorModelSelected().

Bug: 1069315
Change-Id: Ie3f665d5245e5aee04010f7c61d7b193936a0655
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143372
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757982}
parent 39852264
......@@ -5,6 +5,7 @@
#include "printing/backend/cups_helper.h"
#include "printing/backend/print_backend.h"
#include "printing/print_settings.h"
#include "printing/printing_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -20,6 +21,15 @@ bool PapersEqual(const PrinterSemanticCapsAndDefaults::Paper& lhs,
lhs.vendor_id == rhs.vendor_id && lhs.size_um == rhs.size_um;
}
void VerifyCapabilityColorModels(const PrinterSemanticCapsAndDefaults& caps) {
base::Optional<bool> maybe_color = IsColorModelSelected(caps.color_model);
ASSERT_TRUE(maybe_color.has_value());
EXPECT_TRUE(maybe_color.value());
maybe_color = IsColorModelSelected(caps.bw_model);
ASSERT_TRUE(maybe_color.has_value());
EXPECT_FALSE(maybe_color.value());
}
} // namespace
TEST(PrintBackendCupsHelperTest, TestPpdParsingNoColorDuplexShortEdge) {
......@@ -280,6 +290,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingBrotherPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(BROTHER_BRSCRIPT3_COLOR, caps.color_model);
EXPECT_EQ(BROTHER_BRSCRIPT3_BLACK, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
{
constexpr char kTestPpdData[] =
......@@ -298,6 +309,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingBrotherPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(BROTHER_CUPS_COLOR, caps.color_model);
EXPECT_EQ(BROTHER_CUPS_MONO, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
{
constexpr char kTestPpdData[] =
......@@ -336,6 +348,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingHpPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(HP_COLOR_COLOR, caps.color_model);
EXPECT_EQ(HP_COLOR_BLACK, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
TEST(PrintBackendCupsHelperTest, TestPpdParsingEpsonPrinters) {
......@@ -358,6 +371,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingEpsonPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(EPSON_INK_COLOR, caps.color_model);
EXPECT_EQ(EPSON_INK_MONO, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
TEST(PrintBackendCupsHelperTest, TestPpdParsingSamsungPrinters) {
......@@ -376,6 +390,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingSamsungPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(COLORMODE_COLOR, caps.color_model);
EXPECT_EQ(COLORMODE_MONOCHROME, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
TEST(PrintBackendCupsHelperTest, TestPpdParsingSharpPrinters) {
......@@ -399,6 +414,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingSharpPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(SHARP_ARCMODE_CMCOLOR, caps.color_model);
EXPECT_EQ(SHARP_ARCMODE_CMBW, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
TEST(PrintBackendCupsHelperTest, TestPpdParsingXeroxPrinters) {
......@@ -420,6 +436,7 @@ TEST(PrintBackendCupsHelperTest, TestPpdParsingXeroxPrinters) {
EXPECT_TRUE(caps.color_default);
EXPECT_EQ(XEROX_XRXCOLOR_AUTOMATIC, caps.color_model);
EXPECT_EQ(XEROX_XRXCOLOR_BW, caps.bw_model);
VerifyCapabilityColorModels(caps);
}
} // namespace printing
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