diff options
author | avayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 19:11:40 +0000 |
---|---|---|
committer | avayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 19:11:40 +0000 |
commit | 26332c67c0802f210e735bd96217adce29361f38 (patch) | |
tree | 8c05752d600ec80e264256a03effcf5ac005a283 /chrome | |
parent | fe4d4f0e0d4424e16380c84700573e880c96465d (diff) | |
download | chromium_src-26332c67c0802f210e735bd96217adce29361f38.zip chromium_src-26332c67c0802f210e735bd96217adce29361f38.tar.gz chromium_src-26332c67c0802f210e735bd96217adce29361f38.tar.bz2 |
Fixed flakiness of AccountScreenTest:
- test server to serve account creation page
- deferred creation of login windows to tune account screen for testing
- refactored InProcessBrowserTest to shutdown test reliably.
BUG=39310
TEST=Run browser_tests with --gtest_filter=AccountScreenTest.*
Review URL: http://codereview.chromium.org/1452001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
13 files changed, 202 insertions, 103 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 0fded1c..017ac15 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -913,7 +913,11 @@ int BrowserMain(const MainFunctionParams& parameters) { PrefService* user_prefs = profile->GetPrefs(); DCHECK(user_prefs); - OptionallyRunChromeOSLoginManager(parsed_command_line); + // Tests should be able to tune login manager before showing it. + // Thus only show login manager in normal (non-testing) mode. + if (!parameters.ui_task) { + OptionallyRunChromeOSLoginManager(parsed_command_line); + } // Importing other browser settings is done in a browser-like process // that exits when this task has finished. diff --git a/chrome/browser/chromeos/login/account_screen.cc b/chrome/browser/chromeos/login/account_screen.cc index 2e8a2bf..e7abdce 100644 --- a/chrome/browser/chromeos/login/account_screen.cc +++ b/chrome/browser/chromeos/login/account_screen.cc @@ -64,18 +64,32 @@ const char kCreateAccountJS[] = // AccountScreen, public: AccountScreen::AccountScreen(WizardScreenDelegate* delegate) : ViewScreen<AccountCreationView>(delegate) { + if (!new_account_page_url_.get()) + new_account_page_url_.reset(new GURL(kCreateAccountPageUrl)); } AccountScreen::~AccountScreen() { } +// static +void AccountScreen::set_new_account_page_url(const GURL& url) { + new_account_page_url_.reset(new GURL(url)); +} + +// static +scoped_ptr<GURL> AccountScreen::new_account_page_url_; +// static +bool AccountScreen::check_for_https_ = true; + /////////////////////////////////////////////////////////////////////////////// // AccountScreen, ViewScreen implementation: void AccountScreen::CreateView() { ViewScreen<AccountCreationView>::CreateView(); view()->SetAccountCreationViewDelegate(this); +} - GURL url(kCreateAccountPageUrl); +void AccountScreen::Refresh() { + GURL url(*new_account_page_url_); Profile* profile = ProfileManager::GetDefaultProfile(); view()->InitDOM(profile, SiteInstance::CreateSiteInstanceForURL(profile, url)); @@ -96,7 +110,7 @@ void AccountScreen::LoadingStateChanged(TabContents* source) { delegate()->GetObserver(this)->OnExit(ScreenObserver::ACCOUNT_CREATED); } else if (url == kCreateAccountBackUrl) { delegate()->GetObserver(this)->OnExit(ScreenObserver::ACCOUNT_CREATE_BACK); - } else if (!source->GetURL().SchemeIsSecure()) { + } else if (check_for_https_ && !source->GetURL().SchemeIsSecure()) { delegate()->GetObserver(this)->OnExit(ScreenObserver::CONNECTION_FAILED); } } diff --git a/chrome/browser/chromeos/login/account_screen.h b/chrome/browser/chromeos/login/account_screen.h index 71c52de..95de5dc 100644 --- a/chrome/browser/chromeos/login/account_screen.h +++ b/chrome/browser/chromeos/login/account_screen.h @@ -7,10 +7,12 @@ #include <string> +#include "base/scoped_ptr.h" #include "chrome/browser/chromeos/login/account_creation_view.h" #include "chrome/browser/chromeos/login/view_screen.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" +class GURL; class WizardScreenDelegate; namespace chromeos { @@ -27,9 +29,15 @@ class AccountScreen : public ViewScreen<AccountCreationView>, const std::string& password); virtual void OnPageLoadFailed(const std::string& url); + // Sets the url for account creation. Used in tests. + static void set_new_account_page_url(const GURL& url); + // Sets the flag forcing to check for HTTPS. Used in tests. + static void set_check_for_https(bool check) { check_for_https_ = check; } + private: // ViewScreen implementation: virtual void CreateView(); + virtual void Refresh(); virtual AccountCreationView* AllocateView(); // TabContentsDelegate implementation: @@ -55,6 +63,11 @@ class AccountScreen : public ViewScreen<AccountCreationView>, virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} virtual bool HandleContextMenu(const ContextMenuParams& params); + // Url of account creation page. Overriden by tests. + static scoped_ptr<GURL> new_account_page_url_; + // Indicates if we should check for HTTPS scheme. Overriden by tests. + static bool check_for_https_; + DISALLOW_COPY_AND_ASSIGN(AccountScreen); }; diff --git a/chrome/browser/chromeos/login/account_screen_browsertest.cc b/chrome/browser/chromeos/login/account_screen_browsertest.cc index 922098f..9282b7d 100644 --- a/chrome/browser/chromeos/login/account_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/account_screen_browsertest.cc @@ -2,46 +2,39 @@ // 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 "base/message_loop.h" +#include <string> + +#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" #include "chrome/browser/chromeos/login/account_screen.h" #include "chrome/browser/chromeos/login/wizard_controller.h" -#include "chrome/common/chrome_switches.h" #include "chrome/test/in_process_browser_test.h" -#include "chrome/test/ui_test_utils.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" namespace chromeos { -class AccountScreenTest : public InProcessBrowserTest { +class AccountScreenTest : public WizardInProcessBrowserTest { public: - AccountScreenTest() { + AccountScreenTest(): WizardInProcessBrowserTest("account") { } protected: - virtual void SetUpCommandLine(CommandLine* command_line) { - command_line->AppendSwitch(switches::kLoginManager); - command_line->AppendSwitchWithValue(switches::kLoginScreen, L"account"); - command_line->AppendSwitchWithValue(switches::kLoginScreenSize, - L"1024,600"); - } - - virtual Browser* CreateBrowser(Profile* profile) { - return NULL; + // Overriden from WizardInProcessBrowserTest: + virtual void SetUpWizard() { + HTTPTestServer* server = StartHTTPServer(); + ASSERT_TRUE(server != NULL); + GURL new_account_page_url(server->TestServerPage("new_account.html")); + AccountScreen::set_new_account_page_url(new_account_page_url); + AccountScreen::set_check_for_https(false); } private: DISALLOW_COPY_AND_ASSIGN(AccountScreenTest); }; -IN_PROC_BROWSER_TEST_F(AccountScreenTest, DISABLED_TestBasic) { - WizardController* controller = WizardController::default_controller(); - ASSERT_TRUE(NULL != controller); - EXPECT_EQ(controller->GetAccountScreen(), controller->current_screen()); - // Close login manager windows. - MessageLoop::current()->DeleteSoon(FROM_HERE, controller); - // End the message loop to quit the test since there's no browser window - // created. - MessageLoop::current()->Quit(); +IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestBasic) { + ASSERT_TRUE(controller()); + EXPECT_EQ(controller()->GetAccountScreen(), controller()->current_screen()); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/login_manager_view.cc b/chrome/browser/chromeos/login/login_manager_view.cc index 1233a17..c0bd4f0 100644 --- a/chrome/browser/chromeos/login/login_manager_view.cc +++ b/chrome/browser/chromeos/login/login_manager_view.cc @@ -308,7 +308,7 @@ void LoginManagerView::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == sign_in_button_) { Login(); - } else { + } else if (observer_) { observer_->OnExit(ScreenObserver::LOGIN_CREATE_ACCOUNT); } } diff --git a/chrome/browser/chromeos/login/login_manager_view.h b/chrome/browser/chromeos/login/login_manager_view.h index d4898ed..ceb7726 100644 --- a/chrome/browser/chromeos/login/login_manager_view.h +++ b/chrome/browser/chromeos/login/login_manager_view.h @@ -37,6 +37,8 @@ class LoginManagerView : public views::View, // Initialize view layout. void Init(); + // Overrides observer for testing. + void set_observer(ScreenObserver* observer) { observer_ = observer; } // Update strings from the resources. Executed on language change. void UpdateLocalizedStrings(); diff --git a/chrome/browser/chromeos/login/login_manager_view_browsertest.cc b/chrome/browser/chromeos/login/login_manager_view_browsertest.cc index 8d20d21..b5cb691 100644 --- a/chrome/browser/chromeos/login/login_manager_view_browsertest.cc +++ b/chrome/browser/chromeos/login/login_manager_view_browsertest.cc @@ -4,15 +4,15 @@ #include "base/message_loop.h" #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" -#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" #include "chrome/browser/chromeos/cros/mock_login_library.h" #include "chrome/browser/chromeos/login/login_manager_view.h" #include "chrome/browser/chromeos/login/login_utils.h" +#include "chrome/browser/chromeos/login/mock_screen_observer.h" #include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" #include "chrome/browser/chromeos/login/wizard_screen.h" -#include "chrome/common/chrome_switches.h" -#include "testing/gtest/include/gtest/gtest.h" #include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" namespace chromeos { @@ -73,24 +73,14 @@ class MockLoginUtils : public LoginUtils { DISALLOW_COPY_AND_ASSIGN(MockLoginUtils); }; -class LoginManagerViewTest : public CrosInProcessBrowserTest { +class LoginManagerViewTest : public WizardInProcessBrowserTest { public: - LoginManagerViewTest() { + LoginManagerViewTest(): WizardInProcessBrowserTest("login") { } protected: - virtual void SetUpCommandLine(CommandLine* command_line) { - command_line->AppendSwitch(switches::kLoginManager); - command_line->AppendSwitchWithValue(switches::kLoginScreen, - WizardController::kLoginScreenName); - } - - virtual Browser* CreateBrowser(Profile* profile) { - // Don't need to create separate browser window for OOBE wizard. - return NULL; - } - virtual void SetUpInProcessBrowserTestFixture() { + WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); InitStatusAreaMocks(); SetStatusAreaMocksExpectations(); @@ -109,8 +99,9 @@ class LoginManagerViewTest : public CrosInProcessBrowserTest { } virtual void TearDownInProcessBrowserTestFixture() { - CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); + WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); test_api()->SetLoginLibrary(NULL); + test_api()->SetCryptohomeLibrary(NULL); } private: @@ -121,16 +112,21 @@ class LoginManagerViewTest : public CrosInProcessBrowserTest { }; IN_PROC_BROWSER_TEST_F(LoginManagerViewTest, TestBasic) { - WizardController* controller = WizardController::default_controller(); - ASSERT_TRUE(controller != NULL); - ASSERT_EQ(controller->current_screen(), controller->GetLoginScreen()); - LoginManagerView* login = controller->GetLoginScreen()->view(); + ASSERT_TRUE(controller() != NULL); + ASSERT_EQ(controller()->current_screen(), controller()->GetLoginScreen()); + + scoped_ptr<MockScreenObserver> mock_screen_observer( + new MockScreenObserver()); + EXPECT_CALL(*mock_screen_observer, + OnExit(ScreenObserver::LOGIN_SIGN_IN_SELECTED)) + .Times(1); + + LoginManagerView* login = controller()->GetLoginScreen()->view(); + login->set_observer(mock_screen_observer.get()); login->SetUsername(kUsername); login->SetPassword(kPassword); login->Login(); - - // End the message loop to quit the test. - MessageLoop::current()->Quit(); + login->set_observer(NULL); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/mock_screen_observer.h b/chrome/browser/chromeos/login/mock_screen_observer.h new file mode 100644 index 0000000..3d67671 --- /dev/null +++ b/chrome/browser/chromeos/login/mock_screen_observer.h @@ -0,0 +1,30 @@ +// Copyright (c) 2010 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. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_SCREEN_OBSERVER_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_SCREEN_OBSERVER_H_ + +#include <string> + +#include "chrome/browser/chromeos/login/screen_observer.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace chromeos { + +// Interface that handles notifications received from any of login wizard +// screens. +class MockScreenObserver : public ScreenObserver { + public: + MockScreenObserver() {} + virtual ~MockScreenObserver() {} + MOCK_METHOD1(OnExit, void(ExitCodes)); + MOCK_METHOD1(OnSwitchLanguage, void(const std::string&)); + MOCK_METHOD2(OnSetUserNamePassword, + void(const std::string&, const std::string&)); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_SCREEN_OBSERVER_H_ + diff --git a/chrome/browser/chromeos/login/network_screen_browsertest.cc b/chrome/browser/chromeos/login/network_screen_browsertest.cc index 42afe3e..01dbdca 100644 --- a/chrome/browser/chromeos/login/network_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/network_screen_browsertest.cc @@ -7,7 +7,7 @@ #include "app/l10n_util.h" #include "base/message_loop.h" #include "base/string_util.h" -#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" +#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/mock_login_library.h" #include "chrome/browser/chromeos/cros/mock_network_library.h" @@ -16,7 +16,6 @@ #include "chrome/browser/chromeos/login/network_screen.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_screen.h" -#include "chrome/common/chrome_switches.h" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gmock/include/gmock/gmock.h" @@ -28,17 +27,12 @@ using ::testing::Return; using ::testing::ReturnRef; using ::testing::_; -class NetworkScreenTest : public CrosInProcessBrowserTest { +class NetworkScreenTest : public WizardInProcessBrowserTest { public: - NetworkScreenTest() { + NetworkScreenTest(): WizardInProcessBrowserTest("network") { } protected: - virtual void SetUpCommandLine(CommandLine* command_line) { - command_line->AppendSwitch(switches::kLoginManager); - command_line->AppendSwitchWithValue(switches::kLoginScreen, "network"); - } - virtual void SetUpInProcessBrowserTestFixture() { InitStatusAreaMocks(); @@ -75,10 +69,6 @@ class NetworkScreenTest : public CrosInProcessBrowserTest { test_api()->SetLoginLibrary(NULL); } - virtual Browser* CreateBrowser(Profile* profile) { - return NULL; - } - void EthernetExpectations(bool connected, bool connecting) { EXPECT_CALL(*mock_network_library_, ethernet_connected()) .Times(connected ? 2 : 1) @@ -101,7 +91,7 @@ class NetworkScreenTest : public CrosInProcessBrowserTest { EXPECT_CALL(*mock_network_library_, wifi_networks()) .Times(1) .WillOnce((ReturnRef(wifi_networks_))); - EXPECT_CALL(*mock_network_library_, cellular_networks()) + EXPECT_CALL(*mock_network_library_, cellular_networks()) .Times(1) .WillOnce((ReturnRef(cellular_networks_))); } @@ -116,31 +106,22 @@ class NetworkScreenTest : public CrosInProcessBrowserTest { }; IN_PROC_BROWSER_TEST_F(NetworkScreenTest, TestBasic) { - WizardController* controller = WizardController::default_controller(); - ASSERT_TRUE(controller != NULL); - NetworkScreen* network_screen = controller->GetNetworkScreen(); + ASSERT_TRUE(controller() != NULL); + NetworkScreen* network_screen = controller()->GetNetworkScreen(); ASSERT_TRUE(network_screen != NULL); - ASSERT_EQ(network_screen, controller->current_screen()); + ASSERT_EQ(network_screen, controller()->current_screen()); NetworkSelectionView* network_view = network_screen->view(); ASSERT_TRUE(network_view != NULL); ASSERT_EQ(1, network_screen->GetItemCount()); EXPECT_EQ(l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE), network_screen->GetItemAt(0)); - - // Close login manager windows. - // TODO(nkostylev): Figure out how to close OOBE windows in base class. - MessageLoop::current()->DeleteSoon(FROM_HERE, - WizardController::default_controller()); - // End the message loop to quit the test. - MessageLoop::current()->Quit(); } IN_PROC_BROWSER_TEST_F(NetworkScreenTest, TestOobeNetworksConnected) { - WizardController* controller = WizardController::default_controller(); NetworkLibrary* network_library = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - NetworkScreen* network_screen = controller->GetNetworkScreen(); + NetworkScreen* network_screen = controller()->GetNetworkScreen(); ASSERT_TRUE(network_screen != NULL); NetworkSelectionView* network_view = network_screen->view(); ASSERT_TRUE(network_view != NULL); @@ -150,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(NetworkScreenTest, TestOobeNetworksConnected) { network_screen->NetworkChanged(network_library); // When OOBE flow is active network selection should be explicit. - ASSERT_EQ(network_screen, controller->current_screen()); + ASSERT_EQ(network_screen, controller()->current_screen()); ASSERT_EQ(2, network_screen->GetItemCount()); EXPECT_EQ(l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), network_screen->GetItemAt(1)); @@ -169,7 +150,7 @@ IN_PROC_BROWSER_TEST_F(NetworkScreenTest, TestOobeNetworksConnected) { .Times(1) .WillOnce((ReturnRef(wifi_ssid))); network_screen->NetworkChanged(network_library); - ASSERT_EQ(network_screen, controller->current_screen()); + ASSERT_EQ(network_screen, controller()->current_screen()); ASSERT_EQ(2, network_screen->GetItemCount()); EXPECT_EQ(ASCIIToWide(wifi_ssid), network_screen->GetItemAt(1)); @@ -180,14 +161,11 @@ IN_PROC_BROWSER_TEST_F(NetworkScreenTest, TestOobeNetworksConnected) { .Times(1) .WillOnce((ReturnRef(wifi_ssid))); network_screen->NetworkChanged(network_library); - ASSERT_EQ(network_screen, controller->current_screen()); + ASSERT_EQ(network_screen, controller()->current_screen()); ASSERT_EQ(3, network_screen->GetItemCount()); EXPECT_EQ(l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), network_screen->GetItemAt(1)); EXPECT_EQ(ASCIIToWide(wifi_ssid), network_screen->GetItemAt(2)); - - MessageLoop::current()->DeleteSoon(FROM_HERE, controller); - MessageLoop::current()->Quit(); } } // namespace chromeos diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc index 8593a14..2da0a21 100644 --- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc +++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc @@ -5,29 +5,24 @@ #include "app/l10n_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/login/wizard_controller.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/in_process_browser_test.h" +#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "unicode/locid.h" -class WizardControllerTest : public InProcessBrowserTest { +class WizardControllerTest : public chromeos::WizardInProcessBrowserTest { protected: - WizardControllerTest() {} - virtual Browser* CreateBrowser(Profile* profile) { return NULL; } - virtual void SetUpCommandLine(CommandLine* command_line) { - command_line->AppendSwitch(switches::kLoginManager); - } + WizardControllerTest(): chromeos::WizardInProcessBrowserTest("oobe") {} private: DISALLOW_COPY_AND_ASSIGN(WizardControllerTest); }; IN_PROC_BROWSER_TEST_F(WizardControllerTest, SwitchLanguage) { - WizardController* const wizard = WizardController::default_controller(); - ASSERT_TRUE(wizard); - views::View *current_screen = wizard->contents(); - ASSERT_TRUE(current_screen); + WizardController* const wizard = controller(); + ASSERT_TRUE(wizard != NULL); + views::View* current_screen = wizard->contents(); + ASSERT_TRUE(current_screen != NULL); // Checking the default locale. Provided that the profile is cleared in SetUp. EXPECT_EQ("en-US", g_browser_process->GetApplicationLocale()); @@ -50,10 +45,4 @@ IN_PROC_BROWSER_TEST_F(WizardControllerTest, SwitchLanguage) { const std::wstring ar_str = l10n_util::GetString(IDS_NETWORK_SELECTION_TITLE); EXPECT_NE(fr_str, ar_str); - - // Close login manager windows. It does not delete itself if wizard - // not completed. - MessageLoop::current()->DeleteSoon(FROM_HERE, wizard); - // End the message loop to quit the test. - MessageLoop::current()->Quit(); } diff --git a/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc b/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc new file mode 100644 index 0000000..ae94f0e --- /dev/null +++ b/chrome/browser/chromeos/login/wizard_in_process_browser_test.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2010 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 "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" + +#include "base/message_loop.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/views/browser_dialogs.h" + +namespace chromeos { + +WizardInProcessBrowserTest::WizardInProcessBrowserTest(const char* screen_name) + : screen_name_(screen_name), + controller_(NULL) { +} + +Browser* WizardInProcessBrowserTest::CreateBrowser(Profile* profile) { + SetUpWizard(); + + browser::ShowLoginWizard(screen_name_.c_str(), gfx::Size(1024, 600)); + controller_ = WizardController::default_controller(); + return NULL; +} + +void WizardInProcessBrowserTest::CleanUpOnMainThread() { + delete controller_; +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/login/wizard_in_process_browser_test.h b/chrome/browser/chromeos/login/wizard_in_process_browser_test.h new file mode 100644 index 0000000..d9b634e --- /dev/null +++ b/chrome/browser/chromeos/login/wizard_in_process_browser_test.h @@ -0,0 +1,47 @@ +// Copyright (c) 2010 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. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_IN_PROCESS_BROWSER_TEST_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_IN_PROCESS_BROWSER_TEST_H_ + +#include <string> + +#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" + +class Browser; +class Profile; +class WizardController; + +namespace chromeos { + +// Base class for test related to login wizard and its screens. +// Instead of creating Chrome browser window it creates login wizard window +// with specified parameters and allows to customize environment at the +// right moment in time before wizard is created. +class WizardInProcessBrowserTest : public CrosInProcessBrowserTest { + public: + explicit WizardInProcessBrowserTest(const char* screen_name); + + protected: + // Can be overriden by derived test fixtures to set up environment after + // browser is created but wizard is not shown yet. + virtual void SetUpWizard() {} + + // Overriden from InProcessBrowserTest: + virtual Browser* CreateBrowser(Profile* profile); + virtual void CleanUpOnMainThread(); + + WizardController* controller() const { return controller_; } + + private: + std::string screen_name_; + WizardController* controller_; + + DISALLOW_COPY_AND_ASSIGN(WizardInProcessBrowserTest); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_IN_PROCESS_BROWSER_TEST_H_ + diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index ecaa251..51ceeb8 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1200,6 +1200,8 @@ 'test/test_launcher/test_runner.cc', 'test/test_launcher/test_runner.h', 'test/unit/chrome_test_suite.h', + 'browser/chromeos/login/wizard_in_process_browser_test.cc', + 'browser/chromeos/login/wizard_in_process_browser_test.h', # Actual test sources 'browser/autocomplete/autocomplete_browsertest.cc', 'browser/browser_browsertest.cc', |