| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os |
| 7 import time |
| 8 |
| 6 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
| 7 import pyauto | 10 import pyauto |
| 8 | 11 |
| 9 | 12 |
| 10 class ChromeosPrefsTest(pyauto.PyUITest): | 13 class ChromeosPrefsTest(pyauto.PyUITest): |
| 11 """TestCase for ChromeOS Preferences.""" | 14 """TestCase for ChromeOS Preferences.""" |
| 12 | 15 |
| 16 # Defined in src/chrome/browser/chromeos/login/user_manager.cc |
| 17 k_logged_in_users = 'LoggedInUsers' |
| 18 k_user_images = 'UserImages' |
| 19 |
| 13 def testDefaultUserImage(self): | 20 def testDefaultUserImage(self): |
| 14 """Verify changing default user image prefs work.""" | 21 """Verify changing default user image prefs work.""" |
| 15 | 22 |
| 16 # Defined in src/chrome/browser/chromeos/login/user_manager.cc | |
| 17 k_logged_in_users = 'LoggedInUsers' | |
| 18 k_user_images = 'UserImages' | |
| 19 # Defined in src/chrome/browser/chromeos/login/default_user_images.cc | 23 # Defined in src/chrome/browser/chromeos/login/default_user_images.cc |
| 20 image1 = u'default:4' | 24 image1 = u'default:4' |
| 21 image2 = u'default:5' | 25 image2 = u'default:5' |
| 22 | 26 |
| 23 for image in image1, image2: | 27 for image in image1, image2: |
| 24 logged_in_user = \ | 28 logged_in_user = \ |
| 25 self.GetLocalStatePrefsInfo().Prefs(k_logged_in_users)[0] | 29 self.GetLocalStatePrefsInfo().Prefs( |
| 30 ChromeosPrefsTest.k_logged_in_users)[0] |
| 26 user_images = {} | 31 user_images = {} |
| 27 user_images[logged_in_user] = image | 32 user_images[logged_in_user] = image |
| 28 self.SetLocalStatePrefs(k_user_images, user_images) | 33 self.SetLocalStatePrefs( ChromeosPrefsTest.k_user_images, user_images) |
| 29 self.RestartBrowser(clear_profile=False) | 34 self.RestartBrowser(clear_profile=False) |
| 30 current_user_images = self.GetLocalStatePrefsInfo().Prefs(k_user_images) | 35 current_user_images = self.GetLocalStatePrefsInfo().Prefs( |
| 36 ChromeosPrefsTest.k_user_images) |
| 31 current_image = current_user_images.get(logged_in_user) | 37 current_image = current_user_images.get(logged_in_user) |
| 32 self.assertEqual(image, current_image) | 38 self.assertEqual(image, current_image, |
| 39 msg='Default user image was not set in preferences.') |
| 40 |
| 41 def testCaptureUserPhoto(self): |
| 42 """Verify capturing/saving user photo works.""" |
| 43 |
| 44 logged_in_user = \ |
| 45 self.GetLocalStatePrefsInfo().Prefs( |
| 46 ChromeosPrefsTest.k_logged_in_users)[0] |
| 47 # Defined in src/chrome/browser/chromeos/login/user_manager.cc |
| 48 expected_photo_name = logged_in_user + '.png' |
| 49 |
| 50 self.CaptureProfilePhoto() |
| 51 |
| 52 for i in range(2): |
| 53 current_user_images = self.GetLocalStatePrefsInfo().Prefs( |
| 54 ChromeosPrefsTest.k_user_images) |
| 55 current_image_path = current_user_images.get(logged_in_user) |
| 56 self.assertTrue(expected_photo_name in current_image_path, |
| 57 msg='Captured user photo was not set in preferences.') |
| 58 self.assertTrue(os.path.isfile(current_image_path), |
| 59 msg='Image file was not saved.') and \ |
| 60 self.assertTrue(os.path.getsize(current_image_path) > 1000, |
| 61 msg='Image file may not be valid.' ) |
| 62 if not i: |
| 63 self.RestartBrowser(clear_profile=False) |
| 33 | 64 |
| 34 | 65 |
| 35 if __name__ == '__main__': | 66 if __name__ == '__main__': |
| 36 pyauto_functional.Main() | 67 pyauto_functional.Main() |
| 37 | |
| OLD | NEW |