Chromium Code Reviews| 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 pyauto_functional # Must be imported before pyauto | 6 import pyauto_functional # Must be imported before pyauto |
| 7 import pyauto | 7 import pyauto |
| 8 | 8 |
| 9 | 9 |
| 10 class ChromeosPrefsTest(pyauto.PyUITest): | 10 class ChromeosPrefsTest(pyauto.PyUITest): |
| 11 """TestCase for ChromeOS Preferences.""" | 11 """TestCase for ChromeOS Preferences.""" |
| 12 | 12 |
| 13 # Defined in src/chrome/browser/chromeos/login/user_manager.cc | |
| 14 k_logged_in_users = 'LoggedInUsers' | |
|
Nirnimesh
2011/07/30 10:32:31
I don't think python constants need to have a k_ p
frankf
2011/08/01 19:31:09
This was to match variable name in user_manager.cc
| |
| 15 k_user_images = 'UserImages' | |
| 16 # Defined in src/chrome/browser/chromeos/login/default_user_images.cc | |
| 17 default_image_prefix = 'default:' | |
|
Nirnimesh
2011/07/30 10:32:31
nah.. move it into testDefaultUserImage
image1 =
frankf
2011/08/01 19:31:09
Done.
| |
| 18 | |
| 13 def testDefaultUserImage(self): | 19 def testDefaultUserImage(self): |
| 14 """Verify changing default user image prefs work.""" | 20 """Verify changing default user image prefs work.""" |
| 15 | 21 |
| 16 # Defined in src/chrome/browser/chromeos/login/user_manager.cc | 22 image1 = ChromeosPrefsTest.default_image_prefix + '4' |
| 17 k_logged_in_users = 'LoggedInUsers' | 23 image2 = ChromeosPrefsTest.default_image_prefix + '5' |
| 18 k_user_images = 'UserImages' | |
| 19 # Defined in src/chrome/browser/chromeos/login/default_user_images.cc | |
| 20 image1 = u'default:4' | |
| 21 image2 = u'default:5' | |
| 22 | 24 |
| 23 for image in image1, image2: | 25 for image in image1, image2: |
| 24 logged_in_user = \ | 26 logged_in_user = \ |
| 25 self.GetLocalStatePrefsInfo().Prefs(k_logged_in_users)[0] | 27 self.GetLocalStatePrefsInfo().Prefs( |
| 28 ChromeosPrefsTest.k_logged_in_users)[0] | |
| 26 user_images = {} | 29 user_images = {} |
| 27 user_images[logged_in_user] = image | 30 user_images[logged_in_user] = image |
| 28 self.SetLocalStatePrefs(k_user_images, user_images) | 31 self.SetLocalStatePrefs( |
| 32 ChromeosPrefsTest.k_user_images, user_images) | |
| 29 self.RestartBrowser(clear_profile=False) | 33 self.RestartBrowser(clear_profile=False) |
| 30 current_user_images = self.GetLocalStatePrefsInfo().Prefs(k_user_images) | 34 current_user_images = self.GetLocalStatePrefsInfo().Prefs( |
| 35 ChromeosPrefsTest.k_user_images) | |
| 31 current_image = current_user_images.get(logged_in_user) | 36 current_image = current_user_images.get(logged_in_user) |
| 32 self.assertEqual(image, current_image) | 37 self.assertEqual(image, current_image, |
| 38 msg='Default user image was not set in preferences.') | |
| 39 | |
| 40 def testCaptureUserPhoto(self): | |
| 41 """Verify capturing/saving user photo works.""" | |
| 42 | |
| 43 logged_in_user = \ | |
| 44 self.GetLocalStatePrefsInfo().Prefs( | |
| 45 ChromeosPrefsTest.k_logged_in_users)[0] | |
| 46 self.CaptureProfilePhoto() | |
| 47 self.RestartBrowser(clear_profile=False) | |
|
Nirnimesh
2011/07/30 10:32:31
Should you verify before restarting the browser to
frankf
2011/08/01 19:31:09
Done.
| |
| 48 current_user_images = self.GetLocalStatePrefsInfo().Prefs( | |
| 49 ChromeosPrefsTest.k_user_images) | |
| 50 current_image_path = current_user_images.get(logged_in_user) | |
| 51 # Defined in src/chrome/browser/chromeos/login/user_manager.cc | |
| 52 expected_photo_name = logged_in_user + '.png' | |
| 53 self.assertTrue(expected_photo_name in current_image_path, | |
| 54 msg='Captured user photo was not set in preferences.') | |
|
Nirnimesh
2011/07/30 10:32:31
Can you also verify the file on disk?
frankf
2011/08/01 19:31:09
Done.
| |
| 33 | 55 |
| 34 | 56 |
| 35 if __name__ == '__main__': | 57 if __name__ == '__main__': |
| 36 pyauto_functional.Main() | 58 pyauto_functional.Main() |
| 37 | |
| OLD | NEW |