package com.anysoftkeyboard;

import android.app.AlertDialog;
import android.view.View;

import com.anysoftkeyboard.api.KeyCodes;
import com.anysoftkeyboard.keyboards.views.AnyKeyboardView;
import com.anysoftkeyboard.keyboards.views.KeyboardViewContainerView;
import com.menny.android.anysoftkeyboard.R;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.shadows.ShadowAlertDialog;

@RunWith(AnySoftKeyboardTestRunner.class)
public class AnySoftKeyboardViewRelatedTest extends AnySoftKeyboardBaseTest {

    @Test
    public void testOnCreateInputView() throws Exception {
        View mainKeyboardView = mAnySoftKeyboardUnderTest.getInputViewContainer();
        Assert.assertNotNull(mainKeyboardView);
        Assert.assertTrue(mainKeyboardView instanceof KeyboardViewContainerView);
        KeyboardViewContainerView containerView = (KeyboardViewContainerView) mainKeyboardView;
        Assert.assertEquals(1, containerView.getChildCount());
        final View inputView = containerView.getChildAt(0);
        Assert.assertNotNull(inputView);
        Assert.assertTrue(inputView instanceof AnyKeyboardView);
        Assert.assertSame(inputView, containerView.getStandardKeyboardView());
        Mockito.verify(containerView.getStandardKeyboardView()).setWatermark("α\uD83D\uDD25");
    }

    @Test
    public void testSettingsBasic() throws Exception {
        Assert.assertNull(ShadowAlertDialog.getLatestAlertDialog());
        mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.SETTINGS);
        final AlertDialog latestAlertDialog = ShadowAlertDialog.getLatestAlertDialog();
        Assert.assertNotNull(latestAlertDialog);

        final ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(latestAlertDialog);
        Assert.assertEquals("AnySoftKeyboard", shadowAlertDialog.getTitle());
        Assert.assertEquals(4, shadowAlertDialog.getItems().length);

    }

    @Test
    public void testSettingsIncognito() throws Exception {
        Assert.assertNull(ShadowAlertDialog.getLatestAlertDialog());
        mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.SETTINGS);
        final AlertDialog latestAlertDialog = ShadowAlertDialog.getLatestAlertDialog();
        final ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(latestAlertDialog);

        Assert.assertEquals(RuntimeEnvironment.application.getText(R.string.switch_incognito), shadowAlertDialog.getItems()[3]);

        Assert.assertFalse(mAnySoftKeyboardUnderTest.getSpiedSuggest().isIncognitoMode());

        shadowAlertDialog.clickOnItem(3);

        Assert.assertTrue(mAnySoftKeyboardUnderTest.getSpiedSuggest().isIncognitoMode());
        Mockito.verify(mAnySoftKeyboardUnderTest.getInputView()).setWatermark("α\uD83D\uDD25\uD83D\uDD75");
    }
}
@@ -256,52 +256,8 @@
 iew;
-%0Aimport com.menny.android.anysoftkeyboard.R;
 %0A%0Aim
@@ -367,51 +367,8 @@
 to;%0A
-import org.robolectric.RuntimeEnvironment;%0A
 impo
@@ -2361,73 +2361,38 @@
 als(
-RuntimeEnvironment.application.getText(R.string.switch_incognito)
+%22%5CuD83D%5CuDD75%EF%B8%8F Incognito Mode%22
 , sh

Fix settings menu text unit-test