Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py

Issue 381293003: [Telemetry] Consider linux distribution number is 0 when it cannot be parsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py
diff --git a/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..ca6d15f902c9c4d8bdf444bfed9c8c1551c9bd7d
--- /dev/null
+++ b/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py
@@ -0,0 +1,72 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import unittest
+
+from telemetry import decorators
+from telemetry.core import util
+from telemetry.core.platform import linux_platform_backend
+
+class TestBackend(
+ linux_platform_backend.LinuxPlatformBackend):
+
+ def __init__(self):
+ super(TestBackend, self).__init__()
+ self._mock_files = {}
+
+ def SetMockFile(self, filename, output):
+ self._mock_files[filename] = output
+
+ def _GetFileContents(self, filename):
+ return self._mock_files[filename]
+
+ def StartRawDisplayFrameRateMeasurement(self):
+ raise NotImplementedError()
+
+ def StopRawDisplayFrameRateMeasurement(self):
+ raise NotImplementedError()
+
+ def GetRawDisplayFrameRateMeasurements(self):
+ raise NotImplementedError()
+
+ def IsThermallyThrottled(self):
+ raise NotImplementedError()
+
+ def HasBeenThermallyThrottled(self):
+ raise NotImplementedError()
+
+ def GetSystemCommitCharge(self):
+ raise NotImplementedError()
+
+ def StopVideoCapture(self):
+ raise NotImplementedError()
+
+ def StartVideoCapture(self, min_bitrate_mbps):
+ raise NotImplementedError()
+
+ def GetSystemTotalPhysicalMemory(self):
+ raise NotImplementedError()
+
+
+class LinuxPlatformBackendTest(unittest.TestCase):
+ @decorators.Enabled('linux')
+ def testGetOSVersionNameSaucy(self):
+ backend = TestBackend()
+ path = os.path.join(util.GetUnittestDataDir(), 'ubuntu-saucy-lsb-release')
+ with open(path) as f:
+ backend.SetMockFile('/etc/lsb-release', f.read())
+
+ self.assertEqual(backend.GetOSVersionName(), 'saucy')
+
+ @decorators.Enabled('linux')
+ def testGetOSVersionNameArch(self):
+ backend = TestBackend()
+ path = os.path.join(util.GetUnittestDataDir(), 'arch-lsb-release')
+ with open(path) as f:
+ backend.SetMockFile('/etc/lsb-release', f.read())
+
+ # a distribution may not have a codename or a release number. We just check
+ # that GetOSVersionName doesn't raise an exception
+ backend.GetOSVersionName()
« no previous file with comments | « tools/telemetry/telemetry/core/platform/linux_platform_backend.py ('k') | tools/telemetry/unittest_data/arch-lsb-release » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698