OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import sys |
9 | 10 |
10 import pyauto_functional # Must be imported before pyauto | 11 import pyauto_functional # Must be imported before pyauto |
11 import pyauto | 12 import pyauto |
12 | 13 |
| 14 sys.path.append('/usr/local') # To make autotest libs importable. |
| 15 from autotest.cros import cros_ui |
| 16 from autotest.cros import cryptohome |
| 17 |
13 | 18 |
14 class ChromeosVolume(pyauto.PyUITest): | 19 class ChromeosVolume(pyauto.PyUITest): |
15 """Test case for volume levels. | 20 """Test case for volume levels. |
16 | 21 |
17 Test volume and mute changes with different state like, login, | 22 Test volume and mute changes with different state like, login, |
18 lock, logout, etc... | 23 lock, logout, etc... |
19 """ | 24 """ |
20 | 25 |
21 def setUp(self): | 26 def setUp(self): |
22 # We want a clean session_manager instance for every run, | 27 # We want a clean session_manager instance for every run, |
23 # so restart session_manager now. | 28 # so restart ui now. |
24 assert self.WaitForSessionManagerRestart( | 29 cros_ui.stop(allow_fail=True) |
25 lambda: subprocess.call(['pkill', 'session_manager'])), \ | 30 cryptohome.remove_all_vaults() |
26 'Timed out waiting for session_manager to start.' | 31 cros_ui.start(wait_for_login_prompt=False) |
27 pyauto.PyUITest.setUp(self) | 32 pyauto.PyUITest.setUp(self) |
28 self._initial_volume_info = self.GetVolumeInfo() | 33 self._initial_volume_info = self.GetVolumeInfo() |
29 | 34 |
30 def tearDown(self): | 35 def tearDown(self): |
31 self.SetVolume(self._initial_volume_info['volume']) | 36 self.SetVolume(self._initial_volume_info['volume']) |
32 self.SetMute(self._initial_volume_info['is_mute']) | 37 self.SetMute(self._initial_volume_info['is_mute']) |
33 pyauto.PyUITest.tearDown(self) | 38 pyauto.PyUITest.tearDown(self) |
34 | 39 |
| 40 def ShouldAutoLogin(self): |
| 41 return False |
| 42 |
35 def _Login(self): | 43 def _Login(self): |
36 """Perform login""" | 44 """Perform login""" |
37 credentials = self.GetPrivateInfo()['test_google_account'] | 45 credentials = self.GetPrivateInfo()['test_google_account'] |
38 self.Login(credentials['username'], credentials['password']) | 46 self.Login(credentials['username'], credentials['password']) |
39 logging.info('Logged in as %s' % credentials['username']) | 47 logging.info('Logged in as %s' % credentials['username']) |
40 login_info = self.GetLoginInfo() | 48 login_info = self.GetLoginInfo() |
41 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') | 49 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
42 | 50 |
43 def testDefaultVolume(self): | 51 def testDefaultVolume(self): |
44 """Test the default volume settings""" | 52 """Test the default volume settings""" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 self.SetVolume(lock_volume['volume']) | 88 self.SetVolume(lock_volume['volume']) |
81 self.SetMute(lock_volume['is_mute']) | 89 self.SetMute(lock_volume['is_mute']) |
82 self.UnlockScreen(self.GetPrivateInfo()['test_google_account']['password']) | 90 self.UnlockScreen(self.GetPrivateInfo()['test_google_account']['password']) |
83 after_login = self.GetVolumeInfo() | 91 after_login = self.GetVolumeInfo() |
84 self.assertEqual(lock_volume, after_login, | 92 self.assertEqual(lock_volume, after_login, |
85 msg='Locking screen volume changes are not preserved') | 93 msg='Locking screen volume changes are not preserved') |
86 | 94 |
87 | 95 |
88 if __name__ == '__main__': | 96 if __name__ == '__main__': |
89 pyauto_functional.Main() | 97 pyauto_functional.Main() |
OLD | NEW |