package org.redcross.openmapkit;

import android.support.test.espresso.Espresso;
import android.support.test.espresso.action.ViewActions;
import android.support.test.espresso.assertion.PositionAssertions;
import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import android.view.View;

import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Created by Jason Rogena|Mark Ekisa on 7/22/16.
 */
@RunWith(AndroidJUnit4.class)
public class MapActivityTest {
    private static final String TAG = "OMK.MapActivityTest";
    private static final long INITIAL_SLEEP_TIME = 5000l;

    @Before
    public void waitForSomeTime() {
        Log.d(TAG, "Sleeping for 5 seconds before running tests");
        try {
            Log.d(TAG, "Running tests");
            Thread.sleep(INITIAL_SLEEP_TIME);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Rule
    public ActivityTestRule<MapActivity> mActivityRule = new ActivityTestRule<>(MapActivity.class);

    /**
     * This method tests the position of the 'locate-me' button in the activity
     */
    @Test
    public void locationButtonPosition() {
        //check initial position
        Espresso.onView(ViewMatchers.withId(R.id.locationButton))
                .check(PositionAssertions
                        .isAbove(ViewMatchers.withId(R.id.nodeModeButton)));
        Espresso.onView(ViewMatchers.withId(R.id.locationButton))
                .check(PositionAssertions
                        .isRightAlignedWith(ViewMatchers.withId(R.id.nodeModeButton)));
    }
}

@@ -1155,16 +1155,92 @@
 %0A    %7D%0A%0A
+    private static final String ROUNDED_BUTTON_LABEL = %22+  Add Structure%22;%0A%0A
     @Rul
@@ -1910,11 +1910,393 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void roundedButtonLabel() %7B%0A        //show the add structure marker by clicking the '+' button%0A        Espresso.onView(ViewMatchers.withId(R.id.nodeModeButton)).perform(ViewActions.click());%0A%0A        //perform check%0A        Espresso.onView(ViewMatchers.withId(R.id.addNodeBtn)).check(ViewAssertions.matches(ViewMatchers.withText(ROUNDED_BUTTON_LABEL)));%0A    %7D
 %0A%7D%0A

Add Espresso Tests for Issue #26