OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
6 import time | 6 import time |
7 import unittest | 7 import unittest |
8 | 8 |
9 from telemetry.core import platform as platform_module | 9 from telemetry.core import platform as platform_module |
| 10 from telemetry.testing import tab_test_case |
10 from telemetry import decorators | 11 from telemetry import decorators |
11 | 12 |
12 | 13 |
13 class PlatformBackendTest(unittest.TestCase): | 14 class PlatformBackendTest(unittest.TestCase): |
14 @decorators.Disabled('mac', # crbug.com/440666 | 15 @decorators.Disabled('mac', # crbug.com/440666 |
15 'vista', # crbug.com/479337 | 16 'vista', # crbug.com/479337 |
16 'chromeos', # crbug.com/483212 | 17 'chromeos', # crbug.com/483212 |
17 'win') # catapult/issues/2282 | 18 'win') # catapult/issues/2282 |
18 def testPowerMonitoringSync(self): | 19 def testPowerMonitoringSync(self): |
19 # Tests that the act of monitoring power doesn't blow up. | 20 # Tests that the act of monitoring power doesn't blow up. |
(...skipping 10 matching lines...) Expand all Loading... |
30 # pylint: disable=protected-access | 31 # pylint: disable=protected-access |
31 browser_mock._browser_backend = lambda: None | 32 browser_mock._browser_backend = lambda: None |
32 # Monitor the launcher, which is always present. | 33 # Monitor the launcher, which is always present. |
33 browser_mock._browser_backend.package = 'com.android.launcher' | 34 browser_mock._browser_backend.package = 'com.android.launcher' |
34 | 35 |
35 platform.StartMonitoringPower(browser_mock) | 36 platform.StartMonitoringPower(browser_mock) |
36 time.sleep(0.001) | 37 time.sleep(0.001) |
37 output = platform.StopMonitoringPower() | 38 output = platform.StopMonitoringPower() |
38 self.assertTrue(output.has_key('energy_consumption_mwh')) | 39 self.assertTrue(output.has_key('energy_consumption_mwh')) |
39 self.assertTrue(output.has_key('identifier')) | 40 self.assertTrue(output.has_key('identifier')) |
| 41 |
| 42 |
| 43 class PlatformBackendIntegrationTest(tab_test_case.TabTestCase): |
| 44 |
| 45 def setUp(self): |
| 46 super(PlatformBackendIntegrationTest, self).setUp() |
| 47 self._platform_backend = self._platform._platform_backend |
| 48 |
| 49 def _GetRootCertificates(self): |
| 50 if self._platform_backend.GetOSName() == 'android': |
| 51 return set(self._platform_backend._device.ListDirectory( |
| 52 '/system/etc/security/cacerts/', as_root=True)) |
| 53 else: |
| 54 raise NotImplementedError() |
| 55 |
| 56 # TODO(nedn): also run this test on linux (crbug.com/756989) |
| 57 @decorators.Enabled('android') |
| 58 def testCAInstallation(self): |
| 59 self.assertTrue(self._platform_backend.supports_test_ca) |
| 60 current_certificates = self._GetRootCertificates() |
| 61 |
| 62 # Assert that we have +1 certificate on the system after invoking |
| 63 # InstallTestCa(). |
| 64 self._platform_backend.InstallTestCa() |
| 65 self.assertEquals( |
| 66 len(current_certificates) + 1, |
| 67 len(self._GetRootCertificates())) |
| 68 |
| 69 # Assert that the system's test certificates should be the same as before |
| 70 # after invoking RemoveTestCa(). |
| 71 self._platform_backend.RemoveTestCa() |
| 72 self.assertEquals(current_certificates, self._GetRootCertificates()) |
OLD | NEW |