GlanceNodeAssertionCollection


class GlanceNodeAssertionCollection<R : Any?, T : GlanceNode<R>>


Represents a collection of Glance nodes from the tree that can be asserted on.

An instance of GlanceNodeAssertionCollection can be obtained from GlanceNodeAssertionsProvider.onAllNodes and equivalent methods.

Summary

Public functions

GlanceNodeAssertionCollection<R, T>

Asserts that all the nodes in this collection satisfy the given matcher.

GlanceNodeAssertionCollection<R, T>

Asserts that this collection contains at least one element that satisfies the given matcher.

GlanceNodeAssertionCollection<R, T>
assertCountEquals(expectedCount: Int)

Asserts that this collection of nodes is equal to the given expectedCount.

GlanceNodeAssertionCollection<R, T>

Returns a new collection of nodes by filtering the given nodes using the provided matcher.

operator GlanceNodeAssertion<R, T>
get(index: Int)

Returns a GlanceNodeAssertion that can assert on the node at the given index of this collection.

Public functions

assertAll

Added in 1.1.0-beta02
fun assertAll(matcher: GlanceNodeMatcher<R>): GlanceNodeAssertionCollection<R, T>

Asserts that all the nodes in this collection satisfy the given matcher.

Doesn't throw error if the collection is empty. Use assertCountEquals to assert on expected size of the collection.

Parameters
matcher: GlanceNodeMatcher<R>

Matcher that has to be satisfied by all the nodes in the collection.

Throws
kotlin.AssertionError

if the collection contains at least one element that does not satisfy the given matcher.

assertAny

Added in 1.1.0-beta02
fun assertAny(matcher: GlanceNodeMatcher<R>): GlanceNodeAssertionCollection<R, T>

Asserts that this collection contains at least one element that satisfies the given matcher.

Parameters
matcher: GlanceNodeMatcher<R>

Matcher that has to be satisfied by at least one of the nodes in the collection.

Throws
kotlin.AssertionError

if not at least one matching node was found.

assertCountEquals

Added in 1.1.0-beta02
fun assertCountEquals(expectedCount: Int): GlanceNodeAssertionCollection<R, T>

Asserts that this collection of nodes is equal to the given expectedCount.

Throws
kotlin.AssertionError

if the size is not equal to expectedCount

filter

Added in 1.1.0-beta02
fun filter(matcher: GlanceNodeMatcher<R>): GlanceNodeAssertionCollection<R, T>

Returns a new collection of nodes by filtering the given nodes using the provided matcher.

get

Added in 1.1.0-beta02
operator fun get(index: Int): GlanceNodeAssertion<R, T>

Returns a GlanceNodeAssertion that can assert on the node at the given index of this collection.

Any subsequent assertion on its result will throw error if index is out of bounds of the matching nodes found from previous operations.