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

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 (multi-value) 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
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..37810fecc1d5d0eccae11c91222429932896c58d
--- /dev/null
+++ b/ash/material_design/material_design_controller_unittest.cc
@@ -0,0 +1,137 @@
+// 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 <string>
+
+#include "ash/ash_switches.h"
+#include "ash/material_design/material_design_controller.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 testing::Test {
+ public:
+ MaterialDesignControllerTest();
+ ~MaterialDesignControllerTest() override;
+
+ protected:
+ // testing::Test:
+ void SetUp() override;
+ void TearDown() override;
+ void SetCommandLineValue(const std::string& value_string);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest);
+};
+
+MaterialDesignControllerTest::MaterialDesignControllerTest() {}
+
+MaterialDesignControllerTest::~MaterialDesignControllerTest() {}
+
+void MaterialDesignControllerTest::SetUp() {
+ testing::Test::SetUp();
+ MaterialDesignController::Initialize();
+}
+
+void MaterialDesignControllerTest::TearDown() {
+ test::MaterialDesignControllerTestAPI::Uninitialize();
+ testing::Test::TearDown();
+}
+
+void MaterialDesignControllerTest::SetCommandLineValue(
+ const std::string& value_string) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ ash::switches::kAshMaterialDesign, value_string);
+}
+
+class MaterialDesignControllerTestNonMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestNonMaterial() { SetCommandLineValue("disabled"); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestNonMaterial);
+};
+
+class MaterialDesignControllerTestMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestMaterial() { SetCommandLineValue("enabled"); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestMaterial);
+};
+
+class MaterialDesignControllerTestExperimental
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestExperimental() {
+ SetCommandLineValue("experimental");
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestExperimental);
+};
+
+class MaterialDesignControllerTestInvalid
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestInvalid() {
+ SetCommandLineValue("1nvalid-valu3");
+ }
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698