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

Unified Diff: chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc

Issue 11280287: Magnifier: Prevent useless operation in enabling/disabling magnifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix test failure (MagnificationManagerTest.ChangeMagnifierType) Created 8 years 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: chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
diff --git a/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc b/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
index 1c528968f517ea1be9f407141fa40a69630976a2..f21f54884db1058ba4a62b68f5fd1ed24651123b 100644
--- a/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
+++ b/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
@@ -22,9 +22,11 @@
namespace chromeos {
-class MagnificationManagerTest : public CrosInProcessBrowserTest {
+class MagnificationManagerTest : public CrosInProcessBrowserTest,
+ public MagnificationObserver {
protected:
- MagnificationManagerTest() {}
+ MagnificationManagerTest() : observed_(false),
+ observed_type_(ash::MAGNIFIER_OFF) {}
virtual ~MagnificationManagerTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
@@ -33,6 +35,20 @@ class MagnificationManagerTest : public CrosInProcessBrowserTest {
TestingProfile::kTestUserProfileDir);
}
+ virtual void SetUpOnMainThread() OVERRIDE {
+ MagnificationManager::Get()->AddObserver(this);
+ }
+
+ virtual void CleanUpOnMainThread() OVERRIDE {
+ MagnificationManager::Get()->RemoveObserver(this);
+ }
+
+ // Overridden from MagnificationObserever:
+ virtual void OnMagnifierTypeChanged(ash::MagnifierType new_type) OVERRIDE {
+ observed_ = true;
+ observed_type_ = new_type;
+ }
+
Profile* profile() {
Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
DCHECK(profile);
@@ -44,7 +60,7 @@ class MagnificationManagerTest : public CrosInProcessBrowserTest {
}
void SetScreenManagnifierType(ash::MagnifierType type) {
- MagnificationManager::GetInstance()->SetMagnifier(type);
+ MagnificationManager::Get()->SetMagnifier(type);
}
void SetScreenManagnifierTypeToPref(ash::MagnifierType type) {
@@ -54,10 +70,11 @@ class MagnificationManagerTest : public CrosInProcessBrowserTest {
void CheckCurrentMagnifierType(
ash::MagnifierType type) {
- EXPECT_EQ(MagnificationManager::GetInstance()->GetMagnifierType(),
- type);
+ EXPECT_EQ(MagnificationManager::Get()->GetMagnifierType(), type);
}
+ bool observed_;
+ ash::MagnifierType observed_type_;
DISALLOW_COPY_AND_ASSIGN(MagnificationManagerTest);
};
@@ -158,4 +175,42 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedPref) {
CheckCurrentMagnifierType(ash::MAGNIFIER_FULL);
}
+IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangingTypeInvokesObserver) {
+ // Logs in
+ UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
+ UserManager::Get()->SessionStarted();
+
+ // Before the test, sets to full magnifier.
+ SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL);
+ CheckCurrentMagnifierType(ash::MAGNIFIER_FULL);
+
+ // Disables magnifier and confirms observer is invoked.
+ observed_ = false;
+ SetScreenManagnifierTypeToPref(ash::MAGNIFIER_OFF);
+ EXPECT_TRUE(observed_);
+ EXPECT_EQ(observed_type_, ash::MAGNIFIER_OFF);
+ CheckCurrentMagnifierType(ash::MAGNIFIER_OFF);
+
+ // Enables full screen magnifier and confirms observer is invoked.
+ observed_ = false;
+ SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL);
+ EXPECT_TRUE(observed_);
+ EXPECT_EQ(observed_type_, ash::MAGNIFIER_FULL);
+ CheckCurrentMagnifierType(ash::MAGNIFIER_FULL);
+
+ // Enables partial screen magnifier and confirms observer is invoked.
+ observed_ = false;
+ SetScreenManagnifierTypeToPref(ash::MAGNIFIER_PARTIAL);
+ EXPECT_TRUE(observed_);
+ EXPECT_EQ(observed_type_, ash::MAGNIFIER_PARTIAL);
+ CheckCurrentMagnifierType(ash::MAGNIFIER_PARTIAL);
+
+ // Disables magnifier again and confirms observer is invoked.
+ observed_ = false;
+ SetScreenManagnifierTypeToPref(ash::MAGNIFIER_OFF);
+ EXPECT_TRUE(observed_);
+ EXPECT_EQ(observed_type_, ash::MAGNIFIER_OFF);
+ CheckCurrentMagnifierType(ash::MAGNIFIER_OFF);
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/accessibility/magnification_manager.cc ('k') | chrome/browser/chromeos/chrome_browser_main_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698