Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / platform / mac_platform_backend_unittest.py
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 benchmark
9 from telemetry.core import platform as platform_module
10 from telemetry.core.platform import platform_backend
11
12
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']),
22                      'mavericks2')
23     self.assertEqual(platform_backend.LION.upper(), 'LION')
24
25   @benchmark.Enabled('mac')
26   def testGetCPUStats(self):
27     platform = platform_module.GetHostPlatform()
28
29     backend = platform._platform_backend # pylint: disable=W0212
30
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'))