From c922d0a6a91d3e8623823ef8fda9218fa8718618 Mon Sep 17 00:00:00 2001 From: "nirnimesh@chromium.org" Date: Fri, 14 Sep 2012 00:32:14 +0000 Subject: [chromeos] Make Login() automation reliably work for relogin scenarios. NOTIFICATION_LOGIN_WEBUI_VISIBLE is the notification that gets emitted for all cases of login webui. Use that. This also fixes the Login() automation for relogin scenarios. Also, fix the typo in the auth-ext path used in tests (in pyauto.py). BUG=chromium:139166 TEST=None Review URL: https://chromiumcodereview.appspot.com/10928168 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156695 0039d316-1c4b-4281-b951-d872f2087c98 --- .../automation_provider_observers_chromeos.cc | 13 ++--------- .../testing_automation_provider_chromeos.cc | 5 ++-- chrome/test/functional/chromeos_device_policy.py | 27 ++++------------------ chrome/test/pyautolib/pyauto.py | 5 +--- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/chrome/browser/automation/automation_provider_observers_chromeos.cc b/chrome/browser/automation/automation_provider_observers_chromeos.cc index e80d839..440091f 100644 --- a/chrome/browser/automation/automation_provider_observers_chromeos.cc +++ b/chrome/browser/automation/automation_provider_observers_chromeos.cc @@ -64,13 +64,7 @@ OOBEWebuiReadyObserver::OOBEWebuiReadyObserver(AutomationProvider* automation) WizardController::default_controller()->current_screen()) { OOBEWebuiReady(); } else { - registrar_.Add(this, chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN, - content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED, - content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_LOADED, - content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_DEMO_WEBUI_LOADED, + registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, content::NotificationService::AllSources()); } } @@ -79,10 +73,7 @@ void OOBEWebuiReadyObserver::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN || - type == chrome::NOTIFICATION_LOGIN_USER_IMAGES_LOADED || - type == chrome::NOTIFICATION_LOGIN_WEBUI_LOADED || - type == chrome::NOTIFICATION_DEMO_WEBUI_LOADED); + DCHECK(type == chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE); OOBEWebuiReady(); } diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc index a5e7dd6..b8115b53 100644 --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc @@ -358,7 +358,6 @@ void TestingAutomationProvider::LoginAsGuest(DictionaryValue* args, void TestingAutomationProvider::SubmitLoginForm(DictionaryValue* args, IPC::Message* reply_message) { AutomationJSONReply reply(this, reply_message); - VLOG(2) << "TestingAutomationProvider::StartLogin"; std::string username, password; if (!args->GetString("username", &username) || @@ -377,8 +376,8 @@ void TestingAutomationProvider::SubmitLoginForm(DictionaryValue* args, // WebUI login. chromeos::WebUILoginDisplay* webui_login_display = static_cast(controller->login_display()); - VLOG(2) << "TestingAutomationProvider::StartLogin ShowSigninScreenForCreds(" - << username << ", " << password << ")"; + VLOG(2) << "TestingAutomationProvider::SubmitLoginForm " + << "ShowSigninScreenForCreds(" << username << ", " << password << ")"; webui_login_display->ShowSigninScreenForCreds(username, password); reply.SendSuccess(NULL); diff --git a/chrome/test/functional/chromeos_device_policy.py b/chrome/test/functional/chromeos_device_policy.py index 6bbcc42..b801d65 100644 --- a/chrome/test/functional/chromeos_device_policy.py +++ b/chrome/test/functional/chromeos_device_policy.py @@ -112,13 +112,8 @@ class ChromeosDevicePolicy(policy_base.PolicyTestBase): ommitted since the broken behavior should be fixed rather than protected by tests. """ - # TODO(nirnimesh): Remove show_user_names policy below when - # Login() automation can reliably handle relogin scenario. - # crbug.com/139166 - # No whitelist - self.SetDevicePolicy({'allow_new_users': True, - 'show_user_names': False}) + self.SetDevicePolicy({'allow_new_users': True}) self._Login(user_index=0, expect_success=True) self.Logout() @@ -128,21 +123,18 @@ class ChromeosDevicePolicy(policy_base.PolicyTestBase): self.Logout() self.SetDevicePolicy({'allow_new_users': True, - 'user_whitelist': [], - 'show_user_names': False}) + 'user_whitelist': []}) self._Login(user_index=0, expect_success=True) self.Logout() # Populated whitelist - self.SetDevicePolicy({'user_whitelist': [self._usernames[0]], - 'show_user_names': False}) + self.SetDevicePolicy({'user_whitelist': [self._usernames[0]]}) self._Login(user_index=0, expect_success=True) self.Logout() self._Login(user_index=1, expect_success=False) self.SetDevicePolicy({'allow_new_users': True, - 'user_whitelist': [self._usernames[0]], - 'show_user_names': False}) + 'user_whitelist': [self._usernames[0]]}) self._Login(user_index=0, expect_success=True) self.Logout() self._Login(user_index=1, expect_success=True) @@ -150,8 +142,7 @@ class ChromeosDevicePolicy(policy_base.PolicyTestBase): # New users not allowed, populated whitelist self.SetDevicePolicy({'allow_new_users': False, - 'user_whitelist': [self._usernames[0]], - 'show_user_names': False}) + 'user_whitelist': [self._usernames[0]]}) self._Login(user_index=0, expect_success=True) self.Logout() self._Login(user_index=1, expect_success=False) @@ -200,10 +191,6 @@ class ChromeosDevicePolicy(policy_base.PolicyTestBase): self.Logout() self.assertEqual(timezone, self.GetTimeInfo()['timezone']) - # Work around until crosbug.com/139166 is fixed - self.ExecuteJavascriptInOOBEWebUI( - 'Oobe.showSigninUI();' - 'window.domAutomationController.send("ok");') def testTimezoneSettingWithPolicy(self): @@ -214,10 +201,6 @@ class ChromeosDevicePolicy(policy_base.PolicyTestBase): # screen. Something like a browser restart may work, too. self._Login(user_index=1, expect_success=True) self.Logout() - # Work around until crosbug.com/139166 is fixed - self.ExecuteJavascriptInOOBEWebUI( - 'Oobe.showSigninUI();' - 'window.domAutomationController.send("ok");') self.assertEqual(self._timezones[0], self.GetTimeInfo()['timezone']) diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index bcffdf5..9282a26 100755 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -276,11 +276,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): These are flags needed to facilitate testing. Override this function to use a custom set of Chrome flags. """ - auth_ext_path = ('--auth-ext-path=/usr/local/autotest/deps/pyauto_dep/' + + auth_ext_path = ('/usr/local/autotest/deps/pyauto_dep/' + 'test_src/chrome/browser/resources/gaia_auth') - # TODO(nirnimesh): remove when chromeos side changes land. - if not os.path.exists(auth_ext_path): - auth_ext_path = '/usr/share/chromeos-assets/gaia_auth' if self.IsChromeOS(): return [ '--homepage=about:blank', -- cgit v1.1