Skip to content

Commit ecfd256

Browse files
committed
Fix initialization error
Init TESTDPC_ADMIN and NON_TESTDPC_ADMIN after class created
1 parent ffee36f commit ecfd256

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/test/java/com/afwsamples/testdpc/common/PermissionsHelperTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.os.Build.VERSION_CODES;
3030
import androidx.test.core.app.ApplicationProvider;
3131
import org.junit.Test;
32+
import org.junit.Before;
3233
import org.junit.runner.RunWith;
3334
import org.robolectric.RobolectricTestRunner;
3435
import org.robolectric.annotation.Config;
@@ -38,9 +39,8 @@
3839
@Config(minSdk = VERSION_CODES.Q)
3940
public class PermissionsHelperTest {
4041

41-
private static final ComponentName TESTDPC_ADMIN =
42-
new ComponentName("com.afwsamples.testdpc", "TestCls");
43-
private static final ComponentName NON_TESTDPC_ADMIN = new ComponentName("TestPkg", "TestCls");
42+
private ComponentName TESTDPC_ADMIN = null;
43+
private ComponentName NON_TESTDPC_ADMIN = null;
4444

4545
private final Context mContext = ApplicationProvider.getApplicationContext();
4646
private final DevicePolicyManager mDevicePolicyManager =
@@ -53,6 +53,12 @@ public class PermissionsHelperTest {
5353
private static final String NORMAL_PERMISSION = permission.ACCESS_WIFI_STATE;
5454
private static final String MISSING_INFO_PERMISSION = permission.CHANGE_WIFI_STATE;
5555

56+
@Before
57+
public void initialize() {
58+
TESTDPC_ADMIN = new ComponentName("com.afwsamples.testdpc", "TestCls");
59+
NON_TESTDPC_ADMIN = new ComponentName("TestPkg", "TestCls");
60+
}
61+
5662
@Test
5763
public void
5864
ensureRequiredPermissions_ifPermissionMissingFromManifest_shouldReturnFalseAndLogError() {

0 commit comments

Comments
 (0)