OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 logging | 6 import logging |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 | 9 |
10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
11 import pyauto | 11 import pyauto |
12 | 12 |
13 | 13 |
14 class ChromeosVolume(pyauto.PyUITest): | 14 class ChromeosVolume(pyauto.PyUITest): |
15 """Test case for volume levels. | 15 """Test case for volume levels. |
16 | 16 |
17 Test volume and mute changes with different state like, login, | 17 Test volume and mute changes with different state like, login, |
18 lock, logout, etc... | 18 lock, logout, etc... |
19 """ | 19 """ |
20 | 20 |
| 21 DEFAULT_VOLUME = {u'volume': 77.134215500945189, u'is_mute': False} |
| 22 |
21 def setUp(self): | 23 def setUp(self): |
22 # We want a clean session_manager instance for every run, | 24 # We want a clean session_manager instance for every run, |
23 # so restart session_manager now. | 25 # so restart session_manager now. |
24 assert self.WaitForSessionManagerRestart( | 26 assert self.WaitForSessionManagerRestart( |
25 lambda: subprocess.call(['pkill', 'session_manager'])), \ | 27 lambda: subprocess.call(['pkill', 'session_manager'])), \ |
26 'Timed out waiting for session_manager to start.' | 28 'Timed out waiting for session_manager to start.' |
27 pyauto.PyUITest.setUp(self) | 29 pyauto.PyUITest.setUp(self) |
28 self._initial_volume_info = self.GetVolumeInfo() | 30 self._initial_volume_info = self.GetVolumeInfo() |
29 | 31 |
30 def tearDown(self): | 32 def tearDown(self): |
31 self.SetVolume(self._initial_volume_info['volume']) | 33 self.SetVolume(self._initial_volume_info['volume']) |
32 self.SetMute(self._initial_volume_info['is_mute']) | 34 self.SetMute(self._initial_volume_info['is_mute']) |
33 pyauto.PyUITest.tearDown(self) | 35 pyauto.PyUITest.tearDown(self) |
34 | 36 |
35 def _Login(self): | 37 def _Login(self): |
36 """Perform login""" | 38 """Perform login""" |
37 credentials = self.GetPrivateInfo()['test_google_account'] | 39 credentials = self.GetPrivateInfo()['test_google_account'] |
38 self.Login(credentials['username'], credentials['password']) | 40 self.Login(credentials['username'], credentials['password']) |
39 logging.info('Logged in as %s' % credentials['username']) | 41 logging.info('Logged in as %s' % credentials['username']) |
40 login_info = self.GetLoginInfo() | 42 login_info = self.GetLoginInfo() |
41 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') | 43 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
42 | 44 |
| 45 def testDefaultVolume(self): |
| 46 """Test the default volume settings""" |
| 47 self._Login() |
| 48 volume = self.GetVolumeInfo() |
| 49 self.assertEqual(volume, self.DEFAULT_VOLUME, |
| 50 msg='Volume settings are set to %s, not matching with default '\ |
| 51 'volume settings %s.' % (volume, self.DEFAULT_VOLUME)) |
| 52 |
43 def testLoginLogoutVolume(self): | 53 def testLoginLogoutVolume(self): |
44 """Test that volume settings are preserved after login and logout""" | 54 """Test that volume settings are preserved after login and logout""" |
45 before_login = self.GetVolumeInfo() | 55 before_login = self.GetVolumeInfo() |
46 self._Login() | 56 self._Login() |
47 after_login = self.GetVolumeInfo() | 57 after_login = self.GetVolumeInfo() |
48 self.assertEqual(before_login, after_login, | 58 self.assertEqual(before_login, after_login, |
49 msg='Before login : %s and after login : %s, volume states are not '\ | 59 msg='Before login : %s and after login : %s, volume states are not '\ |
50 'matching' % (before_login, after_login)) | 60 'matching' % (before_login, after_login)) |
51 self.Logout() | 61 self.Logout() |
52 after_logout = self.GetVolumeInfo() | 62 after_logout = self.GetVolumeInfo() |
(...skipping 12 matching lines...) Expand all Loading... |
65 self.SetVolume(lock_volume['volume']) | 75 self.SetVolume(lock_volume['volume']) |
66 self.SetMute(lock_volume['is_mute']) | 76 self.SetMute(lock_volume['is_mute']) |
67 self.UnlockScreen(self.GetPrivateInfo()['test_google_account']['password']) | 77 self.UnlockScreen(self.GetPrivateInfo()['test_google_account']['password']) |
68 after_login = self.GetVolumeInfo() | 78 after_login = self.GetVolumeInfo() |
69 self.assertEqual(lock_volume, after_login, | 79 self.assertEqual(lock_volume, after_login, |
70 msg='Locking screen volume changes are not preserved') | 80 msg='Locking screen volume changes are not preserved') |
71 | 81 |
72 | 82 |
73 if __name__ == '__main__': | 83 if __name__ == '__main__': |
74 pyauto_functional.Main() | 84 pyauto_functional.Main() |
OLD | NEW |