Skip to content

Commit 4ab9ccb

Browse files
click notification permission dialog 2
1 parent 33f1bee commit 4ab9ccb

File tree

2 files changed

+42
-26
lines changed

2 files changed

+42
-26
lines changed

src/androidTestMedicmobilegammaDebug/java/org/medicmobile/webapp/mobile/LoginTests.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
import androidx.test.ext.junit.runners.AndroidJUnit4;
3333
import androidx.test.filters.LargeTest;
3434

35+
import androidx.test.uiautomator.UiDevice;
36+
import androidx.test.uiautomator.UiObject;
37+
import androidx.test.uiautomator.UiSelector;
38+
import androidx.test.platform.app.InstrumentationRegistry;
39+
3540
import org.hamcrest.Description;
3641
import org.hamcrest.Matcher;
3742
import org.hamcrest.TypeSafeMatcher;
@@ -42,6 +47,7 @@
4247
import org.junit.runners.MethodSorters;
4348

4449
import java.util.Locale;
50+
4551
@LargeTest
4652
@RunWith(AndroidJUnit4.class)
4753
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -56,14 +62,16 @@ public class LoginTests {
5662
@Test
5763
public void testLoginScreen() throws Exception {
5864
onData(anything())
59-
.inAdapterView(withId(R.id.lstServers))
60-
.atPosition(0)
61-
.perform(click());
65+
.inAdapterView(withId(R.id.lstServers))
66+
.atPosition(0)
67+
.perform(click());
6268
onView(withText("Continue"))
63-
.inRoot(isDialog())
64-
.perform(click());
69+
.inRoot(isDialog())
70+
.perform(click());
6571
Thread.sleep(7000);//TODO: use better ways to handle delays
6672

73+
allowNotificationPermission();
74+
6775
ViewInteraction webView = onView(
6876
allOf(withId(R.id.wbvMain),
6977
withParent(allOf(withId(R.id.lytWebView),
@@ -124,4 +132,12 @@ public boolean matchesSafely(View view) {
124132
}
125133
};
126134
}
135+
136+
private void allowNotificationPermission() throws Exception {
137+
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
138+
UiObject allowButton = device.findObject(new UiSelector().text("Allow"));
139+
if (allowButton.exists() && allowButton.isEnabled()) {
140+
allowButton.click();
141+
}
142+
}
127143
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,22 @@ public void serverSelectionScreenIsDisplayed() {
8888
@Test
8989
public void testLoginScreen() throws Exception {
9090
onData(anything())
91-
.inAdapterView(withId(R.id.lstServers))
92-
.atPosition(1)
93-
.perform(click());
91+
.inAdapterView(withId(R.id.lstServers))
92+
.atPosition(1)
93+
.perform(click());
9494

9595
onView(withText("Login to Gamma Dev?"))
96-
.inRoot(isDialog())
97-
.check(matches(isDisplayed()));
96+
.inRoot(isDialog())
97+
.check(matches(isDisplayed()));
9898
onView(withText("Cancel"))
99-
.inRoot(isDialog())
100-
.check(matches(isDisplayed()));
99+
.inRoot(isDialog())
100+
.check(matches(isDisplayed()));
101101

102102
onView(withText("Continue"))
103-
.inRoot(isDialog())
104-
.perform(click());
103+
.inRoot(isDialog())
104+
.perform(click());
105105

106-
Thread.sleep(7000); //TODO: use better ways to handle delays
106+
Thread.sleep(7000); //TODO: use better ways to handle delays
107107

108108
allowNotificationPermission();
109109

@@ -153,13 +153,13 @@ public void testLoginScreen() throws Exception {
153153
@Test
154154
public void testCancelSelectedServer() {
155155
onData(anything())
156-
.inAdapterView(withId(R.id.lstServers))
157-
.atPosition(2)
158-
.perform(click());
156+
.inAdapterView(withId(R.id.lstServers))
157+
.atPosition(2)
158+
.perform(click());
159159

160160
onView(withText(R.string.btnCancel))
161-
.inRoot(isDialog())
162-
.perform(click());
161+
.inRoot(isDialog())
162+
.perform(click());
163163

164164
onView(withText("CHT Android")).check(matches(isDisplayed()));
165165
onView(withText("Custom")).check(matches(isDisplayed()));
@@ -204,21 +204,21 @@ public void testFilterServers() throws InterruptedException {
204204
onView(withText(SERVER_THREE)).check(matches(isDisplayed()));
205205

206206
onData(anything())
207-
.inAdapterView(withId(R.id.lstServers))
208-
.atPosition(0)
209-
.perform(click());
207+
.inAdapterView(withId(R.id.lstServers))
208+
.atPosition(0)
209+
.perform(click());
210210

211211
onView(withText("Login to Gamma Dev?"))
212-
.inRoot(isDialog())
213-
.check(matches(isDisplayed()));
212+
.inRoot(isDialog())
213+
.check(matches(isDisplayed()));
214214
}
215215

216216
private String getLanguage(String code) {
217217
Locale aLocale = new Locale(code);
218218
return aLocale.getDisplayName();
219219
}
220220

221-
private void allowNotificationPermission () throws Exception {
221+
private void allowNotificationPermission() throws Exception {
222222
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
223223
UiObject allowButton = device.findObject(new UiSelector().text("Allow"));
224224
if (allowButton.exists() && allowButton.isEnabled()) {

0 commit comments

Comments
 (0)