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/test/ash_test_base.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/chromeos/accessibility_types.h"
16 void EnableMagnifier() {
17 return MagnificationManager::Get()->SetMagnifierEnabled(true);
20 void DisableMagnifier() {
21 return MagnificationManager::Get()->SetMagnifierEnabled(false);
24 bool IsMagnifierEnabled() {
25 return MagnificationManager::Get()->IsMagnifierEnabled();
28 ui::MagnifierType
GetMagnifierType() {
29 return MagnificationManager::Get()->GetMagnifierType();
32 void SetMagnifierType(ui::MagnifierType type
) {
33 return MagnificationManager::Get()->SetMagnifierType(type
);
38 class MagnificationManagerTest
: public ash::test::AshTestBase
{
40 MagnificationManagerTest() {
43 virtual void SetUp() override
{
44 ash::test::AshTestBase::SetUp();
45 MagnificationManager::Initialize();
46 ASSERT_TRUE(MagnificationManager::Get());
47 MagnificationManager::Get()->SetProfileForTest(&profile_
);
50 virtual void TearDown() override
{
51 MagnificationManager::Shutdown();
52 ash::test::AshTestBase::TearDown();
55 TestingProfile profile_
;
58 TEST_F(MagnificationManagerTest
, ChangeType
) {
59 // Set full screen magnifier, and confirm the status is set successfully.
61 SetMagnifierType(ui::MAGNIFIER_FULL
);
62 EXPECT_TRUE(IsMagnifierEnabled());
63 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL
);
65 // Set partial screen magnifier, and confirm the change is ignored.
66 SetMagnifierType(ui::MAGNIFIER_PARTIAL
);
67 EXPECT_TRUE(IsMagnifierEnabled());
68 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL
);
70 // Disables magnifier, and confirm the status is set successfully.
72 EXPECT_FALSE(IsMagnifierEnabled());
73 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL
);
76 } // namespace chromeos