Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 6612688

Browse files
kunall17niftynei
authored andcommitted
Modified BaseTest to support the new login flow
1 parent 66ddde9 commit 6612688

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

app/src/androidTest/java/com/zulip/android/activities/BaseTest.java

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
import android.support.test.espresso.Root;
55
import android.support.test.espresso.ViewInteraction;
6+
import android.support.test.filters.LargeTest;
67
import android.support.test.rule.ActivityTestRule;
78
import android.support.test.runner.AndroidJUnit4;
8-
import android.test.suitebuilder.annotation.LargeTest;
99

1010
import com.zulip.android.R;
1111
import com.zulip.android.ToastMatcher;
1212
import com.zulip.android.ZulipApp;
13+
import com.zulip.android.util.ZLog;
1314

1415
import org.hamcrest.Matcher;
1516
import org.junit.Before;
@@ -38,6 +39,7 @@ public class BaseTest {
3839

3940
private static final String PASSWORD_TEST = "yourpasswordhere";
4041
private static final String EMAIL_TEST = "[email protected]";
42+
public static final String SERVER_URL = "www.local.test.com";
4143

4244
@Rule
4345
public ActivityTestRule<ZulipActivity> mActivityTestRule = new ActivityTestRule<>(ZulipActivity.class);
@@ -53,7 +55,22 @@ public void setUp() {
5355
public void WrongLoginPasswordToast() {
5456
if (ZulipApp.get().getApiKey() != null) {
5557
logout();
58+
try {
59+
Thread.sleep(4000);
60+
} catch (InterruptedException e) {
61+
ZLog.logException(e);
62+
}
5663
}
64+
65+
//Fill Server URL
66+
ViewInteraction serverURLInteraction = onView(allOf(withId(R.id.server_url_in), isDisplayed()));
67+
serverURLInteraction.perform(replaceText(SERVER_URL));
68+
69+
//Click Enter server URL
70+
ViewInteraction enterServerUrl = onView(allOf(withId(R.id.server_btn), withText(R.string.enter), isDisplayed()));
71+
enterServerUrl.perform(click());
72+
73+
5774
//Fill Username
5875
ViewInteraction usernameVI = onView(
5976
allOf(withId(R.id.username), isDisplayed()));
@@ -78,6 +95,23 @@ public static Matcher<Root> isToast() {
7895

7996
@Test
8097
public void logout() {
98+
try {
99+
Thread.sleep(2000);
100+
} catch (InterruptedException e) {
101+
ZLog.logException(e);
102+
}
103+
mActivityTestRule.getActivity().runOnUiThread(new Runnable() {
104+
@Override
105+
public void run() {
106+
mActivityTestRule.getActivity().showView(mActivityTestRule.getActivity().findViewById(R.id.appBarLayout));
107+
}
108+
});
109+
try {
110+
Thread.sleep(2000);
111+
} catch (InterruptedException e) {
112+
ZLog.logException(e);
113+
}
114+
81115
//Open overflow menu
82116
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
83117

@@ -88,21 +122,28 @@ public void logout() {
88122
assertNull(ZulipApp.get().getApiKey());
89123
}
90124

125+
@Test
91126
public void login() {
92127
try {
93128
Thread.sleep(1000);
94129
} catch (InterruptedException e) {
95-
e.printStackTrace();
130+
ZLog.logException(e);
96131
}
97132

133+
//Fill Server URL
134+
ViewInteraction serverURLInteraction = onView(allOf(withId(R.id.server_url_in), isDisplayed()));
135+
serverURLInteraction.perform(replaceText(SERVER_URL));
136+
137+
//Click Enter server URL
138+
ViewInteraction enterServerUrl = onView(allOf(withId(R.id.server_btn), withText(R.string.enter), isDisplayed()));
139+
enterServerUrl.perform(click());
140+
98141
//Fill Username
99-
ViewInteraction usernameVI = onView(
100-
allOf(withId(R.id.username), isDisplayed()));
142+
ViewInteraction usernameVI = onView(allOf(withId(R.id.username), isDisplayed()));
101143
usernameVI.perform(replaceText(EMAIL_TEST));
102144

103145
//Fill Password
104-
ViewInteraction passwordVI = onView(
105-
allOf(withId(R.id.password), isDisplayed()));
146+
ViewInteraction passwordVI = onView(allOf(withId(R.id.password), isDisplayed()));
106147
passwordVI.perform(replaceText(PASSWORD_TEST));
107148

108149
//Click Login

app/src/main/res/layout/main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<android.support.design.widget.AppBarLayout
1515
android:layout_width="match_parent"
1616
android:layout_height="wrap_content"
17+
android:id="@+id/appBarLayout"
1718
android:theme="@style/AppTheme.AppBarOverlay"
1819
app:layout_behavior="com.zulip.android.util.RemoveViewsOnScroll">
1920

0 commit comments

Comments
 (0)