Index: chrome/test/functional/perf_endure.py |
diff --git a/chrome/test/functional/perf_endure.py b/chrome/test/functional/perf_endure.py |
index fed79f499f00ed363d487cb579e2d3ff11c9f4d2..e0cb6541e2f7057cefcbc24e5db3e13f67861d03 100755 |
--- a/chrome/test/functional/perf_endure.py |
+++ b/chrome/test/functional/perf_endure.py |
@@ -33,7 +33,7 @@ import pyauto_utils |
import remote_inspector_client |
import selenium.common.exceptions |
from selenium.webdriver.support.ui import WebDriverWait |
- |
+import test_utils |
class NotSupportedEnvironmentError(RuntimeError): |
"""Represent an error raised since the environment (OS) is not supported.""" |
@@ -540,6 +540,60 @@ class ChromeEndureBaseTest(perf.BasePerfTest): |
return True |
+ def _GetConfig(self): |
+ """Load endure configuration file.""" |
+ config_file = os.path.join(os.path.dirname(__file__), 'endure_config.txt') |
+ if not os.path.exists(config_file): |
+ return {} |
dennis_jeffrey
2012/08/09 17:29:04
if the file doesn't exist, let's return a dictiona
fdeng1
2012/08/11 00:11:27
Done.
|
+ else: |
+ return pyauto.PyUITest.EvalDataFrom(config_file) |
+ |
+ def _LoginToGoogleAccount(self, account_key='test_google_account'): |
+ """Login to Google account. |
+ |
+ Try to use the url and credential specified in endure_config.txt. |
+ If it fails to load valid information, try to login via public |
+ google account url with credential in |
+ src/data/pyauto_private/private_tests_info.txt. |
+ |
+ Args: |
+ account_key: The string key in private_tests_info.txt which is associated |
+ with the test account login credentials to use. It will only |
+ be used when fail to load credential from endure_config.txt |
+ |
+ Raises: |
+ RuntimeError: if could not get credential information. |
+ """ |
dennis_jeffrey
2012/08/09 17:29:04
if this function successfully finds credentials to
fdeng1
2012/08/11 00:11:27
Added a log message for each case.
On 2012/08/09 1
|
+ config = self._GetConfig() |
+ google_account_url = (config['google_account_url'] |
+ if 'google_account_url' in config |
+ else None) |
+ username = (config['username'] if 'username' in config else None) |
+ password = (config['password'] if 'password' in config else None) |
+ if not username or not password: |
+ private_file = os.path.join(pyauto.PyUITest.DataDir(), 'pyauto_private', |
dennis_jeffrey
2012/08/09 17:29:04
can we just use the superclass's _LoginToGoogleAcc
fdeng1
2012/08/11 00:11:27
I tried to make config file also effective for per
|
+ 'private_tests_info.txt') |
+ if os.path.exists(private_file): |
+ google_account_url = None |
+ creds = self.GetPrivateInfo()[account_key] |
+ username = creds['username'] |
+ password = creds['password'] |
+ else: |
+ message = \ |
+ 'Please sepecify credential information in %s.\n' \ |
+ 'Format:\n\t{\n' \ |
+ '\t "username": "my_username",\n' \ |
+ '\t "password": "my_password",\n' \ |
+ '\t "google_account_url": "https://my-google-account-server/",\n' \ |
+ '\t "gmail_url: "https://my-gmail-server",\n' \ |
+ '\t "plus_url": "https://my-plus-server",\n' \ |
+ '\t "docs_url": "https://my-docs-server",\n\t}\n' \ |
+ % os.path.join(os.path.dirname(__file__), 'endure_config.txt') |
+ raise RuntimeError('Could not get credential information.\n' + message) |
+ test_utils.GoogleAccountsLogin( |
+ self, username, password, url=google_account_url) |
+ self.NavigateToURL('about:blank') |
+ |
class ChromeEndureControlTest(ChromeEndureBaseTest): |
"""Control tests for Chrome Endure.""" |
@@ -602,7 +656,10 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Gmail. |
self._LoginToGoogleAccount(account_key='test_google_account_gmail') |
- self.NavigateToURL('http://www.gmail.com') |
+ gmail_url = (self._GetConfig()['gmail_url'] |
+ if 'gmail_url' in self._GetConfig() |
+ else 'http://www.gmail.com') |
+ self.NavigateToURL(gmail_url) |
loaded_tab_title = self.GetActiveTabTitle() |
self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
msg='Loaded tab title does not contain "%s": "%s"' % |
@@ -940,7 +997,10 @@ class ChromeEndureDocsTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Google Docs. |
self._LoginToGoogleAccount() |
- self.NavigateToURL('http://docs.google.com') |
+ docs_url = (self._GetConfig()['docs_url'] |
+ if 'docs_url' in self._GetConfig() |
+ else 'http://docs.google.com') |
+ self.NavigateToURL(docs_url) |
self.assertTrue( |
self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in |
self.GetActiveTabTitle(), |
@@ -1012,7 +1072,10 @@ class ChromeEndurePlusTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Google Plus. |
self._LoginToGoogleAccount() |
- self.NavigateToURL('http://plus.google.com') |
+ plus_url = (self._GetConfig()['plus_url'] |
+ if 'plus_url' in self._GetConfig() |
+ else 'http://plus.google.com') |
+ self.NavigateToURL(plus_url) |
loaded_tab_title = self.GetActiveTabTitle() |
self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
msg='Loaded tab title does not contain "%s": "%s"' % |