Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / chromeos / accessibility / magnification_manager_unittest.cc
blob50a83ca0212f21d971b6756480e1d43ff12fe29f
1 // Copyright (c) 2013 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.
5 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
7 #include "ash/magnifier/magnifier_constants.h"
8 #include "ash/test/ash_test_base.h"
9 #include "base/prefs/pref_service.h"
10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace chromeos {
15 namespace {
17 void EnableMagnifier() {
18 return MagnificationManager::Get()->SetMagnifierEnabled(true);
21 void DisableMagnifier() {
22 return MagnificationManager::Get()->SetMagnifierEnabled(false);
25 bool IsMagnifierEnabled() {
26 return MagnificationManager::Get()->IsMagnifierEnabled();
29 ash::MagnifierType GetMagnifierType() {
30 return MagnificationManager::Get()->GetMagnifierType();
33 void SetMagnifierType(ash::MagnifierType type) {
34 return MagnificationManager::Get()->SetMagnifierType(type);
37 } // namespace
39 class MagnificationManagerTest : public ash::test::AshTestBase {
40 public:
41 MagnificationManagerTest() {
44 virtual void SetUp() override {
45 ash::test::AshTestBase::SetUp();
46 MagnificationManager::Initialize();
47 ASSERT_TRUE(MagnificationManager::Get());
48 MagnificationManager::Get()->SetProfileForTest(&profile_);
51 virtual void TearDown() override {
52 MagnificationManager::Shutdown();
53 ash::test::AshTestBase::TearDown();
56 TestingProfile profile_;
59 TEST_F(MagnificationManagerTest, ChangeType) {
60 // Set full screen magnifier, and confirm the status is set successfully.
61 EnableMagnifier();
62 SetMagnifierType(ash::MAGNIFIER_FULL);
63 EXPECT_TRUE(IsMagnifierEnabled());
64 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
66 // Set partial screen magnifier, and confirm the change is ignored.
67 SetMagnifierType(ash::MAGNIFIER_PARTIAL);
68 EXPECT_TRUE(IsMagnifierEnabled());
69 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
71 // Disables magnifier, and confirm the status is set successfully.
72 DisableMagnifier();
73 EXPECT_FALSE(IsMagnifierEnabled());
74 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
77 } // namespace chromeos