OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 MaterialDesignController::Initialize(); | 41 MaterialDesignController::Initialize(); |
42 } | 42 } |
43 | 43 |
44 void MaterialDesignControllerTest::TearDown() { | 44 void MaterialDesignControllerTest::TearDown() { |
45 test::MaterialDesignControllerTestAPI::Uninitialize(); | 45 test::MaterialDesignControllerTestAPI::Uninitialize(); |
46 testing::Test::TearDown(); | 46 testing::Test::TearDown(); |
47 } | 47 } |
48 | 48 |
49 void MaterialDesignControllerTest::SetCommandLineSwitch( | 49 void MaterialDesignControllerTest::SetCommandLineSwitch( |
50 const std::string& value_string) { | 50 const std::string& value_string) { |
51 #if defined(ENABLE_TOPCHROME_MD) | |
52 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 51 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
53 switches::kTopChromeMD, value_string); | 52 switches::kTopChromeMD, value_string); |
54 #endif // defined(ENABLE_TOPCHROME_MD) | |
55 } | 53 } |
56 | 54 |
57 class MaterialDesignControllerTestMaterial : | 55 class MaterialDesignControllerTestMaterial : |
58 public MaterialDesignControllerTest { | 56 public MaterialDesignControllerTest { |
59 public: | 57 public: |
60 MaterialDesignControllerTestMaterial() { | 58 MaterialDesignControllerTestMaterial() { |
61 SetCommandLineSwitch("material"); | 59 SetCommandLineSwitch("material"); |
62 } | 60 } |
63 | 61 |
64 private: | 62 private: |
(...skipping 26 matching lines...) Expand all Loading... |
91 public: | 89 public: |
92 MaterialDesignControllerTestInvalid() { | 90 MaterialDesignControllerTestInvalid() { |
93 const std::string kInvalidValue = "1nvalid-valu3"; | 91 const std::string kInvalidValue = "1nvalid-valu3"; |
94 SetCommandLineSwitch(kInvalidValue); | 92 SetCommandLineSwitch(kInvalidValue); |
95 } | 93 } |
96 | 94 |
97 private: | 95 private: |
98 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid); | 96 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid); |
99 }; | 97 }; |
100 | 98 |
101 #if !defined(ENABLE_TOPCHROME_MD) | |
102 | |
103 // Verify the Mode maps to Mode::NON_MATERIAL when the compile time flag is not | |
104 // defined. | |
105 TEST_F(MaterialDesignControllerTest, | |
106 NonMaterialModeWhenCompileTimeFlagDisabled) { | |
107 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, | |
108 MaterialDesignController::GetMode()); | |
109 } | |
110 | |
111 #else | |
112 | |
113 // Verify command line value "material" maps to Mode::MATERIAL when the compile | 99 // Verify command line value "material" maps to Mode::MATERIAL when the compile |
114 // time flag is defined. | 100 // time flag is defined. |
115 TEST_F(MaterialDesignControllerTestMaterial, | 101 TEST_F(MaterialDesignControllerTestMaterial, |
116 EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) { | 102 EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) { |
117 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_NORMAL, | 103 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_NORMAL, |
118 MaterialDesignController::GetMode()); | 104 MaterialDesignController::GetMode()); |
119 } | 105 } |
120 | 106 |
121 // Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID | 107 // Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID |
122 // when the compile time flag is defined. | 108 // when the compile time flag is defined. |
(...skipping 28 matching lines...) Expand all Loading... |
151 EXPECT_EQ(MaterialDesignController::DefaultMode(), | 137 EXPECT_EQ(MaterialDesignController::DefaultMode(), |
152 MaterialDesignController::GetMode()); | 138 MaterialDesignController::GetMode()); |
153 } | 139 } |
154 | 140 |
155 // Verify that MaterialDesignController::IsModeMaterial() will be true when | 141 // Verify that MaterialDesignController::IsModeMaterial() will be true when |
156 // initialized with command line flag "material". | 142 // initialized with command line flag "material". |
157 TEST_F(MaterialDesignControllerTestMaterial, IsModeMaterialInitializesMode) { | 143 TEST_F(MaterialDesignControllerTestMaterial, IsModeMaterialInitializesMode) { |
158 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); | 144 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); |
159 } | 145 } |
160 | 146 |
161 #endif // !defined(ENABLE_TOPCHROME_MD) | |
162 | |
163 } // namespace | 147 } // namespace |
164 } // namespace ui | 148 } // namespace ui |
OLD | NEW |