package ca.six.todo.addedittask;

import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import ca.six.todo.R;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.junit.Assert.*;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class AddEditTaskFragmentTest {

    @Rule
    public ActivityTestRule<AddEditTaskActivity> actvRule = new ActivityTestRule<>(AddEditTaskActivity. class);

    @Test
    public void createTask_emptyView(){
        onView(withId(R.id.add_task_title))
                .check(matches(withText("")));

        onView(withId(R.id.fab_edit_task_done))
                .perform(click());

        /*
        // SnackBar is not testable for now.
        String message = "TO DOs cannot be empty";
        onView(withText(message))
            .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
        */

        // Verify that the activity is still displayed (a correct task would close it).
        onView(withId(R.id.add_task_title))
                .check(matches(isDisplayed()));

    }

//    @Test
//    public void createTask_inputAndSaveTask(){
//        // screen is empty at first
//        onView(withId(R.id.add_task_title))
//                .check(matches(withText("")));
//
//        // type text and save
//        onView(withId(R.id.add_task_title))
//                .perform(typeText("grocery"));
//        onView(withId(R.id.add_task_description))
//                .perform(typeText("tomato, onion, garlic, eggplant"));
//        onView(withId(R.id.fab_edit_task_done))
//                .perform(click());
//
//        // check the result
//
//
//    }

}
@@ -1829,18 +1829,16 @@
 %0A    %7D%0A%0A
-//
     @Tes
@@ -1839,18 +1839,16 @@
   @Test%0A
-//
     publ
@@ -1886,18 +1886,16 @@
 Task()%7B%0A
-//
         
@@ -1922,18 +1922,16 @@
 t first%0A
-//
         
@@ -1958,34 +1958,32 @@
 dd_task_title))%0A
-//
                 
@@ -2009,29 +2009,25 @@
 Text(%22%22)));%0A
-//%0A//
+%0A
         // t
@@ -2044,18 +2044,16 @@
 nd save%0A
-//
         
@@ -2084,26 +2084,24 @@
 ask_title))%0A
-//
             
@@ -2131,26 +2131,24 @@
 grocery%22));%0A
-//
         onVi
@@ -2185,18 +2185,16 @@
 ption))%0A
-//
         
@@ -2256,18 +2256,16 @@
 ant%22));%0A
-//
         
@@ -2304,18 +2304,16 @@
 _done))%0A
-//
         
@@ -2339,21 +2339,17 @@
 ick());%0A
-//%0A//
+%0A
         
@@ -2371,17 +2371,131 @@
 sult
-%0A//%0A//%0A//
+ : %E8%BF%99%E4%B8%AA%E6%9D%A1%E4%BB%B6%E4%B8%8D%E5%A5%BD%E3%80%82%E5%9B%A0%E4%B8%BA%E5%9C%A8add%E9%A1%B5%E4%B8%8D%E9%80%80%E5%87%BA%EF%BC%8C%E8%BF%99%E4%B8%AA%22grocery%22%E4%B9%9F%E6%9C%89%E7%9A%84%0A//        onView(withText(%22grocery%22))%0A//            .check( matches(isDisplayed()) );%0A%0A
     

write unit test code