OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.test.outstrumentation.slave; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.content.ComponentName; |
| 9 import android.content.Intent; |
| 10 import android.os.Bundle; |
| 11 import android.util.Log; |
| 12 |
| 13 /** |
| 14 * An Activity target for Outstrumentation that starts the specified Instrumenta
tion test. |
| 15 */ |
| 16 public class OutstrumentationSlaveActivity extends Activity { |
| 17 |
| 18 public static final String EXTRA_INSTRUMENTATION_PACKAGE = |
| 19 "org.chromium.test.outstrumentation.slave.OutstrumentationSlaveActiv
ity." |
| 20 + "InstrumentationPackage"; |
| 21 public static final String EXTRA_INSTRUMENTATION_CLASS = |
| 22 "org.chromium.test.outstrumentation.slave.OutstrumentationSlaveActiv
ity." |
| 23 + "InstrumentationClass"; |
| 24 public static final String EXTRA_TARGET_ARGS = |
| 25 "org.chromium.test.outstrumentation.slave.OutstrumentationSlaveActiv
ity.TargetArgs"; |
| 26 public static final String EXTRA_TEST = |
| 27 "org.chromium.test.outstrumentation.slave.OutstrumentationSlaveActiv
ity.Test"; |
| 28 |
| 29 private static final String TAG = "OutstrumentationSlaveActivity"; |
| 30 |
| 31 @Override |
| 32 public void onCreate(Bundle savedInstanceState) { |
| 33 super.onCreate(savedInstanceState); |
| 34 Log.d(TAG, "onCreate()"); |
| 35 } |
| 36 |
| 37 @Override |
| 38 public void onStart() { |
| 39 super.onStart(); |
| 40 |
| 41 Intent i = getIntent(); |
| 42 String instrumentationPackage = i.getStringExtra(EXTRA_INSTRUMENTATION_P
ACKAGE); |
| 43 String instrumentationClass = i.getStringExtra(EXTRA_INSTRUMENTATION_CLA
SS); |
| 44 Bundle targetArgs = i.getBundleExtra(EXTRA_TARGET_ARGS); |
| 45 String test = i.getStringExtra(EXTRA_TEST); |
| 46 |
| 47 if (instrumentationPackage == null || instrumentationClass == null) { |
| 48 finish(); |
| 49 return; |
| 50 } |
| 51 |
| 52 ComponentName instrumentationComponent = |
| 53 new ComponentName(instrumentationPackage, instrumentationClass); |
| 54 |
| 55 if (test != null) { |
| 56 targetArgs.putString("class", test); |
| 57 } |
| 58 |
| 59 startInstrumentation(instrumentationComponent, null, targetArgs); |
| 60 finish(); |
| 61 } |
| 62 } |
| 63 |
OLD | NEW |