1 /* 2 * Copyright (C) 2017 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 */ 16 package android.jvmti.cts; 17 18 import android.support.test.filters.SmallTest; 19 import android.support.test.rule.ActivityTestRule; 20 import android.support.test.runner.AndroidJUnit4; 21 22 import org.junit.Before; 23 import org.junit.Rule; 24 import org.junit.runner.RunWith; 25 26 import android.jvmti.JvmtiActivity; 27 import art.CtsMain; 28 29 /** 30 * Base class for JVMTI tests. Ensures that the agent is connected for the tests. If you 31 * do not subclass this test, make sure that JniBindings.waitFor is appropriately called. 32 */ 33 @SmallTest 34 @RunWith(AndroidJUnit4.class) 35 public abstract class JvmtiTestBase { 36 37 /** 38 * A reference to the activity being tested. 39 */ 40 protected JvmtiActivity mActivity; 41 42 @Rule 43 public ActivityTestRule<JvmtiActivity> mActivityRule = 44 new ActivityTestRule<>(JvmtiActivity.class); 45 46 @Before setup()47 public void setup() { 48 mActivity = mActivityRule.getActivity(); 49 50 // Make sure that the agent is ready. 51 CtsMain.waitFor(); 52 } 53 } 54