diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-09 14:22:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-05-09 15:11:45 +0000 |
commit | 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch) | |
tree | e75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/ui/base/material_design/material_design_controller_unittest.cc | |
parent | a4f3d46271c57e8155ba912df46a05559d14726e (diff) | |
download | qtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz |
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion.
Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/ui/base/material_design/material_design_controller_unittest.cc')
-rw-r--r-- | chromium/ui/base/material_design/material_design_controller_unittest.cc | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/chromium/ui/base/material_design/material_design_controller_unittest.cc b/chromium/ui/base/material_design/material_design_controller_unittest.cc new file mode 100644 index 00000000000..543cf3d2c8f --- /dev/null +++ b/chromium/ui/base/material_design/material_design_controller_unittest.cc @@ -0,0 +1,121 @@ +// 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 "base/command_line.h" +#include "base/macros.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/material_design/material_design_controller.h" +#include "ui/base/test/material_design_controller_test_api.h" +#include "ui/base/ui_base_switches.h" + +namespace ui { +namespace { + +// Test fixture for the MaterialDesignController class. +class MaterialDesignControllerTest : public testing::Test { + public: + MaterialDesignControllerTest(); + ~MaterialDesignControllerTest() override; + + // testing::Test: + void SetUp() override; + + private: + DISALLOW_COPY_AND_ASSIGN(MaterialDesignControllerTest); +}; + +MaterialDesignControllerTest::MaterialDesignControllerTest() { +} + +MaterialDesignControllerTest::~MaterialDesignControllerTest() { +} + +void MaterialDesignControllerTest::SetUp() { + testing::Test::SetUp(); + + // Ensure other tests aren't polluted by a Mode set in these tests. The Mode + // has to be cleared in SetUp and not in TearDown because when the test suite + // starts up it triggers a call to ResourceBundle::LoadCommonResources() + // which calls MaterialDesignController::IsModeMaterial(), thereby + // initializing the mode and potentially causing the first test to fail. + test::MaterialDesignControllerTestAPI::UninitializeMode(); +} + +#if !defined(ENABLE_TOPCHROME_MD) + +// Verify the Mode maps to Mode::NON_MATERIAL when the compile time flag is not +// defined. +TEST_F(MaterialDesignControllerTest, + NonMaterialModeWhenCompileTimeFlagDisabled) { + EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, + MaterialDesignController::GetMode()); +} + +#else + +// Verify command line value "material" maps to Mode::MATERIAL when the compile +// time flag is defined. +TEST_F(MaterialDesignControllerTest, + EnabledCommandLineValueMapsToMaterialModeWhenCompileTimeFlagEnabled) { + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kTopChromeMD, "material"); + EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_NORMAL, + MaterialDesignController::GetMode()); +} + +// Verify command line value "material-hybrid" maps to Mode::MATERIAL_HYBRID +// when the compile time flag is defined. +TEST_F( + MaterialDesignControllerTest, + EnabledHybridCommandLineValueMapsToMaterialHybridModeWhenCompileTimeFlagEnabled) { + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kTopChromeMD, "material-hybrid"); + EXPECT_EQ(MaterialDesignController::Mode::MATERIAL_HYBRID, + MaterialDesignController::GetMode()); +} + +// Verify command line value "" maps to the default mode when the compile time +// flag is defined. +TEST_F( + MaterialDesignControllerTest, + DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kTopChromeMD, ""); + EXPECT_EQ(MaterialDesignController::DefaultMode(), + MaterialDesignController::GetMode()); +} + +// Verify the current mode is reported as the default mode when no command line +// flag is defined. +TEST_F(MaterialDesignControllerTest, + NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { + ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kTopChromeMD)); + EXPECT_EQ(MaterialDesignController::DefaultMode(), + MaterialDesignController::GetMode()); +} + +// Verify an invalid command line value uses the default mode. +TEST_F(MaterialDesignControllerTest, InvalidCommandLineValue) { + const std::string kInvalidValue = "1nvalid-valu3"; + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kTopChromeMD, kInvalidValue); + EXPECT_EQ(MaterialDesignController::DefaultMode(), + MaterialDesignController::GetMode()); +} + +// Verify that MaterialDesignController::IsModeMaterial() will initialize the +// mode if it hasn't been initialized yet. +TEST_F(MaterialDesignControllerTest, IsModeMaterialInitializesMode) { + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kTopChromeMD, "material"); + EXPECT_TRUE(MaterialDesignController::IsModeMaterial()); +} + +#endif // !defined(ENABLE_TOPCHROME_MD) + +} // namespace +} // namespace ui |