package ca.six.todo.addedittask;

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.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("")));
    }

    @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


    }

}
@@ -27,16 +27,75 @@
 ttask;%0A%0A
+import android.support.test.espresso.matcher.ViewMatchers;%0A
 import a
@@ -620,16 +620,106 @@
 atches;%0A
+import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;%0A
 import s
@@ -1238,23 +1238,287 @@
 (%22%22)));%0A
+%0A        onView(withId(R.id.fab_edit_task_done))%0A                .perform(click());%0A%0A        String message = %22TO DOs cannot be empty%22;%0A        onView(withText(message))%0A                .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));%0A%0A
     %7D%0A%0A
+//
     @Tes
@@ -1511,32 +1511,34 @@
  %7D%0A%0A//    @Test%0A
+//
     public void 
@@ -1564,24 +1564,26 @@
 SaveTask()%7B%0A
+//
         // s
@@ -1606,16 +1606,18 @@
 t first%0A
+//
         
@@ -1644,32 +1644,34 @@
 dd_task_title))%0A
+//
                 
@@ -1693,33 +1693,37 @@
 withText(%22%22)));%0A
-%0A
+//%0A//
         // type 
@@ -1736,16 +1736,18 @@
 nd save%0A
+//
         
@@ -1774,32 +1774,34 @@
 dd_task_title))%0A
+//
                 
@@ -1827,24 +1827,26 @@
 grocery%22));%0A
+//
         onVi
@@ -1883,16 +1883,18 @@
 ption))%0A
+//
         
@@ -1956,16 +1956,18 @@
 ant%22));%0A
+//
         
@@ -1998,32 +1998,34 @@
 dit_task_done))%0A
+//
                 
@@ -2035,33 +2035,37 @@
 rform(click());%0A
-%0A
+//%0A//
         // check
@@ -2076,18 +2076,24 @@
  result%0A
-%0A%0A
+//%0A//%0A//
     %7D%0A%0A%7D

write unit test code