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;

/**
 * Starts from the ListActivity, but opens the StudyRoomDetailActivity
 */
public class StatisticsTest extends ActivityInstrumentationTestCase2<ListActivity> {

    private Solo mySolo;

    public StatisticsTest() {
        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 testStudyRoomDetailStatisticsOutput() {
        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.fullness_full)) ||
                    mySolo.searchText(getActivity().getString(R.string.fullness_halffull)) ||
                    mySolo.searchText(getActivity().getString(R.string.fullness_empty));
            assertEquals("Required text not found", true, text_found);
        }
    }
}
@@ -211,16 +211,67 @@
 ivity;%0A%0A
+import java.util.Calendar;%0Aimport java.util.Date;%0A%0A
 /**%0A * S
@@ -1662,10 +1662,913 @@
  %7D%0A    %7D
+%0A%0A    public void testStudyRoomDetailStatisticsCurrentDate() %7B%0A        mySolo.sleep(500);%0A        // If there are any items in the list%0A        // The second argument of searchText means it searches only for visible text (not hidden)%0A        if (!mySolo.searchText(getActivity().getString(R.string.no_fav), true)) %7B%0A            // Click on first list item%0A            mySolo.clickInList(1);%0A%0A            // Look for text in study room detail activity%0A            mySolo.waitForActivity(%22StudyRoomDetailActivity%22);%0A            Calendar calendar = Calendar.getInstance();%0A            int hour = calendar.get(Calendar.HOUR);%0A            int weekday = calendar.get(Calendar.DAY_OF_WEEK);%0A            boolean text_found = mySolo.searchText(%22Weekday: %22 + weekday) &&%0A                    mySolo.searchText(%22Time: %22 + hour);%0A            assertEquals(%22Required text not found%22, true, text_found);%0A        %7D%0A    %7D
 %0A%7D

Test Date and Time