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

Side by Side Diff: build/android/pylib/uiautomator/test_runner.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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
(Empty)
1 # Copyright (c) 2013 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 """Class for running uiautomator tests on a single device."""
6
7 from pylib import constants
8 from pylib import flag_changer
9 from pylib.device import intent
10 from pylib.instrumentation import test_options as instr_test_options
11 from pylib.instrumentation import test_runner as instr_test_runner
12
13
14 class TestRunner(instr_test_runner.TestRunner):
15 """Responsible for running a series of tests connected to a single device."""
16
17 def __init__(self, test_options, device, shard_index, test_pkg):
18 """Create a new TestRunner.
19
20 Args:
21 test_options: A UIAutomatorOptions object.
22 device: Attached android device.
23 shard_index: Shard index.
24 test_pkg: A TestPackage object.
25 """
26 # Create an InstrumentationOptions object to pass to the super class
27 instrumentation_options = instr_test_options.InstrumentationOptions(
28 test_options.tool,
29 test_options.annotations,
30 test_options.exclude_annotations,
31 test_options.test_filter,
32 test_options.test_data,
33 test_options.save_perf_json,
34 test_options.screenshot_failures,
35 wait_for_debugger=False,
36 coverage_dir=None,
37 test_apk=None,
38 test_apk_path=None,
39 test_apk_jar_path=None,
40 test_runner=None,
41 test_support_apk_path=None,
42 device_flags=None,
43 isolate_file_path=None,
44 set_asserts=test_options.set_asserts,
45 delete_stale_data=False)
46 super(TestRunner, self).__init__(instrumentation_options, device,
47 shard_index, test_pkg)
48
49 cmdline_file = constants.PACKAGE_INFO[test_options.package].cmdline_file
50 self.flags = None
51 if cmdline_file:
52 self.flags = flag_changer.FlagChanger(self.device, cmdline_file)
53 self._package = constants.PACKAGE_INFO[test_options.package].package
54 self._activity = constants.PACKAGE_INFO[test_options.package].activity
55
56 #override
57 def InstallTestPackage(self):
58 self.test_pkg.Install(self.device)
59
60 #override
61 def _RunTest(self, test, timeout):
62 self.device.ClearApplicationState(self._package)
63 if self.flags:
64 annotations = self.test_pkg.GetTestAnnotations(test)
65 if 'FirstRunExperience' == annotations.get('Feature', None):
66 self.flags.RemoveFlags(['--disable-fre'])
67 else:
68 self.flags.AddFlags(['--disable-fre'])
69 self.device.StartActivity(
70 intent.Intent(action='android.intent.action.MAIN',
71 activity=self._activity,
72 package=self._package),
73 blocking=True,
74 force_stop=True)
75 cmd = ['uiautomator', 'runtest',
76 self.test_pkg.UIAUTOMATOR_PATH + self.test_pkg.GetPackageName(),
77 '-e', 'class', test,
78 '-e', 'test_package', self._package]
79 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0)
80
81 #override
82 def _GenerateTestResult(self, test, _result_code, _result_bundle, statuses,
83 start_ms, duration_ms):
84 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE,
85 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses.
86 summary_code, summary_bundle = statuses[-1]
87 return super(TestRunner, self)._GenerateTestResult(
88 test, summary_code, summary_bundle, statuses[:-1], start_ms,
89 duration_ms)
OLDNEW
« no previous file with comments | « build/android/pylib/uiautomator/test_package.py ('k') | build/android/pylib/uirobot/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698