Index: chrome/test/functional/perf.py |
diff --git a/chrome/test/functional/perf.py b/chrome/test/functional/perf.py |
index 84b1910dd39b49e737a6c4d4a36ae346e191f510..e94cccf0e93ba3b1e89f605351b8a9bad4d3a261 100755 |
--- a/chrome/test/functional/perf.py |
+++ b/chrome/test/functional/perf.py |
@@ -597,15 +597,70 @@ class BasePerfTest(pyauto.PyUITest): |
self._PrintSummaryResults(description, timings, 'milliseconds', graph_name) |
+ def _GetConfig(self): |
fdeng1
2012/08/11 00:11:27
I just moved the changes to perf.py so that the cr
dennis_jeffrey
2012/08/15 01:21:17
Good, now we can let the user change the login cre
|
+ """Load endure configuration file.""" |
dennis_jeffrey
2012/08/15 01:21:17
'endure' --> 'perf test'
dennis_jeffrey
2012/08/15 01:21:17
Add a "Returns:" section to this docstring to ment
fdeng1
2012/08/16 17:42:49
Done.
fdeng1
2012/08/16 17:42:49
Done.
|
+ config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg') |
+ config = {'google_account_url': 'https://accounts.google.com/', |
+ 'gmail_url': 'https://www.gmail.com', |
+ 'plus_url': 'http://plus.google.com', |
+ 'docs_url': 'http://docs.google.com'} |
+ if os.path.exists(config_file): |
+ try: |
+ config.update(pyauto.PyUITest.EvalDataFrom(config_file)) |
dennis_jeffrey
2012/08/15 01:21:17
If you address my comment from the .cfg file that
fdeng1
2012/08/16 17:42:49
Done.
|
+ except SyntaxError: |
+ logging.info('Could not read %s', config_file) |
dennis_jeffrey
2012/08/15 01:21:17
maybe you can also log the text that comes along w
fdeng1
2012/08/16 17:42:49
Done.
|
+ return config |
+ |
def _LoginToGoogleAccount(self, account_key='test_google_account'): |
"""Logs in to a test Google account. |
+ Try to use the url and credential specified in perf.cfg. |
+ 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. |
dennis_jeffrey
2012/08/15 01:21:17
We can shorten this description to something like
fdeng1
2012/08/16 17:42:49
Done.
|
+ |
Args: |
- account_key: The string key associated with the test account login |
- credentials to use. |
- """ |
- creds = self.GetPrivateInfo()[account_key] |
- test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) |
+ 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 perf.cfg |
+ |
+ Raises: |
+ RuntimeError: if could not get credential information. |
+ """ |
+ config_file = os.path.join(os.path.dirname(__file__), 'perf.cfg') |
+ config = self._GetConfig() |
+ google_account_url = config.get('google_account_url') |
+ username = config.get('username') |
+ password = config.get('password') |
+ if not username or not password: |
+ private_file = os.path.join(pyauto.PyUITest.DataDir(), 'pyauto_private', |
+ 'private_tests_info.txt') |
+ if os.path.exists(private_file): |
+ google_account_url = 'https://accounts.google.com/' |
+ creds = self.GetPrivateInfo()[account_key] |
+ username = creds['username'] |
+ password = creds['password'] |
+ logging.info( |
+ 'Google account credential not defined in %s, using %s', |
+ config_file, private_file) |
+ 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' \ |
+ % config_file |
+ raise RuntimeError('Could not get credential information.\n' + message) |
+ else: |
dennis_jeffrey
2012/08/15 01:21:17
I think it would be simpler to re-arrange the logi
fdeng1
2012/08/16 17:42:49
Done.
|
+ logging.info( |
+ 'Using google account credential from %s', |
+ os.path.join(os.path.dirname(__file__), 'perf.cfg')) |
+ test_utils.GoogleAccountsLogin( |
+ self, username, password, url=google_account_url) |
self.NavigateToURL('about:blank') # Clear the existing tab. |
def _GetCPUUsage(self): |