OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import ctypes | 6 import ctypes |
7 import email | 7 import email |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import platform | 10 import platform |
11 import shutil | 11 import shutil |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 assert pyauto.PyUITest.IsLinux() or pyauto.PyUITest.IsChromeOS() | 324 assert pyauto.PyUITest.IsLinux() or pyauto.PyUITest.IsChromeOS() |
325 process = subprocess.Popen('ps h -o rss -p %s' % pid, shell=True, | 325 process = subprocess.Popen('ps h -o rss -p %s' % pid, shell=True, |
326 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 326 stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
327 stdout = process.communicate()[0] | 327 stdout = process.communicate()[0] |
328 if stdout: | 328 if stdout: |
329 return float(stdout.strip()) / 1024 | 329 return float(stdout.strip()) / 1024 |
330 else: | 330 else: |
331 return 0 | 331 return 0 |
332 | 332 |
333 | 333 |
334 def GetCredsKey(): | |
335 """Get the credential key associated with a bot on the waterfall. | |
336 | |
337 The key is associated with the proper credentials in the text data file stored | |
338 in the private directory. The key determines a bot's OS and machine name. Each | |
339 key credential is associated with its own user/password value. This allows | |
340 sync integration tests to run in parallel on all bots. | |
341 | |
342 Returns: | |
343 A String of the credentials key for the specified bot. Otherwise None. | |
344 """ | |
345 if pyauto.PyUITest.IsWin(): | |
346 system_name = 'win' | |
347 elif pyauto.PyUITest.IsLinux(): | |
348 system_name = 'linux' | |
349 elif pyauto.PyUITest.IsMac(): | |
350 system_name = 'mac' | |
351 else: | |
352 return None | |
353 node = platform.uname()[1].split('.')[0] | |
354 creds_key = 'test_google_acct_%s_%s' % (system_name, node) | |
355 return creds_key | |
356 | |
357 | |
358 def SignInToSyncAndVerifyState(test, account_key): | |
359 """Sign into sync and verify that it was successful. | |
360 | |
361 Args: | |
362 test: derived from pyauto.PyUITest - base class for UI test cases. | |
363 account_key: the credentials key in the private account dictionary file. | |
364 """ | |
365 creds = test.GetPrivateInfo()[account_key] | |
366 username = creds['username'] | |
367 password = creds['password'] | |
368 test.assertTrue(test.GetSyncInfo()['last synced'] == 'Never') | |
369 test.assertTrue(test.SignInToSync(username, password)) | |
370 test.assertTrue(test.GetSyncInfo()['last synced'] == 'Just now') | |
371 | |
372 | |
373 def LoginToDevice(test, test_account='test_google_account'): | 334 def LoginToDevice(test, test_account='test_google_account'): |
374 """Login to the Chromeos device using the given test account. | 335 """Login to the Chromeos device using the given test account. |
375 | 336 |
376 If no test account is specified, we use test_google_account as the default. | 337 If no test account is specified, we use test_google_account as the default. |
377 You can choose test accounts from - | 338 You can choose test accounts from - |
378 chrome/test/data/pyauto_private/private_tests_info.txt | 339 chrome/test/data/pyauto_private/private_tests_info.txt |
379 | 340 |
380 Args: | 341 Args: |
381 test_account: The account used to login to the Chromeos device. | 342 test_account: The account used to login to the Chromeos device. |
382 """ | 343 """ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 """This test opens crosh. | 411 """This test opens crosh. |
451 | 412 |
452 This function assumes that no browser windows are open. | 413 This function assumes that no browser windows are open. |
453 """ | 414 """ |
454 self.assertEqual(0, self.GetBrowserWindowCount()) | 415 self.assertEqual(0, self.GetBrowserWindowCount()) |
455 self.OpenCrosh() | 416 self.OpenCrosh() |
456 self.assertEqual(1, self.GetBrowserWindowCount()) | 417 self.assertEqual(1, self.GetBrowserWindowCount()) |
457 self.assertEqual(1, self.GetTabCount(), | 418 self.assertEqual(1, self.GetTabCount(), |
458 msg='Could not open crosh') | 419 msg='Could not open crosh') |
459 self.assertEqual('crosh', self.GetActiveTabTitle()) | 420 self.assertEqual('crosh', self.GetActiveTabTitle()) |
OLD | NEW |