Package com.example.skeddly.utilities
Class TestUtil
java.lang.Object
com.example.skeddly.utilities.TestUtil
Utility class for creating mock objects for instrumentation tests.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EventcreateMockEvent(String eventName, byte[] imageBytes) Creates a mock Event with default data and a specified name and image.static androidx.test.espresso.ViewInteractiononViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher) Waits for a view to load before continuing.static androidx.test.espresso.ViewInteractiononViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher, long timeout) Waits for a view to load before continuing.static androidx.test.espresso.ViewActiontypeSearchViewText(String text) Types text into a SearchView https://stackoverflow.com/a/48037073static androidx.test.espresso.ViewActionwaitForView(org.hamcrest.Matcher<android.view.View> viewMatcher, long timeout) Pauses an espresso test until a view appears Particularly useful for ListViews with lots of items/images Credit to Stephan Petzl
-
Constructor Details
-
TestUtil
public TestUtil()
-
-
Method Details
-
createMockEvent
Creates a mock Event with default data and a specified name and image.- Parameters:
eventName- The name for the mock event.imageBytes- The byte array for the event's image. Can be null.- Returns:
- A new Event object.
-
waitForView
public static androidx.test.espresso.ViewAction waitForView(org.hamcrest.Matcher<android.view.View> viewMatcher, long timeout) Pauses an espresso test until a view appears Particularly useful for ListViews with lots of items/images Credit to Stephan Petzl- Parameters:
viewMatcher- Matchertimeout- long- Returns:
- ViewAction
-
onViewLoaded
public static androidx.test.espresso.ViewInteraction onViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher) Waits for a view to load before continuing. DO NOT use.check(matches(isDisplayed()))with this method as this is already assumed when view is loaded. Timeout is 10000 ms by default.- Parameters:
viewMatcher- Matcher- Returns:
- ViewInteraction
-
onViewLoaded
public static androidx.test.espresso.ViewInteraction onViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher, long timeout) Waits for a view to load before continuing. DO NOT use.check(matches(isDisplayed()))with this method as this is already assumed when view is loaded. If the time it takes to load exceeds the timeout, it will fail.- Parameters:
viewMatcher- Matchertimeout- int- Returns:
- ViewInteraction
-
typeSearchViewText
Types text into a SearchView https://stackoverflow.com/a/48037073- Parameters:
text- String- Returns:
- ViewAction
-