Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ui/base/resource/material_design/material_design_controller_unittest.cc

Issue 1188713007: Moved --top-chrome-md command line switch from chrome_switches to ui_base_switches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed typedef in unittest. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
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 <string>
6
7 #include "base/command_line.h"
8 #include "base/macros.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/resource/material_design/material_design_controller.h"
11 #include "ui/base/test/material_design_controller_test_api.h"
12 #include "ui/base/ui_base_switches.h"
13
14 namespace ui {
15 namespace {
16
17 // Test fixture for the MaterialDesignController class.
18 class MaterialDesignControllerTest : public testing::Test {
19 public:
20 MaterialDesignControllerTest();
21 ~MaterialDesignControllerTest() override;
22
23 // testing::Test:
24 void TearDown() override;
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest);
28 };
29
30 MaterialDesignControllerTest::MaterialDesignControllerTest() {
31 }
32
33 MaterialDesignControllerTest::~MaterialDesignControllerTest() {
34 }
35
36 void MaterialDesignControllerTest::TearDown() {
37 testing::Test::TearDown();
38
39 // Ensure other tests aren't polluted by a Mode set in these tests.
40 test::MaterialDesignControllerTestAPI::UninitializeMode();
41 }
42
43 #if !defined(ENABLE_TOPCHROME_MD)
44
45 // Verify the Mode maps to Mode::NON_MATERIAL when the compile time flag is not
46 // defined.
47 TEST_F(MaterialDesignControllerTest,
48 NonMaterialModeWhenCompileTimeFlagDisabled) {
49 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
50 MaterialDesignController::GetMode());
51 }
52
53 #else
54
55 // Verify command line value "material" maps to Mode::MATERIAL when the compile
56 // time flag is defined.
57 TEST_F(MaterialDesignControllerTest,
58 EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) {
59 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
60 switches::kTopChromeMD, "material");
61 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL,
62 MaterialDesignController::GetMode());
63 }
64
65 // Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID
66 // when the compile time flag is defined.
67 TEST_F(
68 MaterialDesignControllerTest,
69 EnabledHybridCommandLineValueMapsToMaterialHybridModeWhenCompileTimeFlagEnab led) {
70 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
71 switches::kTopChromeMD, "material-hybrid");
72 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_HYBRID,
73 MaterialDesignController::GetMode());
74 }
75
76 // Verify command line value "" maps to Mode::NON_MATERIAL when the compile time
77 // flag is defined.
78 TEST_F(
79 MaterialDesignControllerTest,
80 DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
81 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
82 switches::kTopChromeMD, "");
83 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
84 MaterialDesignController::GetMode());
85 }
86
87 // Verify no command line value maps to Mode::NON_MATERIAL when the compile time
88 // flag is defined.
89 TEST_F(MaterialDesignControllerTest,
90 NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
91 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
92 switches::kTopChromeMD));
93 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
94 MaterialDesignController::GetMode());
95 }
96
97 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OFFICIAL_BUILD) && \
98 !defined(NDEBUG)
99
100 // Verify an invalid command line value fails.
101 TEST_F(MaterialDesignControllerTest, InvalidCommandLineValueFailsDeathTest) {
102 const std::string kInvalidValue = "1nvalid-valu3";
103 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
104 switches::kTopChromeMD, kInvalidValue);
105 EXPECT_DEATH(MaterialDesignController::GetMode(), kInvalidValue);
106 }
107
108 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OFFICIAL_BUILD) &&
109 // !defined(NDEBUG)
110
111 #endif // !defined(ENABLE_TOPCHROME_MD)
112
113 } // namespace
114 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698