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

Side by Side Diff: ash/material_design/material_design_controller_unittest.cc

Issue 1921133002: Adds ash::MaterialDesignController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds ash::MaterialDesignController (multi-value) Created 4 years, 7 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 2016 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 "ash/ash_switches.h"
8 #include "ash/material_design/material_design_controller.h"
9 #include "ash/test/material_design_controller_test_api.h"
10 #include "base/command_line.h"
11 #include "base/macros.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace ash {
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 protected:
24 // testing::Test:
25 void SetUp() override;
26 void TearDown() override;
27 void SetCommandLineValue(const std::string& value_string);
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest);
31 };
32
33 MaterialDesignControllerTest::MaterialDesignControllerTest() {}
34
35 MaterialDesignControllerTest::~MaterialDesignControllerTest() {}
36
37 void MaterialDesignControllerTest::SetUp() {
38 testing::Test::SetUp();
39 MaterialDesignController::Initialize();
40 }
41
42 void MaterialDesignControllerTest::TearDown() {
43 test::MaterialDesignControllerTestAPI::Uninitialize();
44 testing::Test::TearDown();
45 }
46
47 void MaterialDesignControllerTest::SetCommandLineValue(
48 const std::string& value_string) {
49 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
50 ash::switches::kAshMaterialDesign, value_string);
51 }
52
53 class MaterialDesignControllerTestNonMaterial
54 : public MaterialDesignControllerTest {
55 public:
56 MaterialDesignControllerTestNonMaterial() { SetCommandLineValue("disabled"); }
57
58 private:
59 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestNonMaterial);
60 };
61
62 class MaterialDesignControllerTestMaterial
63 : public MaterialDesignControllerTest {
64 public:
65 MaterialDesignControllerTestMaterial() { SetCommandLineValue("enabled"); }
66
67 private:
68 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestMaterial);
69 };
70
71 class MaterialDesignControllerTestExperimental
72 : public MaterialDesignControllerTest {
73 public:
74 MaterialDesignControllerTestExperimental() {
75 SetCommandLineValue("experimental");
76 }
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestExperimental);
80 };
81
82 class MaterialDesignControllerTestInvalid
83 : public MaterialDesignControllerTest {
84 public:
85 MaterialDesignControllerTestInvalid() {
86 SetCommandLineValue("1nvalid-valu3");
87 }
88
89 private:
90 DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid);
91 };
92
93 } // namespace
94
95 // Verify the current mode is reported as the default mode when no command line
96 // flag is added.
97 TEST_F(MaterialDesignControllerTest, NoCommandLineValueMapsToDefaultMode) {
98 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
99 ash::switches::kAshMaterialDesign));
100 EXPECT_EQ(test::MaterialDesignControllerTestAPI::DefaultMode() ==
101 MaterialDesignController::Mode::MATERIAL_NORMAL ||
102 test::MaterialDesignControllerTestAPI::DefaultMode() ==
103 MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL,
104 MaterialDesignController::IsMaterial());
105 }
106
107 // Verify that MaterialDesignController::IsMaterial() will be false when
108 // initialized with command line flag "disabled".
109 TEST_F(MaterialDesignControllerTestNonMaterial, CommandLineValue) {
110 EXPECT_FALSE(MaterialDesignController::IsMaterial());
111 EXPECT_FALSE(MaterialDesignController::IsMaterialExperimental());
112 }
113
114 // Verify that MaterialDesignController::IsMaterial() will be true when
115 // initialized with command line flag "enabled".
116 TEST_F(MaterialDesignControllerTestMaterial, CommandLineValue) {
117 EXPECT_TRUE(MaterialDesignController::IsMaterial());
118 EXPECT_FALSE(MaterialDesignController::IsMaterialExperimental());
119 }
120
121 // Verify that MaterialDesignController::IsMaterialexperimental() will be true
122 // when initialized with command line flag "experimental".
123 TEST_F(MaterialDesignControllerTestExperimental, CommandLineValue) {
124 EXPECT_TRUE(MaterialDesignController::IsMaterial());
125 EXPECT_TRUE(MaterialDesignController::IsMaterialExperimental());
126 }
127
128 // Verify an invalid command line value uses the default mode.
129 TEST_F(MaterialDesignControllerTestInvalid, CommandLineValue) {
130 EXPECT_EQ(test::MaterialDesignControllerTestAPI::DefaultMode() ==
131 MaterialDesignController::Mode::MATERIAL_NORMAL ||
132 test::MaterialDesignControllerTestAPI::DefaultMode() ==
133 MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL,
134 MaterialDesignController::IsMaterial());
135 }
136
137 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698