Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10836187: [chromeos] pyauto tests should auto login by default on chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/pyautolib/policy_base.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 0b85086a0cc18d20660ff6d2a1efb544f455e2ed..a2e081bf7ec0d7af3b203fed948611db7a327358 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -209,10 +209,18 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
if self.IsChromeOS():
self.WaitUntil(lambda: not self.GetNetworkInfo()['offline_mode'])
- if (self.IsChromeOS() and self.ShouldOOBESkipToLogin() and
- not self.GetLoginInfo()['is_logged_in'] and
- self.GetOOBEScreenInfo()['screen_name'] != 'login'):
- self.SkipToLogin()
+ if (self.IsChromeOS() and not self.GetLoginInfo()['is_logged_in'] and
+ self.ShouldOOBESkipToLogin()):
+ if self.GetOOBEScreenInfo()['screen_name'] != 'login':
+ self.SkipToLogin()
+ if self.ShouldAutoLogin():
+ # Login with default creds.
+ sys.path.append('/usr/local') # to import autotest libs
+ from autotest.cros import constants
+ creds = constants.CREDENTIALS['$default']
+ self.Login(creds[0], creds[1])
+ assert self.GetLoginInfo()['is_logged_in']
+ logging.info('Logged in as %s.' % creds[0])
# If we are connected to any RemoteHosts, create PyAuto
# instances on the remote sides and set them up too.
@@ -302,6 +310,23 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
assert self.IsChromeOS()
return True
+ def ShouldAutoLogin(self):
+ """Determine if we should auto-login on ChromeOS at browser startup.
+
+ To be used for tests that expect user to be logged in before running test,
+ without caring which user. ShouldOOBESkipToLogin() should return True
+ for this to take effect.
+
+ Override and return False to not auto login, for tests where login is part
+ of the use case.
+
+ Returns:
+ True, if chrome should auto login after startup.
+ False, otherwise.
+ """
+ assert self.IsChromeOS()
+ return True
+
def CloseChromeOnChromeOS(self):
"""Gracefully exit chrome on ChromeOS."""
« no previous file with comments | « chrome/test/pyautolib/policy_base.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698