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.
8 from telemetry import benchmark
9 from telemetry.core import platform as platform_module
10 from telemetry.core.platform import platform_backend
13 class MacPlatformBackendTest(unittest.TestCase):
14 def testVersionCamparison(self):
15 self.assertGreater(platform_backend.MAVERICKS,
16 platform_backend.SNOWLEOPARD)
17 self.assertGreater(platform_backend.LION,
18 platform_backend.LEOPARD)
19 self.assertEqual(platform_backend.MAVERICKS, 'mavericks')
20 self.assertEqual('%s2' % platform_backend.MAVERICKS, 'mavericks2')
21 self.assertEqual(''.join([platform_backend.MAVERICKS, '2']),
23 self.assertEqual(platform_backend.LION.upper(), 'LION')
25 @benchmark.Enabled('mac')
26 def testGetCPUStats(self):
27 platform = platform_module.GetHostPlatform()
29 backend = platform._platform_backend # pylint: disable=W0212
31 cpu_stats = backend.GetCpuStats(os.getpid())
32 self.assertGreater(cpu_stats['CpuProcessTime'], 0)
33 self.assertTrue(cpu_stats.has_key('ContextSwitches'))
34 if backend.GetOSVersionName() >= platform_backend.MAVERICKS:
35 self.assertTrue(cpu_stats.has_key('IdleWakeupCount'))