InstrumentationRunListener.java revision 52b9cd1de29c41a6407ec0a3aba746dcb9a4395a
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.android.test.runner.listener; 17 18import android.app.Instrumentation; 19import android.os.Bundle; 20 21import org.junit.runner.notification.RunListener; 22 23/** 24 * A {@link RunListener} that has access to a {@link Instrumentation}. This is useful for 25 * test result listeners that want to dump data back to the instrumentation results. 26 */ 27public abstract class InstrumentationRunListener extends RunListener { 28 29 private final Instrumentation mInstr; 30 31 public InstrumentationRunListener(Instrumentation instr) { 32 mInstr = instr; 33 } 34 35 public Instrumentation getInstrumentation() { 36 return mInstr; 37 } 38 39 /** 40 * Convenience method for {@link #getInstrumentation()#sendStatus()} 41 */ 42 public void sendStatus(int code, Bundle bundle) { 43 getInstrumentation().sendStatus(code, bundle); 44 } 45} 46