1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "printing/print_settings.h"
7 #include "base/test/gtest_util.h"
8 #include "build/build_config.h"
9 #include "build/chromeos_buildflags.h"
10 #include "printing/mojom/print.mojom.h"
11 #include "testing/gtest/include/gtest/gtest.h"
15 TEST(PrintSettingsTest, ColorModeToColorModel) {
16 for (int mode = static_cast<int>(mojom::ColorModel::kUnknownColorModel);
17 mode <= static_cast<int>(mojom::ColorModel::kColorModelLast); ++mode) {
18 EXPECT_EQ(ColorModeToColorModel(mode),
19 static_cast<mojom::ColorModel>(mode));
23 EXPECT_EQ(ColorModeToColorModel(
24 static_cast<int>(mojom::ColorModel::kUnknownColorModel) - 1),
25 mojom::ColorModel::kUnknownColorModel);
26 EXPECT_EQ(ColorModeToColorModel(
27 static_cast<int>(mojom::ColorModel::kColorModelLast) + 1),
28 mojom::ColorModel::kUnknownColorModel);
31 TEST(PrintSettingsTest, IsColorModelSelected) {
32 for (int model = static_cast<int>(mojom::ColorModel::kUnknownColorModel) + 1;
33 model <= static_cast<int>(mojom::ColorModel::kColorModelLast); ++model) {
34 EXPECT_TRUE(IsColorModelSelected(static_cast<mojom::ColorModel>(model))
39 TEST(PrintSettingsDeathTest, IsColorModelSelectedEdges) {
40 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
42 IsColorModelSelected(mojom::ColorModel::kUnknownColorModel));
45 TEST(PrintSettingsTest, GetColorModelForModel) {
46 std::string color_setting_name;
47 std::string color_value;
48 for (int model = static_cast<int>(mojom::ColorModel::kUnknownColorModel);
49 model <= static_cast<int>(mojom::ColorModel::kColorModelLast); ++model) {
50 GetColorModelForModel(static_cast<mojom::ColorModel>(model),
51 &color_setting_name, &color_value);
52 EXPECT_FALSE(color_setting_name.empty());
53 EXPECT_FALSE(color_value.empty());
54 color_setting_name.clear();
59 #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH)
60 TEST(PrintSettingsTest, GetIppColorModelForModel) {
61 for (int model = static_cast<int>(mojom::ColorModel::kUnknownColorModel);
62 model <= static_cast<int>(mojom::ColorModel::kColorModelLast); ++model) {
63 EXPECT_FALSE(GetIppColorModelForModel(static_cast<mojom::ColorModel>(model))
67 #endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH)
68 #endif // defined(USE_CUPS)
70 } // namespace printing