package com.sw_ss16.lc_app.ui.tests;

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;
import com.sw_ss16.lc_app.R;
import com.sw_ss16.lc_app.ui.learning_center_list.ListActivity;

/**
 * Tests that start from the ListActivity
 */
public class ListActivityTest extends ActivityInstrumentationTestCase2<ListActivity> {

    private Solo mySolo;

    public ListActivityTest() {
        super(ListActivity.class);
    }

    public void setUp() throws Exception {
        super.setUp();
        mySolo = new Solo(getInstrumentation(), getActivity());

    }

    public void tearDown() throws Exception {
        mySolo.finishOpenedActivities();
        super.tearDown();
    }

    public void testNavigationDrawerOpen() {
        mySolo.sleep(500);
        mySolo.clickOnImageButton(0);
        mySolo.sleep(500);

        boolean text_found = mySolo.searchText(getActivity().getString(R.string.navigation_title));
        assertEquals("Required text not found", true, text_found);
    }

    public void testStudyRoomDetailOpen() {
        mySolo.sleep(500);
        // If there are any items in the list
        // The second argument of searchText means it searches only for visible text (not hidden)
        if (!mySolo.searchText(getActivity().getString(R.string.no_fav), true)) {
            // Click on first list item
            mySolo.clickInList(1);

            // Look for text in study room detail activity
            mySolo.waitForActivity("StudyRoomDetailActivity");
            boolean text_found = mySolo.searchText(getActivity().getString(R.string.lc_statistics_title));
            assertEquals("Required text not found", true, text_found);
        }
    }
}
@@ -84,16 +84,48 @@
 stCase2;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -1005,32 +1005,34 @@
 (%22Required text 
+1 
 not found%22, true
@@ -1552,58 +1552,251 @@
 %22);%0A
-            boolean text_found = mySolo.searchText
+%0A            TextView view = (TextView) mySolo.getView(R.id.lc_statistics_title);%0A%0A            System.out.println(view.getText());%0A%0A            boolean text_found = mySolo.searchText(view.getText().toString());%0A            //System.out.println
 (get
@@ -1888,16 +1888,18 @@
 ed text 
+2 
 not foun

change test from string to textview, text check