1 /* 2 * Copyright (C) 2024 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 com.android.adservices.shared.testing; 17 18 import android.content.Context; 19 20 import androidx.test.platform.app.InstrumentationRegistry; 21 22 import org.junit.Rule; 23 24 /** 25 * Superclass for all device-side tests, it contains just the bare minimum features used by all 26 * tests. 27 */ 28 public abstract class DeviceSideTestCase extends SidelessTestCase { 29 30 /** Reference to the context of package being instrumented (target context). */ 31 protected static final Context sContext = 32 InstrumentationRegistry.getInstrumentation().getTargetContext(); 33 34 /** Package name of the app being instrumented. */ 35 protected static final String sPackageName = sContext.getPackageName(); 36 37 /** Reference to the context of package being instrumented (target context). */ 38 protected final Context mContext = sContext; 39 40 /** Package name of the app being instrumented. */ 41 protected final String mPackageName = sPackageName; 42 43 /** {@code logcat} tag. */ 44 protected final String mTag = getClass().getSimpleName(); 45 46 // TODO(b/342639109): make sure it's the right order 47 @Rule(order = 0) 48 public final SdkLevelSupportRule sdkLevel = SdkLevelSupportRule.forAnyLevel(); 49 50 // TODO(b/342639109): set order 51 @Rule 52 public final ProcessLifeguardRule processLifeguard = 53 new ProcessLifeguardRule(ProcessLifeguardRule.Mode.IGNORE); 54 } 55