Created
March 16, 2018 15:22
-
-
Save mrenouf/45d71d42faf8e5065e7769d42251556a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.mrenouf.touchtest; | |
import android.support.test.rule.ActivityTestRule; | |
import android.support.test.runner.AndroidJUnit4; | |
import android.view.View; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import static com.example.mrenouf.touchtest.ViewGroups.isVisiblePointWithinView; | |
import static org.junit.Assert.assertFalse; | |
import static org.junit.Assert.assertTrue; | |
@RunWith(AndroidJUnit4.class) | |
public class ViewGroupsTest { | |
@Rule | |
public ActivityTestRule<ViewGroupsTestActivity> activityTestRule = | |
new ActivityTestRule<>(ViewGroupsTestActivity.class); | |
@Test | |
public void testIsVisiblePointWithinView_visible() throws Exception { | |
ViewGroupsTestActivity activity = activityTestRule.getActivity(); | |
View contentInner = activity.findViewById(R.id.content_inner); | |
// check point within top half of the scrollview (not covered by panel) | |
int targetX = contentInner.getWidth() / 2; | |
int targetY = contentInner.getHeight () / 4; | |
assertTrue(isVisiblePointWithinView(contentInner, targetX, targetY)); | |
} | |
@Test | |
public void testIsVisiblePointWithinView_covered() throws Exception { | |
ViewGroupsTestActivity activity = activityTestRule.getActivity(); | |
View contentInner = activity.findViewById(R.id.content_inner); | |
// check point within bottom half of the scrollview (covered by panel) | |
int targetX = contentInner.getWidth() / 2; | |
int targetY = (contentInner.getHeight () / 2) + (contentInner.getHeight () / 4); | |
assertFalse(isVisiblePointWithinView(contentInner, targetX, targetY)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment