package com.andela.voluminotesapp.activities;

import android.os.Build;
import android.view.View;

import com.andela.voluminotesapp.BuildConfig;
import com.andela.voluminotesapp.R;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.*;

/**
 * Created by andela on 2/23/16.
 */
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
@RunWith(RobolectricGradleTestRunner.class)
public class MainActivityTest {

    private MainActivity mainActivity;

    @Before
    public void setUp() throws Exception {
        mainActivity = Robolectric.setupActivity(MainActivity.class);
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testOnCreate() throws Exception {
        View view = mainActivity.findViewById(R.id.drawer_layout);
        assertNotNull(view);
    }

    @Test
    public void testOnBackPressed() throws Exception {
        
    }

    @Test
    public void testOnCreateOptionsMenu() throws Exception {

    }

    @Test
    public void testOnOptionsItemSelected() throws Exception {

    }

    @Test
    public void testOnNavigationItemSelected() throws Exception {

    }

    @Test
    public void testOnViewDrag() throws Exception {

    }

    @Test
    public void testOnNoteTouch() throws Exception {

    }

    @Test
    public void testOnNoteClick() throws Exception {

    }

    @Test
    public void testOnNoteDelete() throws Exception {

    }

    @Test
    public void testOnClick() throws Exception {

    }

    @Test
    public void testOnSaveInstanceState() throws Exception {

    }

    @Test
    public void testOnPause() throws Exception {

    }
}
@@ -59,16 +59,103 @@
 oid.
-os.Build
+content.Intent;%0Aimport android.os.Build;%0Aimport android.view.Menu;%0Aimport android.view.MenuItem
 ;%0Aim
@@ -451,24 +451,56 @@
 TestRunner;%0A
+import org.robolectric.Shadows;%0A
 import org.r
@@ -533,41 +533,180 @@
 ig;%0A
-%0Aimport static org.junit.Assert.*
+import org.robolectric.shadows.ShadowActivity;%0Aimport org.robolectric.shadows.ShadowToast;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.robolectric.Shadows.shadowOf
 ;%0A%0A/
@@ -1118,33 +1118,32 @@
 ows Exception %7B%0A
-%0A
     %7D%0A%0A    @Test
@@ -1332,19 +1332,25 @@
 stOn
-BackPressed
+CreateOptionsMenu
 () t
@@ -1379,168 +1379,304 @@
     
-%0A    %7D%0A%0A    @Test%0A    public void testOnCreateOptionsMenu() throws Exception %7B%0A%0A    %7D%0A%0A    @Test%0A    public void testOnOptionsItemSelected() throws Exception %7B%0A
+final Menu menu = shadowOf(mainActivity).getOptionsMenu();%0A        assertEquals(menu.findItem(R.id.searchView).getTitle(), %22Search%22);%0A    %7D%0A%0A    @Test%0A    public void testOnOptionsItemSelected() throws Exception %7B%0A        assertEquals(shadowOf(mainActivity).clickMenuItem(R.id.searchView), true);
 %0A   
@@ -1759,78 +1759,92 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void testOnViewDrag() throws Exception %7B%0A
+assertEquals(shadowOf(mainActivity).clickMenuItem(R.id.nav_allNotes), true);
 %0A   
@@ -1914,79 +1914,258 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void testOnNoteClick() throws Exception %7B%0A
+mainActivity.findViewById(R.id.textView).performClick();%0A        Intent intent = Shadows.shadowOf(mainActivity).peekNextStartedActivity();%0A        assertEquals(WriteNoteActivity.class.getCanonicalName(), intent.getComponent().getClassName());
 %0A   
@@ -2208,14 +2208,13 @@
 Note
-Delete
+Click
 () t
@@ -2235,75 +2235,258 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void testOnClick() throws Exception %7B%0A
+mainActivity.findViewById(R.id.textView).performClick();%0A        Intent intent = Shadows.shadowOf(mainActivity).peekNextStartedActivity();%0A        assertEquals(WriteNoteActivity.class.getCanonicalName(), intent.getComponent().getClassName());
 %0A   
@@ -2525,23 +2525,16 @@
 stOn
-SaveInstanceSta
+NoteDele
 te()
@@ -2557,75 +2557,174 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void testOnPause() throws Exception %7B%0A
+assertEquals(shadowOf(mainActivity).clickMenuItem(R.id.nav_allNotes), true);%0A        assertEquals(shadowOf(mainActivity).clickMenuItem(R.id.list_icon), true);
 %0A   

Update MainActivity Test