Added in API level 1
Deprecated in API level 24

ViewAsserts


open class ViewAsserts
kotlin.Any
   ↳ android.test.ViewAsserts

Some useful assertions about views.

Summary

Public methods
open static Unit
assertBaselineAligned(first: View!, second: View!)

Assert that two views are aligned on their baseline, that is that their baselines are on the same y location.

open static Unit
assertBottomAligned(first: View!, second: View!)

Assert that two views are bottom aligned, that is that their bottom edges are on the same y location.

open static Unit
assertBottomAligned(first: View!, second: View!, margin: Int)

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.

open static Unit
assertGroupContains(parent: ViewGroup!, child: View!)

Assert that the specified group contains a specific child once and only once.

open static Unit

Assert the specified group's integrity.

open static Unit

Assert that the specified group does not contain a specific child.

open static Unit
assertHasScreenCoordinates(origin: View!, view: View!, x: Int, y: Int)

Assert that a view has a particular x and y position on the visible screen.

open static Unit
assertHorizontalCenterAligned(reference: View!, test: View!)

Assert that the test view is horizontally center aligned with respect to the reference view.

open static Unit
assertLeftAligned(first: View!, second: View!)

Assert that two views are left aligned, that is that their left edges are on the same x location.

open static Unit
assertLeftAligned(first: View!, second: View!, margin: Int)

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.

open static Unit
assertOffScreenAbove(origin: View!, view: View!)

Assert that view is above the visible screen.

open static Unit
assertOffScreenBelow(origin: View!, view: View!)

Assert that view is below the visible screen.

open static Unit
assertOnScreen(origin: View!, view: View!)

Assert that view is on the screen.

open static Unit
assertRightAligned(first: View!, second: View!)

Assert that two views are right aligned, that is that their right edges are on the same x location.

open static Unit
assertRightAligned(first: View!, second: View!, margin: Int)

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.

open static Unit
assertTopAligned(first: View!, second: View!)

Assert that two views are top aligned, that is that their top edges are on the same y location.

open static Unit
assertTopAligned(first: View!, second: View!, margin: Int)

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.

open static Unit
assertVerticalCenterAligned(reference: View!, test: View!)

Assert that the test view is vertically center aligned with respect to the reference view.

Public methods

assertBaselineAligned

Added in API level 1
open static fun assertBaselineAligned(
    first: View!,
    second: View!
): Unit

Deprecated: Deprecated in Java.

Assert that two views are aligned on their baseline, that is that their baselines are on the same y location.

Parameters
first View!: The first view
second View!: The second view

assertBottomAligned

Added in API level 1
open static fun assertBottomAligned(
    first: View!,
    second: View!
): Unit

Deprecated: Deprecated in Java.

Assert that two views are bottom aligned, that is that their bottom edges are on the same y location.

Parameters
first View!: The first view
second View!: The second view

assertBottomAligned

Added in API level 1
open static fun assertBottomAligned(
    first: View!,
    second: View!,
    margin: Int
): Unit

Deprecated: Deprecated in Java.

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.

Parameters
first View!: The first view
second View!: The second view
margin Int: The margin between the first view and the second view

assertGroupContains

Added in API level 1
open static fun assertGroupContains(
    parent: ViewGroup!,
    child: View!
): Unit

Deprecated: Deprecated in Java.

Assert that the specified group contains a specific child once and only once.

Parameters
parent ViewGroup!: The group
child View!: The child that should belong to group

assertGroupIntegrity

Added in API level 1
open static fun assertGroupIntegrity(parent: ViewGroup!): Unit

Deprecated: Deprecated in Java.

Assert the specified group's integrity. The children count should be >= 0 and each child should be non-null.

Parameters
parent ViewGroup!: The group whose integrity to check

assertGroupNotContains

Added in API level 1
open static fun assertGroupNotContains(
    parent: ViewGroup!,
    child: View!
): Unit

Deprecated: Deprecated in Java.

Assert that the specified group does not contain a specific child.

Parameters
parent ViewGroup!: The group
child View!: The child that should not belong to group

assertHasScreenCoordinates

Added in API level 1
open static fun assertHasScreenCoordinates(
    origin: View!,
    view: View!,
    x: Int,
    y: Int
): Unit

Deprecated: Deprecated in Java.

Assert that a view has a particular x and y position on the visible screen.

Parameters
origin View!: The root view of the screen.
view View!: The view.
x Int: The expected x coordinate.
y Int: The expected y coordinate.

assertHorizontalCenterAligned

Added in API level 1
open static fun assertHorizontalCenterAligned(
    reference: View!,
    test: View!
): Unit

Deprecated: Deprecated in Java.

Assert that the test view is horizontally center aligned with respect to the reference view.

Parameters
reference View!: The reference view
test View!: The view that should be center aligned with the reference view

assertLeftAligned

Added in API level 1
open static fun assertLeftAligned(
    first: View!,
    second: View!
): Unit

Deprecated: Deprecated in Java.

Assert that two views are left aligned, that is that their left edges are on the same x location.

Parameters
first View!: The first view
second View!: The second view

assertLeftAligned

Added in API level 1
open static fun assertLeftAligned(
    first: View!,
    second: View!,
    margin: Int
): Unit

Deprecated: Deprecated in Java.

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.

Parameters
first View!: The first view
second View!: The second view
margin Int: The margin between the first view and the second view

assertOffScreenAbove

Added in API level 1
open static fun assertOffScreenAbove(
    origin: View!,
    view: View!
): Unit

Deprecated: Deprecated in Java.

Assert that view is above the visible screen.

Parameters
origin View!: Te root view of the screen.
view View!: The view

assertOffScreenBelow

Added in API level 1
open static fun assertOffScreenBelow(
    origin: View!,
    view: View!
): Unit

Deprecated: Deprecated in Java.

Assert that view is below the visible screen.

Parameters
origin View!: The root view of the screen.
view View!: The view

assertOnScreen

Added in API level 1
open static fun assertOnScreen(
    origin: View!,
    view: View!
): Unit

Deprecated: Deprecated in Java.

Assert that view is on the screen.

Parameters
origin View!: The root view of the screen.
view View!: The view.

assertRightAligned

Added in API level 1
open static fun assertRightAligned(
    first: View!,
    second: View!
): Unit

Deprecated: Deprecated in Java.

Assert that two views are right aligned, that is that their right edges are on the same x location.

Parameters
first View!: The first view
second View!: The second view

assertRightAligned

Added in API level 1
open static fun assertRightAligned(
    first: View!,
    second: View!,
    margin: Int
): Unit

Deprecated: Deprecated in Java.

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.

Parameters
first View!: The first view
second View!: The second view
margin Int: The margin between the first view and the second view

assertTopAligned

Added in API level 1
open static fun assertTopAligned(
    first: View!,
    second: View!
): Unit

Deprecated: Deprecated in Java.

Assert that two views are top aligned, that is that their top edges are on the same y location.

Parameters
first View!: The first view
second View!: The second view

assertTopAligned

Added in API level 1
open static fun assertTopAligned(
    first: View!,
    second: View!,
    margin: Int
): Unit

Deprecated: Deprecated in Java.

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.

Parameters
first View!: The first view
second View!: The second view
margin Int: The margin between the first view and the second view

assertVerticalCenterAligned

Added in API level 1
open static fun assertVerticalCenterAligned(
    reference: View!,
    test: View!
): Unit

Deprecated: Deprecated in Java.

Assert that the test view is vertically center aligned with respect to the reference view.

Parameters
reference View!: The reference view
test View!: The view that should be center aligned with the reference view