summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 09:40:25 +0000
committeraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-07 09:40:25 +0000
commit4bcf6d66458141778e7e9eed4ee85d5a77c04b30 (patch)
treefef158072967400cbd86288e6643a9943dd82f92
parent1d4ace78936a9722a653d04b48e0e685131b8119 (diff)
downloadchromium_src-4bcf6d66458141778e7e9eed4ee85d5a77c04b30.zip
chromium_src-4bcf6d66458141778e7e9eed4ee85d5a77c04b30.tar.gz
chromium_src-4bcf6d66458141778e7e9eed4ee85d5a77c04b30.tar.bz2
[cros] Get rid of cached WizardController usage.
Cached version of WizardController was used in the browser tests. It brought to wrong controller usage. Note, it usually worked because we create new WizardController right after deletion, so new instance usually has the same address. BUG=chromium-os:27376 TEST=browser_tests works even under ASan Review URL: http://codereview.chromium.org/9605012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125370 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen_browsertest.cc11
-rw-r--r--chrome/browser/chromeos/login/network_screen_browsertest.cc12
-rw-r--r--chrome/browser/chromeos/login/update_screen_browsertest.cc11
-rw-r--r--chrome/browser/chromeos/login/wizard_controller_browsertest.cc67
-rw-r--r--chrome/browser/chromeos/login/wizard_in_process_browser_test.cc4
-rw-r--r--chrome/browser/chromeos/login/wizard_in_process_browser_test.h8
6 files changed, 59 insertions, 54 deletions
diff --git a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen_browsertest.cc b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen_browsertest.cc
index c30c134..d591723 100644
--- a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen_browsertest.cc
+++ b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -25,17 +25,18 @@ class EnterpriseEnrollmentScreenTest : public WizardInProcessBrowserTest {
};
IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentScreenTest, TestCancel) {
- ASSERT_TRUE(controller() != NULL);
+ ASSERT_TRUE(WizardController::default_controller() != NULL);
EnterpriseEnrollmentScreen* enterprise_enrollment_screen =
- controller()->GetEnterpriseEnrollmentScreen();
+ WizardController::default_controller()->GetEnterpriseEnrollmentScreen();
ASSERT_TRUE(enterprise_enrollment_screen != NULL);
MockScreenObserver mock_screen_observer;
static_cast<WizardScreen*>(enterprise_enrollment_screen)->screen_observer_ =
&mock_screen_observer;
- ASSERT_EQ(controller()->current_screen(), enterprise_enrollment_screen);
+ ASSERT_EQ(WizardController::default_controller()->current_screen(),
+ enterprise_enrollment_screen);
EXPECT_CALL(mock_screen_observer,
OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED));
@@ -43,7 +44,7 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentScreenTest, TestCancel) {
Mock::VerifyAndClearExpectations(&mock_screen_observer);
static_cast<WizardScreen*>(enterprise_enrollment_screen)->screen_observer_ =
- controller();
+ WizardController::default_controller();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/network_screen_browsertest.cc b/chrome/browser/chromeos/login/network_screen_browsertest.cc
index 5854387..5040cb8 100644
--- a/chrome/browser/chromeos/login/network_screen_browsertest.cc
+++ b/chrome/browser/chromeos/login/network_screen_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -112,16 +112,18 @@ class NetworkScreenTest : public WizardInProcessBrowserTest {
virtual void SetUpOnMainThread() {
mock_screen_observer_.reset(new MockScreenObserver());
- ASSERT_TRUE(controller() != NULL);
- network_screen_ = controller()->GetNetworkScreen();
+ ASSERT_TRUE(WizardController::default_controller() != NULL);
+ network_screen_ =
+ WizardController::default_controller()->GetNetworkScreen();
ASSERT_TRUE(network_screen_ != NULL);
- ASSERT_EQ(controller()->current_screen(), network_screen_);
+ ASSERT_EQ(WizardController::default_controller()->current_screen(),
+ network_screen_);
network_screen_->screen_observer_ = mock_screen_observer_.get();
ASSERT_TRUE(network_screen_->actor() != NULL);
}
virtual void TearDownInProcessBrowserTestFixture() {
- network_screen_->screen_observer_ = controller();
+ network_screen_->screen_observer_ = WizardController::default_controller();
CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
DBusThreadManager::Shutdown();
}
diff --git a/chrome/browser/chromeos/login/update_screen_browsertest.cc b/chrome/browser/chromeos/login/update_screen_browsertest.cc
index 97c3ccb..e236b05e 100644
--- a/chrome/browser/chromeos/login/update_screen_browsertest.cc
+++ b/chrome/browser/chromeos/login/update_screen_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -77,15 +77,16 @@ class UpdateScreenTest : public WizardInProcessBrowserTest {
virtual void SetUpOnMainThread() {
mock_screen_observer_.reset(new MockScreenObserver());
- ASSERT_TRUE(controller() != NULL);
- update_screen_ = controller()->GetUpdateScreen();
+ ASSERT_TRUE(WizardController::default_controller() != NULL);
+ update_screen_ = WizardController::default_controller()->GetUpdateScreen();
ASSERT_TRUE(update_screen_ != NULL);
- ASSERT_EQ(controller()->current_screen(), update_screen_);
+ ASSERT_EQ(WizardController::default_controller()->current_screen(),
+ update_screen_);
update_screen_->screen_observer_ = mock_screen_observer_.get();
}
virtual void TearDownInProcessBrowserTestFixture() {
- update_screen_->screen_observer_ = (controller());
+ update_screen_->screen_observer_ = (WizardController::default_controller());
WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
DBusThreadManager::Shutdown();
}
diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
index 8332cf3..65c1d80 100644
--- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
@@ -54,8 +54,8 @@ class MockOutShowHide : public T {
#define MOCK(mock_var, screen_name, mocked_class, actor_class) \
mock_var = new MockOutShowHide<mocked_class, actor_class>( \
- controller(), new actor_class); \
- controller()->screen_name.reset(mock_var); \
+ WizardController::default_controller(), new actor_class); \
+ WizardController::default_controller()->screen_name.reset(mock_var); \
EXPECT_CALL(*mock_var, Show()).Times(0); \
EXPECT_CALL(*mock_var, Hide()).Times(0);
@@ -70,8 +70,9 @@ class WizardControllerTest : public WizardInProcessBrowserTest {
};
IN_PROC_BROWSER_TEST_F(WizardControllerTest, SwitchLanguage) {
- ASSERT_TRUE(controller() != NULL);
- controller()->AdvanceToScreen(WizardController::kNetworkScreenName);
+ ASSERT_TRUE(WizardController::default_controller() != NULL);
+ WizardController::default_controller()->AdvanceToScreen(
+ WizardController::kNetworkScreenName);
// Checking the default locale. Provided that the profile is cleared in SetUp.
EXPECT_EQ("en-US", g_browser_process->GetApplicationLocale());
@@ -119,15 +120,16 @@ class WizardControllerFlowTest : public WizardControllerTest {
MockEnterpriseEnrollmentScreen, MockEnterpriseEnrollmentScreenActor);
// Switch to the initial screen.
- EXPECT_EQ(NULL, controller()->current_screen());
+ EXPECT_EQ(NULL, WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
- controller()->AdvanceToScreen(WizardController::kNetworkScreenName);
+ WizardController::default_controller()->AdvanceToScreen(
+ WizardController::kNetworkScreenName);
return ret;
}
void OnExit(ScreenObserver::ExitCodes exit_code) {
- controller()->OnExit(exit_code);
+ WizardController::default_controller()->OnExit(exit_code);
}
MockOutShowHide<MockNetworkScreen, MockNetworkScreenActor>*
@@ -143,12 +145,14 @@ class WizardControllerFlowTest : public WizardControllerTest {
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowMain) {
EXPECT_TRUE(ExistingUserController::current_controller() == NULL);
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(1);
OnExit(ScreenObserver::NETWORK_CONNECTED);
- EXPECT_EQ(controller()->GetEulaScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetEulaScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_eula_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(1);
EXPECT_CALL(*mock_update_screen_, Show()).Times(1);
@@ -156,24 +160,26 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowMain) {
// Let update screen smooth time process (time = 0ms).
ui_test_utils::RunAllPendingInMessageLoop();
- EXPECT_EQ(controller()->GetUpdateScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetUpdateScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, Hide()).Times(0);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(0);
OnExit(ScreenObserver::UPDATE_INSTALLED);
EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
- set_controller(NULL);
}
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowErrorUpdate) {
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(0);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(1);
EXPECT_CALL(*mock_update_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);
OnExit(ScreenObserver::NETWORK_CONNECTED);
- EXPECT_EQ(controller()->GetEulaScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetEulaScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_eula_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(1);
EXPECT_CALL(*mock_update_screen_, Show()).Times(1);
@@ -181,58 +187,61 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowErrorUpdate) {
// Let update screen smooth time process (time = 0ms).
ui_test_utils::RunAllPendingInMessageLoop();
- EXPECT_EQ(controller()->GetUpdateScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetUpdateScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, Hide()).Times(0);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(0);
EXPECT_CALL(*mock_eula_screen_, Hide()).Times(0); // last transition
OnExit(ScreenObserver::UPDATE_ERROR_UPDATING);
EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
- set_controller(NULL);
}
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowEulaDeclined) {
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(0);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(1);
EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);
OnExit(ScreenObserver::NETWORK_CONNECTED);
- EXPECT_EQ(controller()->GetEulaScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetEulaScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_eula_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_network_screen_, Hide()).Times(0); // last transition
OnExit(ScreenObserver::EULA_BACK);
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
}
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowErrorNetwork) {
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
OnExit(ScreenObserver::NETWORK_OFFLINE);
EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
- set_controller(NULL);
}
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
ControlFlowEnterpriseEnrollmentCompleted) {
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(0);
EXPECT_CALL(*mock_enterprise_enrollment_screen_, Show()).Times(1);
EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);
- controller()->AdvanceToScreen(
+ WizardController::default_controller()->AdvanceToScreen(
WizardController::kEnterpriseEnrollmentScreenName);
EnterpriseEnrollmentScreen* screen =
- controller()->GetEnterpriseEnrollmentScreen();
- EXPECT_EQ(screen, controller()->current_screen());
+ WizardController::default_controller()->GetEnterpriseEnrollmentScreen();
+ EXPECT_EQ(screen, WizardController::default_controller()->current_screen());
std::string user;
EXPECT_FALSE(screen->IsAutoEnrollment(&user));
OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED);
EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
- set_controller(NULL);
}
IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
@@ -241,7 +250,8 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
switches::kLoginScreen,
WizardController::kLoginScreenName);
- EXPECT_EQ(controller()->GetNetworkScreen(), controller()->current_screen());
+ EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
+ WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_update_screen_, StartUpdate()).Times(0);
LoginUtils::Set(new TestLoginUtils(kUsername, kPassword));
@@ -258,8 +268,8 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
ExistingUserController::current_controller()->CompleteLogin(kUsername,
kPassword);
EnterpriseEnrollmentScreen* screen =
- controller()->GetEnterpriseEnrollmentScreen();
- EXPECT_EQ(screen, controller()->current_screen());
+ WizardController::default_controller()->GetEnterpriseEnrollmentScreen();
+ EXPECT_EQ(screen, WizardController::default_controller()->current_screen());
std::string user;
EXPECT_TRUE(screen->IsAutoEnrollment(&user));
// This is the main expectation: after auto-enrollment, login is resumed.
@@ -269,7 +279,6 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
browser_shutdown::SetTryingToQuit(true);
// Run the tasks posted to complete the login:
MessageLoop::current()->RunAllPending();
- set_controller(NULL);
}
// TODO(nkostylev): Add test for WebUI accelerators http://crosbug.com/22571
diff --git a/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc b/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc
index 45befb7..cfcdd86 100644
--- a/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc
+++ b/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -17,7 +17,6 @@ namespace chromeos {
WizardInProcessBrowserTest::WizardInProcessBrowserTest(const char* screen_name)
: screen_name_(screen_name),
- controller_(NULL),
host_(NULL) {
}
@@ -28,7 +27,6 @@ Browser* WizardInProcessBrowserTest::CreateBrowser(Profile* profile) {
if (!screen_name_.empty()) {
browser::ShowLoginWizard(screen_name_.c_str(), gfx::Size(1024, 600));
- controller_ = WizardController::default_controller();
host_ = BaseLoginDisplayHost::default_host();
}
return NULL;
diff --git a/chrome/browser/chromeos/login/wizard_in_process_browser_test.h b/chrome/browser/chromeos/login/wizard_in_process_browser_test.h
index 74344a5..9b0f4c9 100644
--- a/chrome/browser/chromeos/login/wizard_in_process_browser_test.h
+++ b/chrome/browser/chromeos/login/wizard_in_process_browser_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -36,14 +36,8 @@ class WizardInProcessBrowserTest : public CrosInProcessBrowserTest {
virtual Browser* CreateBrowser(Profile* profile) OVERRIDE;
virtual void CleanUpOnMainThread() OVERRIDE;
- WizardController* controller() const { return controller_; }
- void set_controller(WizardController* controller) {
- controller_ = controller;
- }
-
private:
std::string screen_name_;
- WizardController* controller_;
LoginDisplayHost* host_;
DISALLOW_COPY_AND_ASSIGN(WizardInProcessBrowserTest);