| Index: ui/base/material_design/material_design_controller_unittest.cc
|
| diff --git a/ui/base/material_design/material_design_controller_unittest.cc b/ui/base/material_design/material_design_controller_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5ffd24943cb73af2f745c818b77bbff5a76b108c
|
| --- /dev/null
|
| +++ b/ui/base/material_design/material_design_controller_unittest.cc
|
| @@ -0,0 +1,106 @@
|
| +// Copyright 2015 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 <string>
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/macros.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| +#include "ui/base/test/material_design_controller_test_api.h"
|
| +#include "ui/base/ui_base_switches.h"
|
| +
|
| +namespace ui {
|
| +namespace {
|
| +
|
| +// Test fixture for the MaterialDesignController class.
|
| +class MaterialDesignControllerTest : public testing::Test {
|
| + public:
|
| + MaterialDesignControllerTest();
|
| + ~MaterialDesignControllerTest() override;
|
| +
|
| + // testing::Test:
|
| + void TearDown() override;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest);
|
| +};
|
| +
|
| +MaterialDesignControllerTest::MaterialDesignControllerTest() {
|
| +}
|
| +
|
| +MaterialDesignControllerTest::~MaterialDesignControllerTest() {
|
| +}
|
| +
|
| +void MaterialDesignControllerTest::TearDown() {
|
| + testing::Test::TearDown();
|
| +
|
| + // Ensure other tests aren't polluted by a look and feel set in these tests.
|
| + test::MaterialDesignControllerTestAPI::UninitializeLookAndFeel();
|
| +}
|
| +
|
| +#if !defined(ENABLE_TOPCHROME_MD)
|
| +
|
| +// Verify the look and feel maps to LookAndFeel::CLASSIC when the compile
|
| +// time flag is not defined.
|
| +TEST_F(MaterialDesignControllerTest,
|
| + ClassicLookAndFeelWhenCompileTimeFlagDisabled) {
|
| + EXPECT_EQ(MaterialDesignController::LookAndFeel::CLASSIC,
|
| + MaterialDesignController::GetLookAndFeel());
|
| +}
|
| +
|
| +#else
|
| +
|
| +// Verify command line value "enabled" maps to LookAndFeel::MATERIAL when the
|
| +// compile time flag is defined.
|
| +TEST_F(
|
| + MaterialDesignControllerTest,
|
| + EnabledCommandLineValueMapsToClassicLookAndFeelWhenCompileTimeFlagEnabled) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kTopChromeMD, "enabled");
|
| + EXPECT_EQ(MaterialDesignController::LookAndFeel::MATERIAL,
|
| + MaterialDesignController::GetLookAndFeel());
|
| +}
|
| +
|
| +// Verify command line value "enabled-hybrid" maps to LookAndFeel::HYBRID when
|
| +// the compile time flag is defined.
|
| +TEST_F(
|
| + MaterialDesignControllerTest,
|
| + EnabledHybridCommandLineValueMapsToHybridLookAndFeelWhenCompileTimeFlagEnabled) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kTopChromeMD, "enabled-hybrid");
|
| + EXPECT_EQ(MaterialDesignController::LookAndFeel::HYBRID,
|
| + MaterialDesignController::GetLookAndFeel());
|
| +}
|
| +
|
| +// Verify command line value "disabled" maps to LookAndFeel::CLASSIC when the
|
| +// compile time flag is defined.
|
| +TEST_F(
|
| + MaterialDesignControllerTest,
|
| + DisabledCommandLineValueMapsToClassicLookAndFeelWhenCompileTimeFlagEnabled) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kTopChromeMD, "disabled");
|
| + EXPECT_EQ(MaterialDesignController::LookAndFeel::CLASSIC,
|
| + MaterialDesignController::GetLookAndFeel());
|
| +}
|
| +
|
| +// Verify no command line value maps to LookAndFeel::CLASSIC when the compile
|
| +// time flag is defined.
|
| +TEST_F(MaterialDesignControllerTest,
|
| + NoCommandLineValueMapsToClassicLookAndFeelWhenCompileTimeFlagEnabled) {
|
| + EXPECT_EQ(MaterialDesignController::LookAndFeel::CLASSIC,
|
| + MaterialDesignController::GetLookAndFeel());
|
| +}
|
| +
|
| +// Verify an invalid command line value fails.
|
| +TEST_F(MaterialDesignControllerTest, InvalidCommandLineValueFails) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kTopChromeMD, "invalid-value");
|
| + EXPECT_DEATH(MaterialDesignController::GetLookAndFeel(), "");
|
| +}
|
| +
|
| +#endif // !defined(ENABLE_TOPCHROME_MD)
|
| +
|
| +} // namespace
|
| +} // namespace ui
|
|
|