| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // when the compile time flag is defined. | 70 // when the compile time flag is defined. |
| 71 TEST_F( | 71 TEST_F( |
| 72 MaterialDesignControllerTest, | 72 MaterialDesignControllerTest, |
| 73 EnabledHybridCommandLineValueMapsToMaterialHybridModeWhenCompileTimeFlagEnab
led) { | 73 EnabledHybridCommandLineValueMapsToMaterialHybridModeWhenCompileTimeFlagEnab
led) { |
| 74 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 74 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 75 switches::kTopChromeMD, "material-hybrid"); | 75 switches::kTopChromeMD, "material-hybrid"); |
| 76 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_HYBRID, | 76 EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_HYBRID, |
| 77 MaterialDesignController::GetMode()); | 77 MaterialDesignController::GetMode()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Verify command line value "" maps to Mode::NON_MATERIAL when the compile time | 80 // Verify command line value "" maps to the default mode when the compile time |
| 81 // flag is defined. | 81 // flag is defined. |
| 82 TEST_F( | 82 TEST_F( |
| 83 MaterialDesignControllerTest, | 83 MaterialDesignControllerTest, |
| 84 DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { | 84 DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { |
| 85 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 85 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 86 switches::kTopChromeMD, ""); | 86 switches::kTopChromeMD, ""); |
| 87 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, | 87 EXPECT_EQ(MaterialDesignController::DefaultMode(), |
| 88 MaterialDesignController::GetMode()); | 88 MaterialDesignController::GetMode()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Verify no command line value maps to Mode::NON_MATERIAL when the compile time | 91 // Verify the current mode is reported as the default mode when no command line |
| 92 // flag is defined. | 92 // flag is defined. |
| 93 TEST_F(MaterialDesignControllerTest, | 93 TEST_F(MaterialDesignControllerTest, |
| 94 NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { | 94 NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { |
| 95 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( | 95 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 96 switches::kTopChromeMD)); | 96 switches::kTopChromeMD)); |
| 97 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, | 97 EXPECT_EQ(MaterialDesignController::DefaultMode(), |
| 98 MaterialDesignController::GetMode()); | 98 MaterialDesignController::GetMode()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Verify an invalid command line value uses the default NON_MATERIAL mode. | 101 // Verify an invalid command line value uses the default mode. |
| 102 TEST_F(MaterialDesignControllerTest, InvalidCommandLineValue) { | 102 TEST_F(MaterialDesignControllerTest, InvalidCommandLineValue) { |
| 103 const std::string kInvalidValue = "1nvalid-valu3"; | 103 const std::string kInvalidValue = "1nvalid-valu3"; |
| 104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 104 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 105 switches::kTopChromeMD, kInvalidValue); | 105 switches::kTopChromeMD, kInvalidValue); |
| 106 EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, | 106 EXPECT_EQ(MaterialDesignController::DefaultMode(), |
| 107 MaterialDesignController::GetMode()); | 107 MaterialDesignController::GetMode()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Verify that MaterialDesignController::IsModeMaterial() will initialize the | 110 // Verify that MaterialDesignController::IsModeMaterial() will initialize the |
| 111 // mode if it hasn't been initialized yet. | 111 // mode if it hasn't been initialized yet. |
| 112 TEST_F(MaterialDesignControllerTest, IsModeMaterialInitializesMode) { | 112 TEST_F(MaterialDesignControllerTest, IsModeMaterialInitializesMode) { |
| 113 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 113 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 114 switches::kTopChromeMD, "material"); | 114 switches::kTopChromeMD, "material"); |
| 115 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); | 115 EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 #endif // !defined(ENABLE_TOPCHROME_MD) | 118 #endif // !defined(ENABLE_TOPCHROME_MD) |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 } // namespace ui | 121 } // namespace ui |
| OLD | NEW |