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. 4import os 5import shutil 6import tempfile 7import zipfile 8 9from telemetry import benchmark 10from telemetry.core.platform.profiler import android_systrace_profiler 11from telemetry.unittest import tab_test_case 12 13 14class TestAndroidSystraceProfiler(tab_test_case.TabTestCase): 15 @benchmark.Enabled('android') 16 def testSystraceProfiler(self): 17 try: 18 out_dir = tempfile.mkdtemp() 19 # pylint: disable=W0212 20 profiler = android_systrace_profiler.AndroidSystraceProfiler( 21 self._browser._browser_backend, 22 self._browser._platform_backend, 23 os.path.join(out_dir, 'systrace'), 24 {}) 25 result = profiler.CollectProfile()[0] 26 self.assertTrue(zipfile.is_zipfile(result)) 27 with zipfile.ZipFile(result) as z: 28 self.assertEquals(len(z.namelist()), 2) 29 self.assertIn('sched_wakeup', z.open('systrace').read()) 30 finally: 31 shutil.rmtree(out_dir) 32