Commit 73bff528 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Add tests for IsColorModelSelected()

Test two simple cases, COLOR and GRAY, and add death tests for corner
cases.

Bug: 1069537
Change-Id: I892da4f1daa384d795fb94a5810a698dfc9544b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148093Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758891}
parent 1a569505
......@@ -331,6 +331,7 @@ test("printing_unittests") {
"page_range_unittest.cc",
"page_setup_unittest.cc",
"print_settings_conversion_unittest.cc",
"print_settings_unittest.cc",
"printing_test.h",
"printing_utils_unittest.cc",
"units_unittest.cc",
......
// 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/print_settings.h"
#include "base/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
TEST(PrintSettingsTest, IsColorModelSelected) {
{
base::Optional<bool> color(IsColorModelSelected(COLOR));
ASSERT_TRUE(color.has_value());
EXPECT_TRUE(color.value());
}
{
base::Optional<bool> gray(IsColorModelSelected(GRAY));
ASSERT_TRUE(gray.has_value());
EXPECT_FALSE(gray.value());
}
{
// Test lower bound validity.
base::Optional<bool> lower(IsColorModelSelected(UNKNOWN_COLOR_MODEL + 1));
EXPECT_TRUE(lower.has_value());
}
{
// Test upper bound validity.
base::Optional<bool> upper(IsColorModelSelected(COLOR_MODEL_LAST));
EXPECT_TRUE(upper.has_value());
}
}
TEST(PrintSettingsDeathTest, IsColorModelSelectedUnknown) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
EXPECT_DCHECK_DEATH(IsColorModelSelected(UNKNOWN_COLOR_MODEL));
EXPECT_DCHECK_DEATH(IsColorModelSelected(UNKNOWN_COLOR_MODEL - 1));
EXPECT_DCHECK_DEATH(IsColorModelSelected(COLOR_MODEL_LAST + 1));
}
} // 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