3
3
4
4
import android .support .test .espresso .Root ;
5
5
import android .support .test .espresso .ViewInteraction ;
6
+ import android .support .test .filters .LargeTest ;
6
7
import android .support .test .rule .ActivityTestRule ;
7
8
import android .support .test .runner .AndroidJUnit4 ;
8
- import android .test .suitebuilder .annotation .LargeTest ;
9
9
10
10
import com .zulip .android .R ;
11
11
import com .zulip .android .ToastMatcher ;
12
12
import com .zulip .android .ZulipApp ;
13
+ import com .zulip .android .util .ZLog ;
13
14
14
15
import org .hamcrest .Matcher ;
15
16
import org .junit .Before ;
@@ -38,6 +39,7 @@ public class BaseTest {
38
39
39
40
private static final String PASSWORD_TEST = "yourpasswordhere" ;
40
41
private static final String EMAIL_TEST =
"[email protected] " ;
42
+ public static final String SERVER_URL = "www.local.test.com" ;
41
43
42
44
@ Rule
43
45
public ActivityTestRule <ZulipActivity > mActivityTestRule = new ActivityTestRule <>(ZulipActivity .class );
@@ -53,7 +55,22 @@ public void setUp() {
53
55
public void WrongLoginPasswordToast () {
54
56
if (ZulipApp .get ().getApiKey () != null ) {
55
57
logout ();
58
+ try {
59
+ Thread .sleep (4000 );
60
+ } catch (InterruptedException e ) {
61
+ ZLog .logException (e );
62
+ }
56
63
}
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
+
57
74
//Fill Username
58
75
ViewInteraction usernameVI = onView (
59
76
allOf (withId (R .id .username ), isDisplayed ()));
@@ -78,6 +95,23 @@ public static Matcher<Root> isToast() {
78
95
79
96
@ Test
80
97
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
+
81
115
//Open overflow menu
82
116
openActionBarOverflowOrOptionsMenu (getInstrumentation ().getTargetContext ());
83
117
@@ -88,21 +122,28 @@ public void logout() {
88
122
assertNull (ZulipApp .get ().getApiKey ());
89
123
}
90
124
125
+ @ Test
91
126
public void login () {
92
127
try {
93
128
Thread .sleep (1000 );
94
129
} catch (InterruptedException e ) {
95
- e . printStackTrace ( );
130
+ ZLog . logException ( e );
96
131
}
97
132
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
+
98
141
//Fill Username
99
- ViewInteraction usernameVI = onView (
100
- allOf (withId (R .id .username ), isDisplayed ()));
142
+ ViewInteraction usernameVI = onView (allOf (withId (R .id .username ), isDisplayed ()));
101
143
usernameVI .perform (replaceText (EMAIL_TEST ));
102
144
103
145
//Fill Password
104
- ViewInteraction passwordVI = onView (
105
- allOf (withId (R .id .password ), isDisplayed ()));
146
+ ViewInteraction passwordVI = onView (allOf (withId (R .id .password ), isDisplayed ()));
106
147
passwordVI .perform (replaceText (PASSWORD_TEST ));
107
148
108
149
//Click Login
0 commit comments