summaryrefslogtreecommitdiff
path: root/app/src/androidTestCustom/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2023-04-11 02:40:15 +0200
committercyBerta <cyberta@riseup.net>2023-04-11 02:40:15 +0200
commitbf797d855bb55f325e2fb647ac0690aabc62772f (patch)
tree2ffe0d6b6fbbe8c9994e12d00273b10c827b9d2a /app/src/androidTestCustom/java
parent04d5df83101f9fc4407eea337fae4fe6cc7a53be (diff)
handle correctly vpn permission dialog
Diffstat (limited to 'app/src/androidTestCustom/java')
-rw-r--r--app/src/androidTestCustom/java/se/leap/bitmaskclient/base/CustomProviderTest.java15
1 files changed, 14 insertions, 1 deletions
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)),