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) |
51 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 52 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
52 switches::kTopChromeMD, value_string); | 53 switches::kTopChromeMD, value_string); |
| 54 #endif // defined(ENABLE_TOPCHROME_MD) |
53 } | 55 } |
54 | 56 |
55 class MaterialDesignControllerTestMaterial : | 57 class MaterialDesignControllerTestMaterial : |
56 public MaterialDesignControllerTest { | 58 public MaterialDesignControllerTest { |
57 public: | 59 public: |
58 MaterialDesignControllerTestMaterial() { | 60 MaterialDesignControllerTestMaterial() { |
59 SetCommandLineSwitch("material"); | 61 SetCommandLineSwitch("material"); |
60 } | 62 } |
61 | 63 |
62 private: | 64 private: |
(...skipping 26 matching lines...) Expand all Loading... |
89 public: | 91 public: |
90 MaterialDesignControllerTestInvalid() { | 92 MaterialDesignControllerTestInvalid() { |
91 const std::string kInvalidValue = "1nvalid-valu3"; | 93 const std::string kInvalidValue = "1nvalid-valu3"; |
92 SetCommandLineSwitch(kInvalidValue); | 94 SetCommandLineSwitch(kInvalidValue); |
93 } | 95 } |
94 | 96 |
95 private: | 97 private: |
96 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid); | 98 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid); |
97 }; | 99 }; |
98 | 100 |
| 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 |
99 // Verify command line value "material" maps to Mode::MATERIAL when the compile | 113 // Verify command line value "material" maps to Mode::MATERIAL when the compile |
100 // time flag is defined. | 114 // time flag is defined. |
101 TEST_F(MaterialDesignControllerTestMaterial, | 115 TEST_F(MaterialDesignControllerTestMaterial, |
102 EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) { | 116 EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) { |
103 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_NORMAL, | 117 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_NORMAL, |
104 MaterialDesignController::GetMode()); | 118 MaterialDesignController::GetMode()); |
105 } | 119 } |
106 | 120 |
107 // Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID | 121 // Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID |
108 // when the compile time flag is defined. | 122 // when the compile time flag is defined. |
(...skipping 28 matching lines...) Expand all Loading... |
137 EXPECT_EQ(MaterialDesignController::DefaultMode(), | 151 EXPECT_EQ(MaterialDesignController::DefaultMode(), |
138 MaterialDesignController::GetMode()); | 152 MaterialDesignController::GetMode()); |
139 } | 153 } |
140 | 154 |
141 // Verify that MaterialDesignController::IsModeMaterial() will be true when | 155 // Verify that MaterialDesignController::IsModeMaterial() will be true when |
142 // initialized with command line flag "material". | 156 // initialized with command line flag "material". |
143 TEST_F(MaterialDesignControllerTestMaterial, IsModeMaterialInitializesMode) { | 157 TEST_F(MaterialDesignControllerTestMaterial, IsModeMaterialInitializesMode) { |
144 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); | 158 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); |
145 } | 159 } |
146 | 160 |
| 161 #endif // !defined(ENABLE_TOPCHROME_MD) |
| 162 |
147 } // namespace | 163 } // namespace |
148 } // namespace ui | 164 } // namespace ui |
OLD | NEW |