// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
//     return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
// 
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
//     return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }


import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
    }

    public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
        openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());

        // The MenuItem id and the View id is not the same. It is needed to use another matcher.
        onView(withText(expectedTitle)).check(matches(isDisplayed()));

        return this;
    }

    public SampleScreen verifyLayoutDirectionRTL() {
        onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));

        return this;
    }

    public SampleScreen verifyLayoutDirectionLTR() {
        onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));

        return this;
    }

    public SampleScreen changeOrientationToLandscape() {
        onView(isRoot()).perform(orientationLandscape());
        SystemClock.sleep(500);
        return this;
    }

    public SampleScreen changeOrientationToPortrait() {
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
//     return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
// 
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
//     return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }


// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;

    }

    public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
        openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());

        // The MenuItem id and the View id is not the same. It is needed to use another matcher.
        onView(withText(expectedTitle)).check(matches(isDisplayed()));

        return this;
    }

    public SampleScreen verifyLayoutDirectionRTL() {
        onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));

        return this;
    }

    public SampleScreen verifyLayoutDirectionLTR() {
        onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));

        return this;
    }

    public SampleScreen changeOrientationToLandscape() {
        onView(isRoot()).perform(orientationLandscape());
        SystemClock.sleep(500);
        return this;
    }

    public SampleScreen changeOrientationToPortrait() {
        onView(isRoot()).perform(orientationPortrait());