Android Open Source - android-marvin Is On Screen






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.matchers;
//from  ww  w.  j  ava 2 s  . c  o  m
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;

import android.view.View;


public class IsOnScreen<T extends View> extends BaseMatcher<T> {
    private final T rootView;

    public IsOnScreen(T rootView) {
        this.rootView = rootView;
    }

    public boolean matches(Object arg) {
        if (!(arg instanceof View)) {
            throw new IllegalArgumentException("not a view");
        }

        View view = (View) arg;

        // The following code is part of the Android SDK,
        // android/test/ViewAsserts.java (Apache License 2.0)

        int[] xy = new int[2];
        view.getLocationOnScreen(xy);

        int[] xyRoot = new int[2];
        rootView.getLocationOnScreen(xyRoot);

        int y = xy[1] - xyRoot[1];

        return y >= 0 && y <= view.getRootView().getHeight();
    }

    public void describeTo(Description description) {
        description.appendText("isOnScreen(")
                .appendValue(rootView)
                .appendText(")");
    }

    @Factory
    public static <T extends View> Matcher<T> isOnScreen(T rootView) {
        return new IsOnScreen<T>(rootView);
    }
}




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