-
Notifications
You must be signed in to change notification settings - Fork 384
Expand file tree
/
Copy pathContactsCompletionViewTest.java
More file actions
44 lines (36 loc) · 1.44 KB
/
ContactsCompletionViewTest.java
File metadata and controls
44 lines (36 loc) · 1.44 KB
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
package com.tokenautocomplete;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.tokenautocomplete.TokenMatchers.emailForPerson;
import static com.tokenautocomplete.TokenMatchers.tokenCount;
import static org.hamcrest.Matchers.is;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ContactsCompletionViewTest {
@Rule
public ActivityTestRule<TokenActivity> activityRule = new ActivityTestRule<>(
TokenActivity.class);
@Test
public void completesOnComma() throws Exception {
onView(withId(R.id.searchView))
.perform(typeText("mar,"))
.check(matches(emailForPerson(2, is("marshall@example.com"))));
}
@Test
public void doesntCompleteWithoutComma() throws Exception {
onView(withId(R.id.searchView))
.perform(typeText("mar"))
.check(matches(tokenCount(is(2))));
}
}