Android Open Source - android-marvin Base 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 ww  .  ja  v  a 2s .  c  o m
import junit.framework.Assert;
import android.app.Instrumentation;
import android.os.SystemClock;
import android.view.MotionEvent;
import de.akquinet.android.marvin.monitor.ExtendedActivityMonitor;


public interface BaseAction
{
}


class BaseActionImpl implements BaseAction
{
    private final long startTimestamp;
    private long lastOperationTimestamp = 0;

    protected final Instrumentation instrumentation;
    protected final ExtendedActivityMonitor activityMonitor;

    public BaseActionImpl(Instrumentation instrumentation, ExtendedActivityMonitor activityMonitor) {
        this.startTimestamp = System.currentTimeMillis();
        this.instrumentation = instrumentation;
        this.activityMonitor = activityMonitor;
    }

    public long getStartTimestamp() {
        return startTimestamp;
    }

    public long getLastOperationTimestamp() {
        return lastOperationTimestamp;
    }

    public void actionPerformed() {
        this.lastOperationTimestamp = System.currentTimeMillis();
    }

    public void click(float x, float y) {
        MotionEvent downEvent = MotionEvent.obtain(SystemClock.uptimeMillis(),
                SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, 0);
        MotionEvent upEvent = MotionEvent.obtain(SystemClock.uptimeMillis(),
                SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0);
        try {
            instrumentation.sendPointerSync(downEvent);
            instrumentation.sendPointerSync(upEvent);
        }
        catch (SecurityException e) {
            Assert.fail("Click on (" + x + "," + y + ") failed.");
        }
    }
}




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