blob: dea81d73ea1f3d826789b0e9594bfa918600bef2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package se.leap.bitmaskclient.test;
import android.view.*;
import com.robotium.solo.*;
import se.leap.bitmaskclient.*;
public class UserStatusTestController {
private final Solo solo;
public UserStatusTestController(Solo solo) {
this.solo = solo;
}
void clickUserSessionButton() {
solo.clickOnView(getUserSessionButton());
}
View getUserSessionButton() throws IllegalStateException {
View view = solo.getView(R.id.user_status_button);
if(view == null)
throw new IllegalStateException();
return view;
}
void logIn(String username, String password) {
solo.enterText(0, username);
solo.enterText(1, password);
solo.clickOnText(solo.getString(R.string.login_button));
solo.waitForDialogToClose();
assertLoggedIn();
}
private void assertLoggedIn() {
String log_out = solo.getString(R.string.logout_button);
solo.waitForText(log_out);
}
void assertLoggedOut() {
String log_in = solo.getString(R.string.login_button);
solo.waitForText(log_in);
}
void logOut() {
assertLoggedIn();
clickUserSessionButton();
solo.clickOnActionBarItem(R.string.logout_button);
solo.waitForDialogToClose();
assertLoggedOut();
}
}
|