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

Side by Side Diff: systrace/profile_chrome/util.py

Issue 2295913002: Enable some profile_chrome unit tests on Trybots (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Disable DDMS test because it is flaky Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import gzip 5 import gzip
6 import os 6 import os
7 import time 7 import time
8 import zipfile 8 import zipfile
9 9
10 from devil.android.sdk import intent
11 from devil.android.sdk import keyevent
12
10 13
11 def ArchiveFiles(host_files, output): 14 def ArchiveFiles(host_files, output):
12 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as z: 15 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as z:
13 for host_file in host_files: 16 for host_file in host_files:
14 z.write(host_file) 17 z.write(host_file)
15 os.unlink(host_file) 18 os.unlink(host_file)
16 19
17 def CompressFile(host_file, output): 20 def CompressFile(host_file, output):
18 with gzip.open(output, 'wb') as out, open(host_file, 'rb') as input_file: 21 with gzip.open(output, 'wb') as out, open(host_file, 'rb') as input_file:
19 out.write(input_file.read()) 22 out.write(input_file.read())
20 os.unlink(host_file) 23 os.unlink(host_file)
21 24
22 def ArchiveData(trace_results, output): 25 def ArchiveData(trace_results, output):
23 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as z: 26 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as z:
24 for result in trace_results: 27 for result in trace_results:
25 trace_file = result.source_name + GetTraceTimestamp() 28 trace_file = result.source_name + GetTraceTimestamp()
26 WriteDataToCompressedFile(result.raw_data, trace_file) 29 WriteDataToCompressedFile(result.raw_data, trace_file)
27 z.write(trace_file) 30 z.write(trace_file)
28 os.unlink(trace_file) 31 os.unlink(trace_file)
29 32
30 def WriteDataToCompressedFile(data, output): 33 def WriteDataToCompressedFile(data, output):
31 with gzip.open(output, 'wb') as out: 34 with gzip.open(output, 'wb') as out:
32 out.write(data) 35 out.write(data)
33 36
34 def GetTraceTimestamp(): 37 def GetTraceTimestamp():
35 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) 38 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
39
40 def StartBrowser(device, package_info):
Sami 2016/09/09 10:28:25 Feels like this fits in better in the test harness
washingtonp 2016/09/09 18:07:29 Done.
41 # Turn on the device screen.
42 device.SetScreen(True)
43
44 # Unlock device.
45 device.SendKeyEvent(keyevent.KEYCODE_MENU)
46
47 # Start browser.
48 device.StartActivity(
49 intent.Intent(activity=package_info.activity,
50 package=package_info.package,
51 data='about:blank',
52 extras={'create_new_tab': True}),
53 blocking=True, force_stop=True)
54
55 def GetChromeProcessID(device, package_info):
56 chrome_processes = device.GetPids(package_info.package)
57 if (package_info.package in chrome_processes and
58 len(chrome_processes[package_info.package]) > 0):
59 return chrome_processes[package_info.package][0]
60 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698