Skip to content

Commit 33f1bee

Browse files
click notification permission dialog
1 parent 6af9ce2 commit 33f1bee

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,5 @@ dependencies {
509509
androidTestImplementation 'androidx.test:rules:1.6.1'
510510
androidTestImplementation 'androidx.test:core:1.6.1'
511511
androidTestImplementation 'org.hamcrest:hamcrest-library:2.2'
512+
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.3.0'
512513
}

src/androidTestUnbrandedDebug/java/org/medicmobile/webapp/mobile/SettingsDialogActivityTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
import androidx.test.ext.junit.runners.AndroidJUnit4;
3535
import androidx.test.filters.LargeTest;
3636

37+
import androidx.test.uiautomator.UiDevice;
38+
import androidx.test.uiautomator.UiObject;
39+
import androidx.test.uiautomator.UiSelector;
40+
import androidx.test.platform.app.InstrumentationRegistry;
41+
3742
import org.junit.FixMethodOrder;
3843
import org.junit.Rule;
3944
import org.junit.Test;
@@ -100,6 +105,8 @@ public void testLoginScreen() throws Exception {
100105

101106
Thread.sleep(7000); //TODO: use better ways to handle delays
102107

108+
allowNotificationPermission();
109+
103110
ViewInteraction webView = onView(
104111
allOf(withId(R.id.wbvMain),
105112
withParent(allOf(withId(R.id.lytWebView),
@@ -210,4 +217,12 @@ private String getLanguage(String code) {
210217
Locale aLocale = new Locale(code);
211218
return aLocale.getDisplayName();
212219
}
220+
221+
private void allowNotificationPermission () throws Exception {
222+
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
223+
UiObject allowButton = device.findObject(new UiSelector().text("Allow"));
224+
if (allowButton.exists() && allowButton.isEnabled()) {
225+
allowButton.click();
226+
}
227+
}
213228
}

0 commit comments

Comments
 (0)