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

Unified 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 (CHECK_* -> DCHECK_*) Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/material_design/material_design_controller.cc ('k') | ash/test/ash_test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/material_design/material_design_controller_unittest.cc
diff --git a/ash/material_design/material_design_controller_unittest.cc b/ash/material_design/material_design_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c2f9d6c355782c3e79ffee25976d34ab396bfe2
--- /dev/null
+++ b/ash/material_design/material_design_controller_unittest.cc
@@ -0,0 +1,135 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <memory>
+#include <string>
+
+#include "ash/ash_switches.h"
+#include "ash/material_design/material_design_controller.h"
+#include "ash/test/ash_test_base.h"
+#include "ash/test/material_design_controller_test_api.h"
+#include "base/command_line.h"
+#include "base/macros.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ash {
+namespace {
+
+// Test fixture for the MaterialDesignController class.
+class MaterialDesignControllerTest : public ash::test::AshTestBase {
+ public:
+ MaterialDesignControllerTest() = default;
+ ~MaterialDesignControllerTest() override = default;
+
+ protected:
+ // ash::test::AshTestBase:
+ void SetCommandLineValue(const std::string& value_string);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest);
+};
+
+void MaterialDesignControllerTest::SetCommandLineValue(
+ const std::string& value_string) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ ash::switches::kAshMaterialDesign, value_string);
+}
+
+class MaterialDesignControllerTestNonMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestNonMaterial() : MaterialDesignControllerTest() {}
+ void SetUp() override {
+ SetCommandLineValue("disabled");
+ MaterialDesignControllerTest::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestNonMaterial);
+};
+
+class MaterialDesignControllerTestMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestMaterial() : MaterialDesignControllerTest() {}
+ void SetUp() override {
+ SetCommandLineValue("enabled");
+ MaterialDesignControllerTest::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestMaterial);
+};
+
+class MaterialDesignControllerTestExperimental
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestExperimental() : MaterialDesignControllerTest() {}
+ void SetUp() override {
+ SetCommandLineValue("experimental");
+ MaterialDesignControllerTest::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestExperimental);
+};
+
+class MaterialDesignControllerTestInvalid
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestInvalid() : MaterialDesignControllerTest() {}
+ void SetUp() override {
+ SetCommandLineValue("1nvalid-valu3");
+ MaterialDesignControllerTest::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestInvalid);
+};
+
+} // namespace
+
+// Verify the current mode is reported as the default mode when no command line
+// flag is added.
+TEST_F(MaterialDesignControllerTest, NoCommandLineValueMapsToDefaultMode) {
+ ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshMaterialDesign));
+ EXPECT_EQ(test::MaterialDesignControllerTestAPI::DefaultMode() ==
+ MaterialDesignController::Mode::MATERIAL_NORMAL ||
+ test::MaterialDesignControllerTestAPI::DefaultMode() ==
+ MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL,
+ MaterialDesignController::IsMaterial());
+}
+
+// Verify that MaterialDesignController::IsMaterial() will be false when
+// initialized with command line flag "disabled".
+TEST_F(MaterialDesignControllerTestNonMaterial, CommandLineValue) {
+ EXPECT_FALSE(MaterialDesignController::IsMaterial());
+ EXPECT_FALSE(MaterialDesignController::IsMaterialExperimental());
+}
+
+// Verify that MaterialDesignController::IsMaterial() will be true when
+// initialized with command line flag "enabled".
+TEST_F(MaterialDesignControllerTestMaterial, CommandLineValue) {
+ EXPECT_TRUE(MaterialDesignController::IsMaterial());
+ EXPECT_FALSE(MaterialDesignController::IsMaterialExperimental());
+}
+
+// Verify that MaterialDesignController::IsMaterialexperimental() will be true
+// when initialized with command line flag "experimental".
+TEST_F(MaterialDesignControllerTestExperimental, CommandLineValue) {
+ EXPECT_TRUE(MaterialDesignController::IsMaterial());
+ EXPECT_TRUE(MaterialDesignController::IsMaterialExperimental());
+}
+
+// Verify an invalid command line value uses the default mode.
+TEST_F(MaterialDesignControllerTestInvalid, CommandLineValue) {
+ EXPECT_EQ(test::MaterialDesignControllerTestAPI::DefaultMode() ==
+ MaterialDesignController::Mode::MATERIAL_NORMAL ||
+ test::MaterialDesignControllerTestAPI::DefaultMode() ==
+ MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL,
+ MaterialDesignController::IsMaterial());
+}
+
+} // namespace ash
« no previous file with comments | « ash/material_design/material_design_controller.cc ('k') | ash/test/ash_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698