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

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: 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..74ac794c323c061dba7d595da1de40440bb0e02f
--- /dev/null
+++ b/ash/material_design/material_design_controller_unittest.cc
@@ -0,0 +1,114 @@
+// Copyright 2015 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;
+
+ 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();
+}
+
+class MaterialDesignControllerTestMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestMaterial() {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshEnableMaterialDesign);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestMaterial);
+};
+
+class MaterialDesignControllerTestNonMaterial
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestNonMaterial() {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshDisableMaterialDesign);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestNonMaterial);
+};
+
+class MaterialDesignControllerTestBothEnabledAndDisabled
+ : public MaterialDesignControllerTest {
+ public:
+ MaterialDesignControllerTestBothEnabledAndDisabled() {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshEnableMaterialDesign);
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshDisableMaterialDesign);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTestBothEnabledAndDisabled);
+};
+
+// Verify the current mode is reported as the default mode when no command line
+// flag is added.
+TEST_F(MaterialDesignControllerTest, NoCommandLineSwitchMapsToDefaultMode) {
+ ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshEnableMaterialDesign));
+ ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshDisableMaterialDesign));
+ EXPECT_EQ(test::MaterialDesignControllerTestAPI::DefaultMode(),
+ MaterialDesignController::IsMaterial());
+}
+
+// Verify that MaterialDesignController::IsModeMaterial() will be true when
+// initialized with command line flag "ash-enable-md".
+TEST_F(MaterialDesignControllerTestMaterial, CommandLineSwitch) {
+ EXPECT_TRUE(MaterialDesignController::IsMaterial());
+}
+
+// Verify that MaterialDesignController::IsModeMaterial() will be false when
+// initialized with command line flag "ash-disable-md".
+TEST_F(MaterialDesignControllerTestNonMaterial, CommandLineSwitch) {
+ EXPECT_FALSE(MaterialDesignController::IsMaterial());
+}
+
+// Verify that MaterialDesignController::IsModeMaterial() will be false when
+// initialized with both command line flags "ash-enable-md --ash-disable-md".
+TEST_F(MaterialDesignControllerTestBothEnabledAndDisabled, CommandLineSwitch) {
+ EXPECT_FALSE(MaterialDesignController::IsMaterial());
+}
+
+} // namespace
oshima 2016/04/25 23:01:43 Just define test bodies in ash namespace. Rational
varkha 2016/04/25 23:16:05 Done.
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698