Back to project page android-view-selector.
The source code is released under:
Copyright (c) 2013 Nik Haldimann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...
If you think the Android project android-view-selector listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nikhaldimann.viewselector.android.activities; /*from w w w .j a v a 2s.c o m*/ import static com.nikhaldimann.viewselector.ViewSelectorAssertions.assertThatSelection; import android.test.ActivityInstrumentationTestCase2; import com.nikhaldimann.viewselector.test.ListViewExampleActivity; /** * Example unit test for an activity with a dynamic list view. The activity has * a ListView with the id "groceries". We can add items to the list. * * Keep this example self-contained so it can be referenced from documentation. */ public class ListViewExampleActivityTest extends ActivityInstrumentationTestCase2<ListViewExampleActivity> { private ListViewExampleActivity activity; public ListViewExampleActivityTest() { super(ListViewExampleActivity.class); } @Override protected void setUp() throws Exception { super.setUp(); activity = getActivity(); } public void testListView() { // Assert that there is a ListView with id "groceries" in this activity assertThatSelection("ListView#groceries", activity).hasSize(1); // Assert that the groceries ListView currently has no items in it assertThatSelection("#groceries TextView", activity).isEmpty(); // Add a couple of items to the list and wait for the UI to update itself activity.runOnUiThread(new Runnable() { public void run() { activity.addGroceryItem("Milk"); activity.addGroceryItem("Cereal"); } }); getInstrumentation().waitForIdleSync(); // Assert that the groceries ListView now has two items assertThatSelection("#groceries TextView", activity) .hasSize(2) .attribute("text").containsExactly("Milk", "Cereal"); } }