OLD | NEW |
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 from pylib.gtest import gtest_test_instance | 5 from pylib.gtest import gtest_test_instance |
6 from pylib.instrumentation import instrumentation_test_instance | 6 from pylib.instrumentation import instrumentation_test_instance |
7 from pylib.local.device import local_device_environment | 7 from pylib.local.device import local_device_environment |
8 from pylib.local.device import local_device_gtest_run | 8 from pylib.local.device import local_device_gtest_run |
9 from pylib.local.device import local_device_instrumentation_test_run | 9 from pylib.local.device import local_device_instrumentation_test_run |
| 10 from pylib.local.device import local_device_perf_test_run |
| 11 from pylib.perf import perf_test_instance |
10 from pylib.uirobot import uirobot_test_instance | 12 from pylib.uirobot import uirobot_test_instance |
11 | 13 |
12 try: | 14 try: |
13 from pylib.remote.device import remote_device_environment | 15 from pylib.remote.device import remote_device_environment |
14 from pylib.remote.device import remote_device_gtest_run | 16 from pylib.remote.device import remote_device_gtest_run |
15 from pylib.remote.device import remote_device_instrumentation_test_run | 17 from pylib.remote.device import remote_device_instrumentation_test_run |
16 from pylib.remote.device import remote_device_uirobot_test_run | 18 from pylib.remote.device import remote_device_uirobot_test_run |
17 except ImportError: | 19 except ImportError: |
18 remote_device_environment = None | 20 remote_device_environment = None |
19 remote_device_gtest_run = None | 21 remote_device_gtest_run = None |
20 remote_device_instrumentation_test_run = None | 22 remote_device_instrumentation_test_run = None |
21 remote_device_uirobot_test_run = None | 23 remote_device_uirobot_test_run = None |
22 | 24 |
23 | 25 |
24 def CreateTestRun(_args, env, test_instance, error_func): | 26 def _CreatePerfTestRun(args, env, test_instance): |
| 27 if args.print_step: |
| 28 return local_device_perf_test_run.PrintStep( |
| 29 env, test_instance) |
| 30 elif args.output_json_list: |
| 31 return local_device_perf_test_run.OutputJsonList( |
| 32 env, test_instance) |
| 33 return local_device_perf_test_run.LocalDevicePerfTestRun( |
| 34 env, test_instance) |
| 35 |
| 36 |
| 37 def CreateTestRun(args, env, test_instance, error_func): |
25 if isinstance(env, local_device_environment.LocalDeviceEnvironment): | 38 if isinstance(env, local_device_environment.LocalDeviceEnvironment): |
26 if isinstance(test_instance, gtest_test_instance.GtestTestInstance): | 39 if isinstance(test_instance, gtest_test_instance.GtestTestInstance): |
27 return local_device_gtest_run.LocalDeviceGtestRun(env, test_instance) | 40 return local_device_gtest_run.LocalDeviceGtestRun(env, test_instance) |
28 if isinstance(test_instance, | 41 if isinstance(test_instance, |
29 instrumentation_test_instance.InstrumentationTestInstance): | 42 instrumentation_test_instance.InstrumentationTestInstance): |
30 return (local_device_instrumentation_test_run | 43 return (local_device_instrumentation_test_run |
31 .LocalDeviceInstrumentationTestRun(env, test_instance)) | 44 .LocalDeviceInstrumentationTestRun(env, test_instance)) |
| 45 if isinstance(test_instance, |
| 46 perf_test_instance.PerfTestInstance): |
| 47 return _CreatePerfTestRun(args, env, test_instance) |
32 | 48 |
33 if (remote_device_environment | 49 if (remote_device_environment |
34 and isinstance(env, remote_device_environment.RemoteDeviceEnvironment)): | 50 and isinstance(env, remote_device_environment.RemoteDeviceEnvironment)): |
35 # The remote_device modules should be all or nothing. | 51 # The remote_device modules should be all or nothing. |
36 assert (remote_device_gtest_run | 52 assert (remote_device_gtest_run |
37 and remote_device_instrumentation_test_run | 53 and remote_device_instrumentation_test_run |
38 and remote_device_uirobot_test_run) | 54 and remote_device_uirobot_test_run) |
39 | 55 |
40 if isinstance(test_instance, gtest_test_instance.GtestTestInstance): | 56 if isinstance(test_instance, gtest_test_instance.GtestTestInstance): |
41 return remote_device_gtest_run.RemoteDeviceGtestTestRun( | 57 return remote_device_gtest_run.RemoteDeviceGtestTestRun( |
42 env, test_instance) | 58 env, test_instance) |
43 if isinstance(test_instance, | 59 if isinstance(test_instance, |
44 instrumentation_test_instance.InstrumentationTestInstance): | 60 instrumentation_test_instance.InstrumentationTestInstance): |
45 return (remote_device_instrumentation_test_run | 61 return (remote_device_instrumentation_test_run |
46 .RemoteDeviceInstrumentationTestRun(env, test_instance)) | 62 .RemoteDeviceInstrumentationTestRun(env, test_instance)) |
47 if isinstance(test_instance, uirobot_test_instance.UirobotTestInstance): | 63 if isinstance(test_instance, uirobot_test_instance.UirobotTestInstance): |
48 return remote_device_uirobot_test_run.RemoteDeviceUirobotTestRun( | 64 return remote_device_uirobot_test_run.RemoteDeviceUirobotTestRun( |
49 env, test_instance) | 65 env, test_instance) |
50 | 66 |
51 | 67 |
52 error_func('Unable to create test run for %s tests in %s environment' | 68 error_func('Unable to create test run for %s tests in %s environment' |
53 % (str(test_instance), str(env))) | 69 % (str(test_instance), str(env))) |
54 | 70 |
OLD | NEW |