-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignInActivityTest_Java.java
89 lines (69 loc) · 2.43 KB
/
SignInActivityTest_Java.java
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.achhatra.threepio.testing.testapp;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.achhatra.threepio.testing.caffelatte.interactors.IButton;
import com.achhatra.threepio.testing.caffelatte.interactors.ICheckBox;
import com.achhatra.threepio.testing.caffelatte.interactors.IEditText;
import com.threepio.testing.SigninActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.text.InputType.TYPE_CLASS_TEXT;
import static android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
import static com.achhatra.threepio.testing.caffelatte.interactors.IButton.forButton;
import static com.achhatra.threepio.testing.caffelatte.interactors.ICheckBox.forCheckBox;
import static com.achhatra.threepio.testing.caffelatte.interactors.IEditText.forEditText;
@RunWith(AndroidJUnit4.class)
public class SignInActivityTest_Java {
@Rule
public ActivityTestRule<SigninActivity> rule = new ActivityTestRule<>(SigninActivity.class);
private IEditText userName = forEditText()
.withId(R.id.user_name)
.build();
private IEditText password = forEditText()
.withId(R.id.password)
.build();
private ICheckBox showPassword = forCheckBox()
.withId(R.id.show_password)
.build();
private IButton signInButton = forButton()
.withId(R.id.sign_in)
.withText("Sign In")
.build();
@Test
public void testInitialScreen() {
userName
.isDisplayed()
.hasHint("User Email")
.hasEmptyText()
.hasInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
password
.isDisplayed()
.hasHint("Password")
.hasEmptyText()
.hasInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
showPassword
.isDisplayed()
.hasText("Show password")
.isNotChecked();
signInButton
.isDisplayed()
.isNotEnabled();
}
@Test
public void testPasswordToggle() {
String passwordText = "lkj3474";
password.typeText(passwordText);
showPassword.check();
password.hasInputType(TYPE_CLASS_TEXT);
showPassword.uncheck();
password.hasInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
}
@Test
public void testEnableSignInOnValidUserDetails() {
userName.typeText("abcd@email.com");
password.typeText("E948fkfj");
signInButton.isEnabled();
}
}