Move and test CUPS IPP color model selector
The version of GetColorModelForMode() that ChromeOS uses will be used
by macOS. Rename it to GetIppColorModelForMode() and move it to
print_settings.h. Meanwhile, add some simple tests.
Bug: 1106437
Change-Id: Ic01d1cf242c6e77774d247253f6cd912c2566f5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303855
Commit-Queue: Daniel Hosseinian <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#789717}
diff --git a/printing/print_settings_unittest.cc b/printing/print_settings_unittest.cc
index 0c7db4a..44a4625 100644
--- a/printing/print_settings_unittest.cc
+++ b/printing/print_settings_unittest.cc
@@ -5,6 +5,7 @@
#include "printing/print_settings.h"
#include "base/test/gtest_util.h"
+#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
@@ -43,6 +44,19 @@
EXPECT_DCHECK_DEATH(GetColorModelForMode(COLOR_MODEL_LAST + 1,
&color_setting_name, &color_value));
}
+
+#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
+TEST(PrintSettingsTest, GetIppColorModelForMode) {
+ for (int model = UNKNOWN_COLOR_MODEL; model <= COLOR_MODEL_LAST; ++model)
+ EXPECT_FALSE(GetIppColorModelForMode(model).empty());
+}
+
+TEST(PrintSettingsDeathTest, GetIppColorModelForModeEdges) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ EXPECT_DCHECK_DEATH(GetIppColorModelForMode(UNKNOWN_COLOR_MODEL - 1));
+ EXPECT_DCHECK_DEATH(GetIppColorModelForMode(COLOR_MODEL_LAST + 1));
+}
+#endif // defined(OS_MACOSX) || defined(OS_CHROMEOS)
#endif // defined(USE_CUPS)
} // namespace printing