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