package se.chalmers.watchmetest.ui;

import se.chalmers.watchme.R;
import se.chalmers.watchme.activity.AddMovieActivity;
import se.chalmers.watchme.activity.MainActivity;
import android.test.ActivityInstrumentationTestCase2;

import com.jayway.android.robotium.solo.Solo;

public class TagListFragmentTest extends
		ActivityInstrumentationTestCase2<MainActivity> {

	Solo solo;

	public TagListFragmentTest() {
		super(MainActivity.class);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		solo = new Solo(getInstrumentation(), getActivity());
	}

	@Override
	public void tearDown() throws Exception {
		// finish all activities that have been opened during test execution.
		solo.finishOpenedActivities();
	}
	
	public void testAddTag() {
		final int ADD_MOVIE_BUTTON = 1;
		
		solo.clickOnText("Movies");
		solo.clickOnActionBarItem(R.id.menu_add_movie);
		solo.enterText(0, "Batman");
		solo.enterText(1, "Action");
		solo.clickOnButton(ADD_MOVIE_BUTTON);
		solo.clickOnText("Tags");
		boolean wasTagFound = solo.searchText("action");
		assertTrue(wasTagFound);
	}

}

@@ -357,16 +357,135 @@
 ivity%3E %7B
+%0A%09%0A%09// TODO: make public static?%0A%09final int ADD_MOVIE_BUTTON = 1;%0A%09final int TITLE_FIELD = 0;%0A%09final int TAG_FIELD = 1;
 %0A%0A%09Solo 
@@ -883,42 +883,8 @@
 ) %7B%0A
-%09%09final int ADD_MOVIE_BUTTON = 1;%0A
 %09%09%0A%09
@@ -979,17 +979,27 @@
 terText(
-0
+TITLE_FIELD
 , %22Batma
@@ -1020,17 +1020,25 @@
 terText(
-1
+TAG_FIELD
 , %22Actio
@@ -1161,16 +1161,16 @@
 tion%22);%0A
-
 %09%09assert
@@ -1192,10 +1192,749 @@
 d);%0A%09%7D%0A%0A
+%09public void testClickTag() %7B%0A%09%09solo.clickOnText(%22Movies%22);%0A%09%09solo.clickOnActionBarItem(R.id.menu_add_movie);%0A%09%09solo.enterText(TITLE_FIELD, %22Batman%22);%0A%09%09solo.enterText(TAG_FIELD, %22Action%22);%0A%09%09solo.clickOnButton(ADD_MOVIE_BUTTON);%0A%09%09%0A%09%09solo.clickOnActionBarItem(R.id.menu_add_movie);%0A%09%09solo.enterText(0, %22Dead poet society%22);%0A%09%09solo.enterText(1, %22Drama%22);%0A%09%09solo.clickOnButton(ADD_MOVIE_BUTTON);%0A%09%09%0A%09%09solo.clickOnText(%22Tags%22);%0A%09%09solo.clickOnText(%22drama%22);%0A%09%09%0A%09%09solo.assertCurrentActivity(%22MainActivity expected%22, MainActivity.class);%0A%09%09boolean wasDramaMoviesFound = solo.searchText(%22Dead poet society%22);%0A%09%09boolean wasActionMoviesFound = solo.searchText(%22Batman%22);%0A%09%09assertTrue(wasDramaMoviesFound);%0A%09%09assertFalse(wasActionMoviesFound);%0A%09%7D%0A%0A
 %7D%0A

Add new test in TagListFragment: testClickTag()