/*
 * Copyright 2015, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.testing.notes.notes;

import com.example.android.testing.notes.R;

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

import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.v4.widget.DrawerLayout;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.Gravity;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.contrib.DrawerActions.open;
import static android.support.test.espresso.contrib.DrawerMatchers.isClosed;
import static android.support.test.espresso.contrib.DrawerMatchers.isOpen;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static com.example.android.testing.notes.custom.action.NavigationViewActions.navigateTo;
import static org.junit.Assert.fail;

/**
 * Tests for the {@link DrawerLayout} layout component in {@link NotesActivity} which manages
 * navigation within the app.
 */
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AppNavigationTest {

    /**
     * {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
     *
     * <p>
     * Rules are interceptors which are executed for each test method and are important building
     * blocks of Junit tests.
     */
    @Rule
    public ActivityTestRule<NotesActivity> mActivityTestRule =
            new ActivityTestRule<>(NotesActivity.class);

    @Test
    public void clickOnStatisticsNavigationItem_ShowsStatisticsScreen() {
        fail("Implement step 9");
//        // Open Drawer to click on navigation.
//        onView(withId(R.id.drawer_layout))
//                .check(matches(isClosed(Gravity.LEFT))) // Left Drawer should be closed.
//                .perform(open()); // Open Drawer
//
//        // Start statistics screen.
//        onView(withId(R.id.nav_view))
//                .perform(navigateTo(R.id.statistics_navigation_menu_item));
//
//        // Check that statistics Activity was opened.
//        String expectedNoStatisticsText = InstrumentationRegistry.getTargetContext()
//                .getString(R.string.no_statistics_available);
//        onView(withId(R.id.no_statistics)).check(matches(withText(expectedNoStatisticsText)));
    }

    @Test
    public void clickOnAndroidHomeIcon_OpensNavigation() {
        fail("Implement step 9");
//        // Check that left drawer is closed at startup
//        onView(withId(R.id.drawer_layout))
//                .check(matches(isClosed(Gravity.LEFT))); // Left Drawer should be closed.
//
//        // Open Drawer
//        onView(withContentDescription("Navigate up")).perform(click());
//
//        // Check if drawer is open
//        onView(withId(R.id.drawer_layout))
//                .check(matches(isOpen(Gravity.LEFT))); // Left drawer is open open.
    }

}
@@ -2553,24 +2553,26 @@
 sScreen() %7B%0A
+//
         fail
@@ -2585,34 +2585,32 @@
 ement step 9%22);%0A
-//
         // Open 
@@ -2640,18 +2640,16 @@
 gation.%0A
-//
         
@@ -2675,34 +2675,32 @@
 drawer_layout))%0A
-//
                 
@@ -2768,26 +2768,24 @@
  be closed.%0A
-//
             
@@ -2821,21 +2821,17 @@
  Drawer%0A
-//%0A//
+%0A
         
@@ -2858,18 +2858,16 @@
 screen.%0A
-//
         
@@ -2896,18 +2896,16 @@
 _view))%0A
-//
         
@@ -2968,29 +2968,25 @@
 enu_item));%0A
-//%0A//
+%0A
         // C
@@ -3027,18 +3027,16 @@
 opened.%0A
-//
         
@@ -3112,18 +3112,16 @@
 ntext()%0A
-//
         
@@ -3174,18 +3174,16 @@
 lable);%0A
-//
         
@@ -3345,16 +3345,18 @@
 ion() %7B%0A
+//
         
@@ -3381,18 +3381,16 @@
 ep 9%22);%0A
-//
         
@@ -3436,18 +3436,16 @@
 startup%0A
-//
         
@@ -3471,34 +3471,32 @@
 drawer_layout))%0A
-//
                 
@@ -3569,21 +3569,17 @@
 closed.%0A
-//%0A//
+%0A
         
@@ -3593,18 +3593,16 @@
  Drawer%0A
-//
         
@@ -3669,13 +3669,9 @@
 ));%0A
-//%0A//
+%0A
     
@@ -3701,18 +3701,16 @@
 is open%0A
-//
         
@@ -3744,18 +3744,16 @@
 ayout))%0A
-//
         

update test