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