Class TestUtil

java.lang.Object
com.example.skeddly.utilities.TestUtil

public class TestUtil extends Object
Utility class for creating mock objects for instrumentation tests.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Event
    createMockEvent(String eventName, byte[] imageBytes)
    Creates a mock Event with default data and a specified name and image.
    static androidx.test.espresso.ViewInteraction
    onViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher)
    Waits for a view to load before continuing.
    static androidx.test.espresso.ViewInteraction
    onViewLoaded(org.hamcrest.Matcher<android.view.View> viewMatcher, long timeout)
    Waits for a view to load before continuing.
    static androidx.test.espresso.ViewAction
    Types text into a SearchView https://stackoverflow.com/a/48037073
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestUtil

      public TestUtil()
  • Method Details

    • createMockEvent

      public static Event createMockEvent(String eventName, byte[] imageBytes)
      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 - Matcher
      timeout - 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 - Matcher
      timeout - int
      Returns:
      ViewInteraction
    • typeSearchViewText

      public static androidx.test.espresso.ViewAction typeSearchViewText(String text)
      Types text into a SearchView https://stackoverflow.com/a/48037073
      Parameters:
      text - String
      Returns:
      ViewAction