package cc.softwarefactory.lokki.android.espresso;

import cc.softwarefactory.lokki.android.R;
import cc.softwarefactory.lokki.android.espresso.utilities.TestUtils;

import static android.support.test.espresso.Espresso.onData;
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.matcher.ViewMatchers.hasDescendant;
import static android.support.test.espresso.matcher.ViewMatchers.hasSibling;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;


public class SettingsScreenTest extends LoggedInBaseTest {
    @Override
    public void setUp() throws Exception {
        super.setUp();
    }

    private void enterSettingScreen() {
        getActivity();
        onView(withId(R.id.decor_content_parent)).perform(TestUtils.clickScreenPosition(0, 0));
        onView(withText("Settings")).perform(click());
    }
    
    
    // TEST
    
    public void testSettingsScreenShown() {
        enterSettingScreen();
        onView(withId(R.id.visibility)).check(matches(isDisplayed()));
        onView(withId(R.id.map_type)).check(matches(isDisplayed()));
    }
    
    public void testUserNameShown() {
        enterSettingScreen();
        onView(withId(R.id.user_name)).check(matches(isDisplayed()));
    }

    public void testVisibilitySpinnerDefaultYes() {
        enterSettingScreen();

        onView(allOf(withText("Yes"), withParent(withId(R.id.spinner_visibility)))).check(matches(isDisplayed()));
    }
    
    public void testVisibilitySpinnerSelectNo() {
        enterSettingScreen();
        onView(withId(R.id.spinner_visibility)).perform(click());
        onData(allOf(is(instanceOf(String.class)), is("No"))).perform(click());
        
        onView(allOf(withText("No"), withParent(withId(R.id.spinner_visibility)))).check(matches(isDisplayed()));
    }

    public void testMapTypeSpinnerDefault() {
        enterSettingScreen();

        onView(allOf(withText("Default"), withParent(withId(R.id.spinner_map)))).check(matches(isDisplayed()));
    }

    public void testMapTypeSpinnerSelectSatellite() {
        enterSettingScreen();
        onView(withId(R.id.spinner_map)).perform(click());
        onData(allOf(is(instanceOf(String.class)), is("Satellite"))).perform(click());

        onView(allOf(withText("Satellite"), withParent(withId(R.id.spinner_map)))).check(matches(isDisplayed()));
    }

    public void testMapTypeSpinnerSelectHybrid() {
        enterSettingScreen();
        onView(withId(R.id.spinner_map)).perform(click());
        onData(allOf(is(instanceOf(String.class)), is("Hybrid"))).perform(click());

        onView(allOf(withText("Hybrid"), withParent(withId(R.id.spinner_map)))).check(matches(isDisplayed()));
    }
}

@@ -433,165 +433,8 @@
 es;%0A
-import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;%0Aimport static android.support.test.espresso.matcher.ViewMatchers.hasSibling;%0A
 impo
@@ -1198,18 +1198,25 @@
 ext(
-%22S
+R.string.s
 ettings
-%22
 )).p
@@ -1752,13 +1752,20 @@
 ext(
-%22Y
+R.string.y
 es
-%22
 ), w
@@ -2051,20 +2051,53 @@
 s)), is(
-%22No%22
+getResources().getString(R.string.no)
 ))).perf
@@ -2153,12 +2153,19 @@
 ext(
-%22No%22
+R.string.no
 ), w
@@ -2358,17 +2358,33 @@
 ext(
-%22D
+R.string.map_mode_d
 efault
-%22
 ), w
@@ -2656,26 +2656,68 @@
 s)), is(
-%22S
+getResources().getString(R.string.map_mode_s
 atellite
 %22))).per
@@ -2708,17 +2708,17 @@
 atellite
-%22
+)
 ))).perf
@@ -2766,18 +2766,35 @@
 ext(
-%22S
+R.string.map_mode_s
 atellite
 %22), 
@@ -2789,17 +2789,16 @@
 atellite
-%22
 ), withP
@@ -3063,24 +3063,66 @@
 s)), is(
-%22H
+getResources().getString(R.string.map_mode_h
 ybrid
-%22
+)
 ))).perf
@@ -3170,16 +3170,32 @@
 ext(
-%22H
+R.string.map_mode_h
 ybrid
-%22
 ), w

Fix hard coded text