| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 6 | 6 |
| 7 #include "ash/magnifier/magnifier_constants.h" | |
| 8 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 9 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/chromeos/accessibility_types.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 void EnableMagnifier() { | 17 void EnableMagnifier() { |
| 18 return MagnificationManager::Get()->SetMagnifierEnabled(true); | 18 return MagnificationManager::Get()->SetMagnifierEnabled(true); |
| 19 } | 19 } |
| 20 | 20 |
| 21 void DisableMagnifier() { | 21 void DisableMagnifier() { |
| 22 return MagnificationManager::Get()->SetMagnifierEnabled(false); | 22 return MagnificationManager::Get()->SetMagnifierEnabled(false); |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool IsMagnifierEnabled() { | 25 bool IsMagnifierEnabled() { |
| 26 return MagnificationManager::Get()->IsMagnifierEnabled(); | 26 return MagnificationManager::Get()->IsMagnifierEnabled(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 ash::MagnifierType GetMagnifierType() { | 29 ui::MagnifierType GetMagnifierType() { |
| 30 return MagnificationManager::Get()->GetMagnifierType(); | 30 return MagnificationManager::Get()->GetMagnifierType(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void SetMagnifierType(ash::MagnifierType type) { | 33 void SetMagnifierType(ui::MagnifierType type) { |
| 34 return MagnificationManager::Get()->SetMagnifierType(type); | 34 return MagnificationManager::Get()->SetMagnifierType(type); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 class MagnificationManagerTest : public ash::test::AshTestBase { | 39 class MagnificationManagerTest : public ash::test::AshTestBase { |
| 40 public: | 40 public: |
| 41 MagnificationManagerTest() { | 41 MagnificationManagerTest() { |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void SetUp() override { | 44 virtual void SetUp() override { |
| 45 ash::test::AshTestBase::SetUp(); | 45 ash::test::AshTestBase::SetUp(); |
| 46 MagnificationManager::Initialize(); | 46 MagnificationManager::Initialize(); |
| 47 ASSERT_TRUE(MagnificationManager::Get()); | 47 ASSERT_TRUE(MagnificationManager::Get()); |
| 48 MagnificationManager::Get()->SetProfileForTest(&profile_); | 48 MagnificationManager::Get()->SetProfileForTest(&profile_); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void TearDown() override { | 51 virtual void TearDown() override { |
| 52 MagnificationManager::Shutdown(); | 52 MagnificationManager::Shutdown(); |
| 53 ash::test::AshTestBase::TearDown(); | 53 ash::test::AshTestBase::TearDown(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 TestingProfile profile_; | 56 TestingProfile profile_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TEST_F(MagnificationManagerTest, ChangeType) { | 59 TEST_F(MagnificationManagerTest, ChangeType) { |
| 60 // Set full screen magnifier, and confirm the status is set successfully. | 60 // Set full screen magnifier, and confirm the status is set successfully. |
| 61 EnableMagnifier(); | 61 EnableMagnifier(); |
| 62 SetMagnifierType(ash::MAGNIFIER_FULL); | 62 SetMagnifierType(ui::MAGNIFIER_FULL); |
| 63 EXPECT_TRUE(IsMagnifierEnabled()); | 63 EXPECT_TRUE(IsMagnifierEnabled()); |
| 64 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL); | 64 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL); |
| 65 | 65 |
| 66 // Set partial screen magnifier, and confirm the change is ignored. | 66 // Set partial screen magnifier, and confirm the change is ignored. |
| 67 SetMagnifierType(ash::MAGNIFIER_PARTIAL); | 67 SetMagnifierType(ui::MAGNIFIER_PARTIAL); |
| 68 EXPECT_TRUE(IsMagnifierEnabled()); | 68 EXPECT_TRUE(IsMagnifierEnabled()); |
| 69 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL); | 69 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL); |
| 70 | 70 |
| 71 // Disables magnifier, and confirm the status is set successfully. | 71 // Disables magnifier, and confirm the status is set successfully. |
| 72 DisableMagnifier(); | 72 DisableMagnifier(); |
| 73 EXPECT_FALSE(IsMagnifierEnabled()); | 73 EXPECT_FALSE(IsMagnifierEnabled()); |
| 74 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL); | 74 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace chromeos | 77 } // namespace chromeos |
| OLD | NEW |