Android Open Source - android-marvin Activity Action






From Project

Back to project page android-marvin.

License

The source code is released under:

Apache License

If you think the Android project android-marvin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.akquinet.android.marvin.actions;
//from w  w w .j  a va 2  s . c  o m
import android.app.Activity;
import android.app.Instrumentation;
import android.content.pm.ActivityInfo;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import de.akquinet.android.marvin.monitor.ExtendedActivityMonitor;


public interface ActivityAction
{
    Activity get();
    
    FindViewAction view();

    /**
     * Flips orientation of this activity from portrait to landscape and vice
     * versa.
     */
    void flipOrientation();

    /**
     * <p>
     * Set the orientation of this activity to the given value.
     * 
     * <p>
     * Example:
     * <code>setOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)</code>
     * 
     * @param orientation
     *            An orientation constant as used in
     *            {@link ActivityInfo#screenOrientation}.
     * 
     * @see ActivityInfo
     */
    void setOrientation(int orientation);

    /**
     * Destroy this activity by calling {@link Activity#finish()} on it.
     */
    void finish();
}


class ActivityActionImpl<T extends Activity> extends BaseActionImpl implements ActivityAction
{
    protected final T activity;

    public ActivityActionImpl(Instrumentation instrumentation,
            ExtendedActivityMonitor activityMonitor, T activity) {
        super(instrumentation, activityMonitor);

        this.activity = activity;
    }

    public Activity get() {
        return activity;
    }

    public void flipOrientation() {
        actionPerformed();
        int currentOrientation = get().getRequestedOrientation();
        if (currentOrientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            get().setRequestedOrientation(
                    ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
        else {
            get().setRequestedOrientation(
                    ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    public void setOrientation(int orientation) {
        actionPerformed();
        get().setRequestedOrientation(orientation);
    }

    public void finish() {
        actionPerformed();
        get().finish();
    }

    public FindViewAction view() {
        return ActionFactory.createFindViewAction(instrumentation, activityMonitor, activity);
    }

}




Java Source Code List

de.akquinet.android.marvin.ActivityTestCase.java
de.akquinet.android.marvin.AndroidMatchers.java
de.akquinet.android.marvin.AndroidTestCase.java
de.akquinet.android.marvin.ServiceTestCase.java
de.akquinet.android.marvin.actions.ActionFactory.java
de.akquinet.android.marvin.actions.ActivityAction.java
de.akquinet.android.marvin.actions.AwaitAction.java
de.akquinet.android.marvin.actions.BaseAction.java
de.akquinet.android.marvin.actions.FindViewAction.java
de.akquinet.android.marvin.actions.PerformAction.java
de.akquinet.android.marvin.actions.ViewAction.java
de.akquinet.android.marvin.actions.ViewFilter.java
de.akquinet.android.marvin.matchers.Condition.java
de.akquinet.android.marvin.matchers.HasText.java
de.akquinet.android.marvin.matchers.IsEnabled.java
de.akquinet.android.marvin.matchers.IsOnScreen.java
de.akquinet.android.marvin.matchers.IsVisible.java
de.akquinet.android.marvin.matchers.ViewGroupComparison.java
de.akquinet.android.marvin.matchers.util.WaitForConditionUtil.java
de.akquinet.android.marvin.monitor.ExtendedActivityMonitor.java
de.akquinet.android.marvin.monitor.StartedActivity.java
de.akquinet.android.marvin.util.MarvinConnectivityUtil.java
de.akquinet.android.marvin.util.TemporaryServiceConnection.java