Created
December 15, 2019 20:28
-
-
Save j1n6/8ad9fed988d93797bafd8b4f1359144f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example.android.notepad.test; | |
import java.util.ArrayList; | |
import android.widget.ListView; | |
import com.example.android.notepad.NotesList; | |
import com.jayway.android.robotium.remotesolo.RemoteSolo; | |
import junit.extensions.TestSetup; | |
import junit.framework.Test; | |
import junit.framework.TestCase; | |
import junit.framework.TestSuite; | |
public class NoteListInconsistancyTest extends TestCase { | |
static RemoteSolo solo; | |
public static Test suite() { | |
TestSetup setup = new TestSetup(new TestSuite(NoteListInconsistancyTest.class)) { | |
// Standard test setup | |
protected void setUp() throws Exception { | |
solo = new RemoteSolo(NotesList.class); | |
// emulators connection setup | |
solo.addDevice("emulator-5554", 5000, 5000); | |
solo.addDevice("emulator-5556", 5003, 5003); | |
// Alternatively, add more device variations | |
//solo.addDevice("HT98YLZ00039", 5001, 5001); | |
solo.connect(); | |
} | |
// Standard test tear down | |
protected void tearDown() throws Exception { | |
solo.disconnect(); | |
} | |
}; | |
return setup; | |
} | |
// NOTE: | |
// One of the device should have added Note 1, | |
// but the other one do not have Note 1. | |
// The test should fail if search text results are not consistent on multiple devices. | |
public void testAddNote(){ | |
solo.clickOnMenuItem("Add note"); //Clicks on menu item | |
solo.enterText(0, "Note 2"); //Add note | |
solo.goBack(); | |
boolean expected = true; | |
boolean actual = solo.searchText("Note 1") && solo.searchText("Note 2"); | |
assertEquals("Note 1 and/or Note 2 are not found", expected, actual); | |
} | |
public void testListViewEqual(){ | |
ArrayList<ListView> lists = solo.getCurrentListViews(); // Clicks on a list line | |
ListView lv1 = lists.get(0); | |
ListView lv2 = lists.get(0); | |
boolean isequal = lv1.equals(lv2); | |
assertTrue(isequal); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment