@@ -0,0 +1,2393 @@
+package se.chalmers.watchmetest.activity;%0A%0Aimport se.chalmers.watchme.R;%0Aimport se.chalmers.watchme.activity.MainActivity;%0Aimport se.chalmers.watchme.database.DatabaseHelper;%0Aimport se.chalmers.watchmetest.Constants;%0Aimport android.test.ActivityInstrumentationTestCase2;%0Aimport android.view.KeyEvent;%0A%0Aimport com.jayway.android.robotium.solo.Solo;%0A%0A/**%0A * Class that tests functionality implemented in the SearchableActivity class.%0A * Tests are performed with methods from the robotium api.%0A * %0A * @author mattiashenriksson%0A * %0A */%0Apublic class SearchableActivityTest extends%0A%09%09ActivityInstrumentationTestCase2%3CMainActivity%3E %7B%0A%0A%09Solo solo;%0A%09DatabaseHelper dbh;%0A%0A%09public SearchableActivityTest() %7B%0A%09%09super(MainActivity.class);%0A%09%7D%0A%0A%09@Override%0A%09protected void setUp() throws Exception %7B%0A%09%09super.setUp();%0A%09%09solo = new Solo(getInstrumentation(), getActivity());%0A%09%09dbh = new DatabaseHelper(getActivity());%0A%09%7D%0A%0A%09@Override%0A%09public void tearDown() throws Exception %7B%0A%09%09// Finish all activities that have been opened during test execution.%0A%09%09solo.finishOpenedActivities();%0A%0A%09%09// Clear list of movies stored in database%0A%09%09dbh.onUpgrade(dbh.getWritableDatabase(), 1, 1);%0A%09%7D%0A%0A%09/**%0A%09 * Test if you can search for movies and if the application will display the correct result if you do.%0A%09 */%0A%09public void testSearch() %7B%0A%09%09// Clear list of movies stored in database%0A%09%09dbh.onUpgrade(dbh.getWritableDatabase(), 1, 1);%0A%09%09%09%0A%09%09solo.waitForActivity(%22MainActivity%22);%0A%0A%09%09// Add two movies with different titles%0A%09%09char movieFirstCharacter = 'A';%0A%09%09for (int i = 0; i %3C 2; i++) %7B%0A%09%09%09solo.clickOnActionBarItem(R.id.menu_add_movie);%0A%09%09%09solo.waitForActivity(%22AddMovieActivity%22);%0A%09%09%09solo.enterText(Constants.TITLE_FIELD, movieFirstCharacter%0A%09%09%09%09%09+ %22_MOVIE%22);%0A%09%09%09solo.clickOnButton(Constants.ADD_MOVIE_BUTTON);%0A%09%09%09solo.waitForActivity(%22MainActivity%22);%0A%0A%09%09%09movieFirstCharacter++;%0A%09%09%7D%0A%09%09%0A%09%09// Search for one of the movies%0A%09%09solo.clickOnActionBarItem(R.id.menu_search_button);%0A%09%09solo.sleep(2000);%0A%09%09solo.enterText(0, %22A_%22);%0A%09%09solo.sendKey(KeyEvent.KEYCODE_ENTER);%0A%09%09%09%0A%09%09boolean isSearchableActivityViewed = solo.waitForActivity(%22SearchableActivity%22);%0A%09%09assertTrue(isSearchableActivityViewed);%0A%09%09%09%0A%09%09boolean isAMovieViewed = solo.searchText(%22A_MOVIE%22);%0A%09%09boolean isBMovieViewed = solo.searchText(%22B_MOVIE%22);%0A%09%09%0A%09%09// Check that the correct result is displayed%0A%09%09assertTrue(isAMovieViewed);%0A%09%09assertFalse(isBMovieViewed);%0A%09%09%09%0A%09%7D%0A%7D%0A

Add new file SearchableActivityTest with tests on SearchableActivity