From bf797d855bb55f325e2fb647ac0690aabc62772f Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 11 Apr 2023 02:40:15 +0200 Subject: handle correctly vpn permission dialog --- .../se/leap/bitmaskclient/base/CustomProviderTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/src/androidTestCustom/java') diff --git a/app/src/androidTestCustom/java/se/leap/bitmaskclient/base/CustomProviderTest.java b/app/src/androidTestCustom/java/se/leap/bitmaskclient/base/CustomProviderTest.java index 1a0814b6..92416af4 100644 --- a/app/src/androidTestCustom/java/se/leap/bitmaskclient/base/CustomProviderTest.java +++ b/app/src/androidTestCustom/java/se/leap/bitmaskclient/base/CustomProviderTest.java @@ -1,5 +1,6 @@ package se.leap.bitmaskclient.base; +import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; @@ -9,7 +10,12 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static utils.CustomInteractions.tryResolve; +import android.net.VpnService; + import androidx.test.espresso.ViewInteraction; +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiObjectNotFoundException; +import androidx.test.uiautomator.UiSelector; import org.junit.Test; @@ -20,7 +26,14 @@ public class CustomProviderTest extends ProviderBaseTest { @Test @Override - public void test01_vpnStartTest() throws InterruptedException { + public void test01_vpnStartTest() throws InterruptedException, UiObjectNotFoundException { + // handle VPN permission dialog + if (VpnService.prepare(getApplicationContext()) != null) { + UiObject okButton = device.findObject(new UiSelector().packageName("com.android.vpndialogs").resourceId("android:id/button1")); + okButton.waitForExists(30000); + okButton.click(); + } + ViewInteraction mainButtonStop; mainButtonStop = tryResolve( onView(withId(R.id.main_button)), -- cgit v1.2.3