Methods Summary |
---|
public static void | assertBaselineAligned(android.view.View first, android.view.View second)Assert that two views are aligned on their baseline, that is that their baselines
are on the same y location.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstTop = xy[1] + first.getBaseline();
second.getLocationOnScreen(xy);
int secondTop = xy[1] + second.getBaseline();
assertEquals("views are not baseline aligned", firstTop, secondTop);
|
public static void | assertBottomAligned(android.view.View first, android.view.View second)Assert that two views are bottom aligned, that is that their bottom edges
are on the same y location.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstBottom = xy[1] + first.getMeasuredHeight();
second.getLocationOnScreen(xy);
int secondBottom = xy[1] + second.getMeasuredHeight();
assertEquals("views are not bottom aligned", firstBottom, secondBottom);
|
public static void | assertBottomAligned(android.view.View first, android.view.View second, int margin)Assert that two views are bottom aligned, that is that their bottom edges
are on the same y location, with respect to the specified margin.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstBottom = xy[1] + first.getMeasuredHeight();
second.getLocationOnScreen(xy);
int secondBottom = xy[1] + second.getMeasuredHeight();
assertEquals("views are not bottom aligned", Math.abs(firstBottom - secondBottom), margin);
|
public static void | assertGroupContains(android.view.ViewGroup parent, android.view.View child)Assert that the specified group contains a specific child once and only once.
final int count = parent.getChildCount();
assertTrue("Child count should be >= 0", count >= 0);
boolean found = false;
for (int i = 0; i < count; i++) {
if (parent.getChildAt(i) == child) {
if (!found) {
found = true;
} else {
assertTrue("child " + child + " is duplicated in parent", false);
}
}
}
assertTrue("group does not contain " + child, found);
|
public static void | assertGroupIntegrity(android.view.ViewGroup parent)Assert the specified group's integrity. The children count should be >= 0 and each
child should be non-null.
final int count = parent.getChildCount();
assertTrue("child count should be >= 0", count >= 0);
for (int i = 0; i < count; i++) {
assertNotNull("group should not contain null children", parent.getChildAt(i));
assertSame(parent, parent.getChildAt(i).getParent());
}
|
public static void | assertGroupNotContains(android.view.ViewGroup parent, android.view.View child)Assert that the specified group does not contain a specific child.
final int count = parent.getChildCount();
assertTrue("Child count should be >= 0", count >= 0);
for (int i = 0; i < count; i++) {
if (parent.getChildAt(i) == child) {
assertTrue("child " + child + " is found in parent", false);
}
}
|
public static void | assertHasScreenCoordinates(android.view.View origin, android.view.View view, int x, int y)Assert that a view has a particular x and y position on the visible screen.
int[] xy = new int[2];
view.getLocationOnScreen(xy);
int[] xyRoot = new int[2];
origin.getLocationOnScreen(xyRoot);
assertEquals("x coordinate", x, xy[0] - xyRoot[0]);
assertEquals("y coordinate", y, xy[1] - xyRoot[1]);
|
public static void | assertHorizontalCenterAligned(android.view.View reference, android.view.View test)Assert that the test view is horizontally center aligned
with respect to the reference view.
int[] xy = new int[2];
reference.getLocationOnScreen(xy);
int referenceLeft = xy[0];
test.getLocationOnScreen(xy);
int testLeft = xy[0];
int center = (reference.getMeasuredWidth() - test.getMeasuredWidth()) / 2;
int delta = testLeft - referenceLeft;
assertEquals("views are not horizontally center aligned", center, delta);
|
public static void | assertLeftAligned(android.view.View first, android.view.View second, int margin)Assert that two views are left aligned, that is that their left edges
are on the same x location, with respect to the specified margin.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstLeft = xy[0];
second.getLocationOnScreen(xy);
int secondLeft = xy[0];
assertEquals("views are not left aligned", Math.abs(firstLeft - secondLeft), margin);
|
public static void | assertLeftAligned(android.view.View first, android.view.View second)Assert that two views are left aligned, that is that their left edges
are on the same x location.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstLeft = xy[0];
second.getLocationOnScreen(xy);
int secondLeft = xy[0];
assertEquals("views are not left aligned", firstLeft, secondLeft);
|
public static void | assertOffScreenAbove(android.view.View origin, android.view.View view)Assert that view is above the visible screen.
int[] xy = new int[2];
view.getLocationOnScreen(xy);
int[] xyRoot = new int[2];
origin.getLocationOnScreen(xyRoot);
int y = xy[1] - xyRoot[1];
assertTrue("view should have y location less than that of origin view",
y < 0);
|
public static void | assertOffScreenBelow(android.view.View origin, android.view.View view)Assert that view is below the visible screen.
int[] xy = new int[2];
view.getLocationOnScreen(xy);
int[] xyRoot = new int[2];
origin.getLocationOnScreen(xyRoot);
int y = xy[1] - xyRoot[1];
assertTrue("view should have y location on screen greater than drawing "
+ "height of origen view (" + y + " is not greater than "
+ origin.getHeight() + ")",
y > origin.getHeight());
|
public static void | assertOnScreen(android.view.View origin, android.view.View view)Assert that view is on the screen.
int[] xy = new int[2];
view.getLocationOnScreen(xy);
int[] xyRoot = new int[2];
origin.getLocationOnScreen(xyRoot);
int y = xy[1] - xyRoot[1];
assertTrue("view should have positive y coordinate on screen",
y >= 0);
assertTrue("view should have y location on screen less than drawing "
+ "height of root view",
y <= view.getRootView().getHeight());
|
public static void | assertRightAligned(android.view.View first, android.view.View second)Assert that two views are right aligned, that is that their right edges
are on the same x location.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstRight = xy[0] + first.getMeasuredWidth();
second.getLocationOnScreen(xy);
int secondRight = xy[0] + second.getMeasuredWidth();
assertEquals("views are not right aligned", firstRight, secondRight);
|
public static void | assertRightAligned(android.view.View first, android.view.View second, int margin)Assert that two views are right aligned, that is that their right edges
are on the same x location, with respect to the specified margin.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstRight = xy[0] + first.getMeasuredWidth();
second.getLocationOnScreen(xy);
int secondRight = xy[0] + second.getMeasuredWidth();
assertEquals("views are not right aligned", Math.abs(firstRight - secondRight), margin);
|
public static void | assertTopAligned(android.view.View first, android.view.View second)Assert that two views are top aligned, that is that their top edges
are on the same y location.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstTop = xy[1];
second.getLocationOnScreen(xy);
int secondTop = xy[1];
assertEquals("views are not top aligned", firstTop, secondTop);
|
public static void | assertTopAligned(android.view.View first, android.view.View second, int margin)Assert that two views are top aligned, that is that their top edges
are on the same y location, with respect to the specified margin.
int[] xy = new int[2];
first.getLocationOnScreen(xy);
int firstTop = xy[1];
second.getLocationOnScreen(xy);
int secondTop = xy[1];
assertEquals("views are not top aligned", Math.abs(firstTop - secondTop), margin);
|
public static void | assertVerticalCenterAligned(android.view.View reference, android.view.View test)Assert that the test view is vertically center aligned
with respect to the reference view.
int[] xy = new int[2];
reference.getLocationOnScreen(xy);
int referenceTop = xy[1];
test.getLocationOnScreen(xy);
int testTop = xy[1];
int center = (reference.getMeasuredHeight() - test.getMeasuredHeight()) / 2;
int delta = testTop - referenceTop;
assertEquals("views are not vertically center aligned", center, delta);
|