Enable chrome with aura for tizen
[platform/framework/web/chromium-efl.git] / printing / print_settings_unittest.cc
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.
4
5 #include "printing/print_settings.h"
6
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"
12
13 namespace printing {
14
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));
20   }
21
22   // Check edge cases.
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);
29 }
30
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))
35                     .has_value());
36   }
37 }
38
39 TEST(PrintSettingsDeathTest, IsColorModelSelectedEdges) {
40   ::testing::FLAGS_gtest_death_test_style = "threadsafe";
41   EXPECT_DCHECK_DEATH(
42       IsColorModelSelected(mojom::ColorModel::kUnknownColorModel));
43 }
44 #if defined(USE_CUPS)
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();
55     color_value.clear();
56   }
57 }
58
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))
64                      .empty());
65   }
66 }
67 #endif  // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH)
68 #endif  // defined(USE_CUPS)
69
70 }  // namespace printing