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