Commit fde2e98d authored by achuith@chromium.org's avatar achuith@chromium.org

Additional debugging for gaia login.

* Use Oobe.addUserForTesting instead of chrome.send
* Merge multiple invocations of EvaluateJavaScriptInContext
* Take a screenshot if we time out on finding _GaiaLoginContext
* Increase timeout to find _GaiaLoginContext.
* Add a disabled test - test is disabled since it hits live gaia.

BUG=361862
TEST=manual
NOTRY=True

Review URL: https://codereview.chromium.org/252643002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266078 0039d316-1c4b-4281-b951-d872f2087c98
parent 17dc5b8d
...@@ -314,9 +314,6 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): ...@@ -314,9 +314,6 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
def _GaiaLoginContext(self): def _GaiaLoginContext(self):
oobe = self.oobe oobe = self.oobe
# TODO(achuith): Implement an api in the oobe instead of calling
# chrome.send.
oobe.ExecuteJavaScript("chrome.send('addUser');")
for gaia_context in range(15): for gaia_context in range(15):
try: try:
if oobe.EvaluateJavaScriptInContext( if oobe.EvaluateJavaScriptInContext(
...@@ -360,18 +357,24 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): ...@@ -360,18 +357,24 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
def _NavigateGaiaLogin(self): def _NavigateGaiaLogin(self):
"""Logs into the GAIA service with provided credentials.""" """Logs into the GAIA service with provided credentials."""
# TODO(achuith): Fake gaia service with a python server. logging.info('Invoking Oobe.addUserForTesting')
self._WaitForSigninScreen()
gaia_context = util.WaitFor(self._GaiaLoginContext, timeout=10)
oobe = self.oobe oobe = self.oobe
oobe.ExecuteJavaScriptInContext( util.WaitFor(lambda: oobe.EvaluateJavaScript(
"document.getElementById('Email').value='%s';" 'typeof Oobe !== \'undefined\''), 10)
% self.browser_options.username, gaia_context) oobe.ExecuteJavaScript('Oobe.addUserForTesting();')
oobe.ExecuteJavaScriptInContext(
"document.getElementById('Passwd').value='%s';" try:
% self.browser_options.password, gaia_context) gaia_context = util.WaitFor(self._GaiaLoginContext, timeout=30)
oobe.ExecuteJavaScriptInContext( except util.TimeoutException:
"document.getElementById('signIn').click();", gaia_context) self._cri.TakeScreenShot('add-user-screen')
raise
oobe.ExecuteJavaScriptInContext("""
document.getElementById('Email').value='%s';
document.getElementById('Passwd').value='%s';
document.getElementById('signIn').click();"""
% (self.browser_options.username, self.browser_options.password),
gaia_context)
self._WaitForLogin() self._WaitForLogin()
def _WaitForLogin(self): def _WaitForLogin(self):
......
...@@ -24,7 +24,8 @@ class CrOSTest(unittest.TestCase): ...@@ -24,7 +24,8 @@ class CrOSTest(unittest.TestCase):
self._password = options.browser_options.password self._password = options.browser_options.password
self._load_extension = None self._load_extension = None
def _CreateBrowser(self, autotest_ext=False, auto_login=True): def _CreateBrowser(self, autotest_ext=False, auto_login=True,
gaia_login=False, username=None, password=None):
"""Finds and creates a browser for tests. if autotest_ext is True, """Finds and creates a browser for tests. if autotest_ext is True,
also loads the autotest extension""" also loads the autotest extension"""
options = options_for_unittests.GetCopy() options = options_for_unittests.GetCopy()
...@@ -42,6 +43,12 @@ class CrOSTest(unittest.TestCase): ...@@ -42,6 +43,12 @@ class CrOSTest(unittest.TestCase):
self.assertTrue(browser_to_create) self.assertTrue(browser_to_create)
options.browser_options.create_browser_with_oobe = True options.browser_options.create_browser_with_oobe = True
options.browser_options.auto_login = auto_login options.browser_options.auto_login = auto_login
options.browser_options.gaia_login = gaia_login
if username is not None:
options.browser_options.username = username
if password is not None:
options.browser_options.password = password
return browser_to_create.Create() return browser_to_create.Create()
def _GetAutotestExtension(self, browser): def _GetAutotestExtension(self, browser):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment