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

Side by Side Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2874173002: Retreive screenshots captured by tests from test devices. (Closed)
Patch Set: Rebase Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 logging 5 import logging
6 import os 6 import os
7 import posixpath 7 import posixpath
8 import re 8 import re
9 import sys 9 import sys
10 import tempfile 10 import tempfile
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 logging.error("Couldn't set flags: no cmdline_file") 209 logging.error("Couldn't set flags: no cmdline_file")
210 else: 210 else:
211 self._CreateFlagChangerIfNeeded(dev) 211 self._CreateFlagChangerIfNeeded(dev)
212 logging.debug('Attempting to set flags: %r', 212 logging.debug('Attempting to set flags: %r',
213 self._test_instance.flags) 213 self._test_instance.flags)
214 self._flag_changers[str(dev)].AddFlags(self._test_instance.flags) 214 self._flag_changers[str(dev)].AddFlags(self._test_instance.flags)
215 215
216 valgrind_tools.SetChromeTimeoutScale( 216 valgrind_tools.SetChromeTimeoutScale(
217 dev, self._test_instance.timeout_scale) 217 dev, self._test_instance.timeout_scale)
218 218
219 @trace_event.traced
mikecase (-- gone --) 2017/05/19 15:46:43 Maybe add this to pull_ui_screen_captures as well
aberent 2017/05/22 18:03:19 Done.
220 def setup_ui_capture_dir():
221 # Make sure the UI capture directory exists and is empty by deleting
222 # and recreating it.
223 capture_dir = posixpath.join(dev.GetExternalStoragePath(),
224 'chromium_tests_root', 'UiCapture')
mikecase (-- gone --) 2017/05/19 15:46:43 nit: for indentation, I would align 'chr... with a
aberent 2017/05/22 18:03:20 Done.
225 if dev.PathExists(capture_dir):
226 dev.RunShellCommand(['rm', '-rf', capture_dir])
227 dev.RunShellCommand(['mkdir', capture_dir])
228
219 steps += [set_debug_app, edit_shared_prefs, push_test_data, 229 steps += [set_debug_app, edit_shared_prefs, push_test_data,
220 create_flag_changer] 230 create_flag_changer, setup_ui_capture_dir]
221 if self._env.concurrent_adb: 231 if self._env.concurrent_adb:
222 reraiser_thread.RunAsync(steps) 232 reraiser_thread.RunAsync(steps)
223 else: 233 else:
224 for step in steps: 234 for step in steps:
225 step() 235 step()
226 if self._test_instance.store_tombstones: 236 if self._test_instance.store_tombstones:
227 tombstones.ClearAllTombstones(dev) 237 tombstones.ClearAllTombstones(dev)
228 238
229 self._env.parallel_devices.pMap( 239 self._env.parallel_devices.pMap(
230 individual_device_set_up, 240 individual_device_set_up,
231 self._test_instance.GetDataDependencies()) 241 self._test_instance.GetDataDependencies())
232 242
233 #override 243 #override
234 def TearDown(self): 244 def TearDown(self):
235 @local_device_environment.handle_shard_failures_with( 245 @local_device_environment.handle_shard_failures_with(
236 self._env.BlacklistDevice) 246 self._env.BlacklistDevice)
237 @trace_event.traced 247 @trace_event.traced
238 def individual_device_tear_down(dev): 248 def individual_device_tear_down(dev):
239 if str(dev) in self._flag_changers: 249 if str(dev) in self._flag_changers:
240 self._flag_changers[str(dev)].Restore() 250 self._flag_changers[str(dev)].Restore()
241 251
242 # Remove package-specific configuration 252 # Remove package-specific configuration
243 dev.RunShellCommand(['am', 'clear-debug-app'], check_return=True) 253 dev.RunShellCommand(['am', 'clear-debug-app'], check_return=True)
244 254
245 valgrind_tools.SetChromeTimeoutScale(dev, None) 255 valgrind_tools.SetChromeTimeoutScale(dev, None)
246 256
257 if self._test_instance.ui_screenshot_dir:
258 pull_ui_screen_captures(dev)
259
260 def pull_ui_screen_captures(dev):
261 capture_dir = posixpath.join(dev.GetExternalStoragePath(),
262 'chromium_tests_root', 'UiCapture')
mikecase (-- gone --) 2017/05/19 15:46:43 I'm guessing this will have to be kept in sync wit
aberent 2017/05/22 18:03:20 Done.
263 file_names = dev.ListDirectory(capture_dir)
264 target_path = self._test_instance.ui_screenshot_dir
265 if not os.path.exists(target_path):
266 os.makedirs(target_path)
267
268 for file_name in file_names:
269 dev.PullFile(posixpath.join(capture_dir, file_name), target_path)
mikecase (-- gone --) 2017/05/19 15:46:43 Even though the name doesn't make it seem like it,
aberent 2017/05/22 18:03:20 So I thought originally. The problem is that PullF
270
247 self._env.parallel_devices.pMap(individual_device_tear_down) 271 self._env.parallel_devices.pMap(individual_device_tear_down)
248 272
249 def _CreateFlagChangerIfNeeded(self, device): 273 def _CreateFlagChangerIfNeeded(self, device):
250 if not str(device) in self._flag_changers: 274 if not str(device) in self._flag_changers:
251 self._flag_changers[str(device)] = flag_changer.FlagChanger( 275 self._flag_changers[str(device)] = flag_changer.FlagChanger(
252 device, self._test_instance.package_info.cmdline_file) 276 device, self._test_instance.package_info.cmdline_file)
253 277
254 #override 278 #override
255 def _CreateShards(self, tests): 279 def _CreateShards(self, tests):
256 return tests 280 return tests
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 651 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
628 652
629 return timeout 653 return timeout
630 654
631 def _IsRenderTest(test): 655 def _IsRenderTest(test):
632 """Determines if a test or list of tests has a RenderTest amongst them.""" 656 """Determines if a test or list of tests has a RenderTest amongst them."""
633 if not isinstance(test, list): 657 if not isinstance(test, list):
634 test = [test] 658 test = [test]
635 return any([RENDER_TEST_FEATURE_ANNOTATION in t['annotations'].get( 659 return any([RENDER_TEST_FEATURE_ANNOTATION in t['annotations'].get(
636 FEATURE_ANNOTATION, {}).get('value', ()) for t in test]) 660 FEATURE_ANNOTATION, {}).get('value', ()) for t in test])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698