| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5f29f2f561631ce707e8241eb4c6c9e1b67572e1
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc
|
| @@ -0,0 +1,119 @@
|
| +// Copyright (c) 2012 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 "base/command_line.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
|
| +#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
|
| +#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
|
| +#include "chrome/browser/chromeos/login/helper.h"
|
| +#include "chrome/browser/chromeos/login/login_utils.h"
|
| +#include "chrome/browser/chromeos/login/user_manager.h"
|
| +#include "chrome/browser/chromeos/login/user_manager_impl.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/common/chrome_notification_types.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "chrome/test/base/testing_profile.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +class MagnificationManagerTest : public CrosInProcessBrowserTest {
|
| + protected:
|
| + MagnificationManagerTest() {}
|
| + virtual ~MagnificationManagerTest() {}
|
| +
|
| + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| + command_line->AppendSwitch(switches::kLoginManager);
|
| + command_line->AppendSwitchASCII(switches::kLoginProfile,
|
| + TestingProfile::kTestUserProfileDir);
|
| + }
|
| +
|
| + Profile* profile() {
|
| + Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
|
| + DCHECK(profile);
|
| + return profile;
|
| + }
|
| +
|
| + PrefServiceBase* prefs() {
|
| + return PrefServiceBase::FromBrowserContext(profile());
|
| + }
|
| +
|
| + void SetScreenManagnifierTypeToPref(accessibility::ScreenMagnifierType type) {
|
| + prefs()->SetString(prefs::kScreenMagnifierType,
|
| + ScreenMagnifierNameFromType(type));
|
| + }
|
| +
|
| + void CheckCurrentScreenMagnifierType(
|
| + accessibility::ScreenMagnifierType type) {
|
| + EXPECT_EQ(MagnificationManager::GetInstance()->GetScreenMagnifierType(),
|
| + type);
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MagnificationManagerTest);
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, Login) {
|
| + // Confirms that magnifier is enabled on the login screen.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Logs in.
|
| + UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
|
| + UserManager::Get()->SessionStarted();
|
| +
|
| + // Confirms that magnifier is disabled just after login.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF);
|
| +
|
| + // Enables magnifier.
|
| + SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Confirms that magnifier is enabled.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, WorkingWithPref) {
|
| + // Logs in
|
| + UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
|
| + UserManager::Get()->SessionStarted();
|
| +
|
| + // Confirms that magnifier is disabled just after login.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF);
|
| +
|
| + // Sets the pref as true to enable magnifier.
|
| + SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Confirms that magnifier is enabled.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Sets the pref as false to disabled magnifier.
|
| + SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_OFF);
|
| +
|
| + // Confirms that magnifier is disabled.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF);
|
| +
|
| + // Sets the pref as true to enable magnifier again.
|
| + SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Confirms that magnifier is enabled.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedPref) {
|
| + // Loads the profile of the user.
|
| + UserManager::Get()->UserLoggedIn("owner@invalid.domain", true);
|
| +
|
| + // Sets the pref as true to enable magnifier before login.
|
| + SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL);
|
| +
|
| + // Logs in.
|
| + UserManager::Get()->SessionStarted();
|
| +
|
| + // Confirms that magnifier is enabled just after login.
|
| + CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL);
|
| +}
|
| +
|
| +} // namespace chromeos
|
|
|