OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os |
| 6 import unittest |
| 7 |
| 8 from telemetry import decorators |
| 9 from telemetry.core import util |
| 10 from telemetry.core.platform import linux_platform_backend |
| 11 |
| 12 class TestBackend( |
| 13 linux_platform_backend.LinuxPlatformBackend): |
| 14 |
| 15 def __init__(self): |
| 16 super(TestBackend, self).__init__() |
| 17 self._mock_files = {} |
| 18 |
| 19 def SetMockFile(self, filename, output): |
| 20 self._mock_files[filename] = output |
| 21 |
| 22 def _GetFileContents(self, filename): |
| 23 return self._mock_files[filename] |
| 24 |
| 25 def StartRawDisplayFrameRateMeasurement(self): |
| 26 raise NotImplementedError() |
| 27 |
| 28 def StopRawDisplayFrameRateMeasurement(self): |
| 29 raise NotImplementedError() |
| 30 |
| 31 def GetRawDisplayFrameRateMeasurements(self): |
| 32 raise NotImplementedError() |
| 33 |
| 34 def IsThermallyThrottled(self): |
| 35 raise NotImplementedError() |
| 36 |
| 37 def HasBeenThermallyThrottled(self): |
| 38 raise NotImplementedError() |
| 39 |
| 40 def GetSystemCommitCharge(self): |
| 41 raise NotImplementedError() |
| 42 |
| 43 def StopVideoCapture(self): |
| 44 raise NotImplementedError() |
| 45 |
| 46 def StartVideoCapture(self, min_bitrate_mbps): |
| 47 raise NotImplementedError() |
| 48 |
| 49 def GetSystemTotalPhysicalMemory(self): |
| 50 raise NotImplementedError() |
| 51 |
| 52 |
| 53 class LinuxPlatformBackendTest(unittest.TestCase): |
| 54 @decorators.Enabled('linux') |
| 55 def testGetOSVersionNameSaucy(self): |
| 56 backend = TestBackend() |
| 57 path = os.path.join(util.GetUnittestDataDir(), 'ubuntu-saucy-lsb-release') |
| 58 with open(path) as f: |
| 59 backend.SetMockFile('/etc/lsb-release', f.read()) |
| 60 |
| 61 self.assertEqual(backend.GetOSVersionName(), 'saucy') |
| 62 |
| 63 @decorators.Enabled('linux') |
| 64 def testGetOSVersionNameArch(self): |
| 65 backend = TestBackend() |
| 66 path = os.path.join(util.GetUnittestDataDir(), 'arch-lsb-release') |
| 67 with open(path) as f: |
| 68 backend.SetMockFile('/etc/lsb-release', f.read()) |
| 69 |
| 70 # a distribution may not have a codename or a release number. We just check |
| 71 # that GetOSVersionName doesn't raise an exception |
| 72 backend.GetOSVersionName() |
OLD | NEW |