本文整理汇总了Java中android.support.test.espresso.DataInteraction类的典型用法代码示例。如果您正苦于以下问题:Java DataInteraction类的具体用法?Java DataInteraction怎么用?Java DataInteraction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataInteraction类属于android.support.test.espresso包,在下文中一共展示了DataInteraction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performStartAdventure
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
protected void performStartAdventure() {
ViewInteraction button = onView(allOf(withText(getString(R.string.create_new_adventure)), isDisplayed()));
button.perform(click());
//Clicks over the proper book using the property order of the GamebookEnum
DataInteraction textView = onData(anything())
.inAdapterView(allOf(withId(R.id.gamebookListView),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
0)))
.atPosition(getGamebook().getOrder() - 1);
textView.perform(click());
button = onView(allOf(withText(getString(R.string.create_new_adventure)), isDisplayed()));
button.perform(click());
Espresso.closeSoftKeyboard();
}
示例2: onListItem
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
/**
*/
@SuppressWarnings("unchecked")
public static DataInteraction onListItem(int pos) {
return onData(anything())
.inAdapterView(allOf(withId(android.R.id.list), isDisplayed()))
.atPosition(pos);
}
示例3: performChoosemartialArt
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
public void performChoosemartialArt() {
DataInteraction linearLayout = onData(anything())
.inAdapterView(allOf(withId(R.id.skillList),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1)))
.atPosition(0);
linearLayout.perform(click());
}
示例4: performChooseSpells
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
public void performChooseSpells() {
DataInteraction textView2 = onData(anything())
.inAdapterView(allOf(withId(R.id.spellListView),
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
1)))
.atPosition(0);
textView2.perform(click());
DataInteraction textView3 = onData(anything())
.inAdapterView(allOf(withId(R.id.spellListView),
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
1)))
.atPosition(0);
textView3.perform(click());
DataInteraction textView4 = onData(anything())
.inAdapterView(allOf(withId(R.id.spellListView),
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
1)))
.atPosition(1);
textView4.perform(click());
DataInteraction textView5 = onData(anything())
.inAdapterView(allOf(withId(R.id.spellListView),
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
1)))
.atPosition(1);
textView5.perform(click());
}
示例5: performChooseSuperpower
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
public void performChooseSuperpower() {
DataInteraction linearLayout = onData(anything())
.inAdapterView(allOf(withId(R.id.superpowerList),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1)))
.atPosition(0);
linearLayout.perform(click());
}
示例6: performChoosePotion
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
protected void performChoosePotion() {
DataInteraction linearLayout = onData(anything())
.inAdapterView(allOf(withId(R.id.potionList),
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
0)))
.atPosition(0);
linearLayout.perform(click());
}
示例7: testExistingGroup
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
@Test
public void testExistingGroup() throws InterruptedException {
//Given a preexisting group newGroup, when we search for new group in the list view,
//then the new group is still there (and clickable)
Thread.sleep(1000);
DataInteraction v2 = onData(hasToString(startsWith("newGroup")))
.inAdapterView(withId(R.id.groupList)).atPosition(0);
v2.check(matches(withText("newGroup")));
}
示例8: testOpenMeal
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
/**
* Tests clicking on a meal in the meal list to open it
*/
public void testOpenMeal() throws SQLException {
final Matcher<View> mealList = withTagKey(R.id.test_tag_meal_list,
Is.<Object>is("Meal List"));
final DataInteraction mealItem = onData(anything()).inAdapterView(mealList);
mealItem.perform(click());
// Check that the MealViewActivity activity has started
// The below statement produces an error in the instrumentation code.
// TODO: Fix
// intended(hasComponent(new ComponentName(getInstrumentation().getTargetContext(),
// MealViewActivity.class)));
}
示例9: with
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
public ActionableData with(C content)
{
DataInteraction dataInteraction = onData(dataMatcher(content));
if (resourceId != 0)
{
return new ActionableData(dataInteraction.inAdapterView(withId(resourceId)));
}
else
{
return new ActionableData(dataInteraction);
}
}
示例10: test_schedule_saturday
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
@Test
public void test_schedule_saturday() {
String fromName = "San Francisco";
String toName = "22nd St";
onView(withId(R.id.btn_sat)).perform(click());
onView(withId(R.id.input_departure)).perform(click());
onData(is(fromName)).perform(click());
onView(withId(R.id.input_arrival)).perform(click());
onData(is(toName)).perform(click());
List<String> expects = Arrays.asList("08:07 => 08:11",
"09:37 => 09:41",
"11:07 => 11:11",
"12:37 => 12:41",
"14:07 => 14:11",
"15:37 => 15:41",
"17:07 => 17:11",
"18:37 => 18:41",
"20:07 => 20:11",
"21:37 => 21:41",
"22:51 => 22:55",
"00:05 => 00:10");
onView(withId(R.id.results)).check(matches(new ResultListMatcher(fromName,
toName,
expects.size())));
DataInteraction interaction = onData(anything()).inAdapterView(withId(R.id.results));
for (int l = expects.size() - 1; l >= 0; l--) {
String expect = expects.get(l);
interaction
.atPosition(l)
.check(matches(new ResultViewMatcher(fromName, toName, l, expect)));
}
}
示例11: test_schedule_sunday
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
@Test
public void test_schedule_sunday() {
String fromName = "San Francisco";
String toName = "22nd St";
onView(withId(R.id.btn_sun)).perform(click());
onView(withId(R.id.input_departure)).perform(click());
onData(is(fromName)).perform(click());
onView(withId(R.id.input_arrival)).perform(click());
onData(is(toName)).perform(click());
List<String> expects = Arrays.asList("08:07 => 08:11",
"09:37 => 09:41",
"11:07 => 11:11",
"12:37 => 12:41",
"14:07 => 14:11",
"15:37 => 15:41",
"17:07 => 17:11",
"18:37 => 18:41",
"20:07 => 20:11",
"21:37 => 21:41");
onView(withId(R.id.results)).check(matches(new ResultListMatcher(fromName,
toName,
expects.size())));
DataInteraction interaction = onData(anything()).inAdapterView(withId(R.id.results));
for (int l = expects.size() - 1; l >= 0; l--) {
String expect = expects.get(l);
interaction
.atPosition(l)
.check(matches(new ResultViewMatcher(fromName, toName, l, expect)));
}
}
示例12: testArticleLoad
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
public static void testArticleLoad(Activity activity) {
while (!viewIsDisplayed(R.id.search_results_list)) {
waitFor(WAIT_FOR_1000);
}
DataInteraction view = onData(anything())
.inAdapterView(allOf(withId(R.id.search_results_list),
childAtPosition(
withId(R.id.search_results_container),
1)))
.atPosition(0);
view.perform(click());
while (!viewIsDisplayed(R.id.view_page_header_image)) {
waitFor(WAIT_FOR_2000);
}
ScreenshotTools.snap("Barack");
onView(withId(R.id.view_page_header_image))
.perform(swipeUp());
onView(withId(R.id.page_fragment))
.perform(swipeUp());
ScreenshotTools.snap("ArticleSwipeUpNoActionBar");
onView(withId(R.id.page_fragment))
.perform(swipeUp());
onView(withId(R.id.page_fragment))
.perform(swipeDown());
ScreenshotTools.snap("ArticleSwipeDownActionBarAndTabSeen");
}
示例13: onSpinnerString
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
static DataInteraction onSpinnerString(String value) {
return onData(allOf(instanceOf(String.class), is(value))).inRoot(not(isDialog()));
}
示例14: testAddMember
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
@Test
public void testAddMember(){
//Given that we have a new group, when we click on it
onData(hasToString(startsWith("Group E")))
.inAdapterView(withId(R.id.groupList)).atPosition(0)
.perform(click());
//and when we click on members in the content page
ViewInteraction appCompatTextView7 = onView(
allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
appCompatTextView7.perform(click());
//and when we click on add members
onView(withId(R.id.addmembers))
.perform(click());
//and when we type in the name of and email of the new member
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.tbMemberName), isDisplayed()));
appCompatEditText.perform(click());
appCompatEditText.perform(replaceText("Harry"), closeSoftKeyboard());
ViewInteraction appCompatEditText4 = onView(
allOf(withId(R.id.tbMemberEmail), isDisplayed()));
appCompatEditText4.perform(replaceText("[email protected]"), closeSoftKeyboard());
ViewInteraction appCompatEditText5 = onView(
allOf(withId(R.id.tbMemberEmail), withText("[email protected]"), isDisplayed()));
appCompatEditText5.perform(pressImeActionButton());
//and click on the button add member
ViewInteraction appCompatButton2 = onView(
allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
appCompatButton2.perform(click());
ViewInteraction appCompatTextView5 = onView(
allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
appCompatTextView5.perform(click());
//then a new member with the info we just inputted appears in the list view
DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
.inAdapterView(withId(R.id.lvMembers)).atPosition(0);
v2.check(matches(withText("[email protected]")));
}
示例15: testAddMember
import android.support.test.espresso.DataInteraction; //导入依赖的package包/类
@Test
public void testAddMember() throws InterruptedException {
Thread.sleep(1000);
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.myFab),
withParent(allOf(withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
floatingActionButton.perform(click());
Thread.sleep(1000);
//and when we create a new group
onView(withId(R.id.userInputDialog))
.perform(typeText("Group C"));
Thread.sleep(1000);
ViewInteraction appCompatButton = onView(
allOf(withId(android.R.id.button1), withText("Create"),
withParent(allOf(withId(R.id.buttonPanel),
withParent(withId(R.id.parentPanel)))),
isDisplayed()));
appCompatButton.perform(click());
//when we enter the new group
onData(hasToString(startsWith("Group C")))
.inAdapterView(withId(R.id.groupList)).atPosition(0)
.perform(click());
//When we click on members...
ViewInteraction appCompatTextView7 = onView(
allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
appCompatTextView7.perform(click());
//then members content page appears. When we click on it...
onView(withId(R.id.addmembers))
.check(matches(isDisplayed()))
.perform(click());
//Then Dialog appears to enter member
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.tbMemberName), isDisplayed()));
appCompatEditText.perform(click());
//When we enter "Students" for the name of the new member
appCompatEditText.perform(replaceText("Students"), closeSoftKeyboard());
//and when we enter an email
ViewInteraction appCompatEditText4 = onView(
allOf(withId(R.id.tbMemberEmail), isDisplayed()));
appCompatEditText4.perform(typeText("[email protected]"), closeSoftKeyboard());
//and when we click addmember
ViewInteraction appCompatButton2 = onView(
allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
appCompatButton2.perform(click());
//and when we cut away from member content page
ViewInteraction appCompatTextView5 = onView(
allOf(withId(android.R.id.title), withText("Info"), isDisplayed()));
appCompatTextView5.perform(click());
//when we come back to the member content page
ViewInteraction appCompatTextView9 = onView(
allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
appCompatTextView9.perform(click());
//the new member's email is still there!
DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
.inAdapterView(withId(R.id.lvMembers)).atPosition(0);
v2.check(matches(withText("[email protected]")));
}