Google is committed to advancing racial equity for Black communities. See how.

SearchTemplateController

public class SearchTemplateController
extends Object

java.lang.Object
   ↳ com.google.android.libraries.car.app.testing.model.SearchTemplateController


A controller that allows testing of a SearchTemplate.

This controller allows:

Summary

Public methods

SearchTemplate get()

Retrieves the PlaceListMapTemplate that this controller is controlling.

ActionStripController getActionStrip()

Returns an ActionStripController that contains the ActionStrip in the SearchTemplate that is being controlled, or null if one is not present.

ActionController getHeaderAction()

Retrieves a ActionController for the header Action that is being controlled, or null if none is present.

String getInitialSearchText()

Returns the initial search text for the SearchTemplate being controlled, or null if one is not present.

ItemListController getItemList()

Returns an ItemListController that contains the ItemList in the SearchTemplate that is being controlled, or null if one is not present.

RowController getRowByTitle(String title)

Returns a RowController containing the first Row that was added with the given title as its title, in the ItemList contained in the SearchTemplate that is being controlled, or null if none match.

String getSearchHint()

Returns the search hint for the SearchTemplate being controlled, or null if one is not present.

boolean isLoading()

Returns true if the template is set to be loading.

static SearchTemplateController of(SearchTemplate searchTemplate)

Creates a SearchTemplateController to control an SearchTemplate for testing.

void performSearchSubmitted(String searchText)

Sends the search text as if the user submitted it.

void performSearchTextChanged(String searchText)

Sends the search text as if the user entered it.

boolean showKeyboardByDefault()

Verifies whether the keyboard is set to open by default.

Inherited methods

Public methods

get

public SearchTemplate get ()

Retrieves the PlaceListMapTemplate that this controller is controlling.

Returns
SearchTemplate

getActionStrip

public ActionStripController getActionStrip ()

Returns an ActionStripController that contains the ActionStrip in the SearchTemplate that is being controlled, or null if one is not present.

Returns
ActionStripController

getHeaderAction

public ActionController getHeaderAction ()

Retrieves a ActionController for the header Action that is being controlled, or null if none is present.

Returns
ActionController

getInitialSearchText

public String getInitialSearchText ()

Returns the initial search text for the SearchTemplate being controlled, or null if one is not present.

Returns
String

getItemList

public ItemListController getItemList ()

Returns an ItemListController that contains the ItemList in the SearchTemplate that is being controlled, or null if one is not present.

Returns
ItemListController

getRowByTitle

public RowController getRowByTitle (String title)

Returns a RowController containing the first Row that was added with the given title as its title, in the ItemList contained in the SearchTemplate that is being controlled, or null if none match.

The value should be the CharSequence.toString() for the title originally provided.

Parameters
title String

Returns
RowController

getSearchHint

public String getSearchHint ()

Returns the search hint for the SearchTemplate being controlled, or null if one is not present.

Returns
String

isLoading

public boolean isLoading ()

Returns true if the template is set to be loading.

This state is set via calling SearchTemplate.Builder.setIsLoading(boolean).

Returns
boolean

of

public static SearchTemplateController of (SearchTemplate searchTemplate)

Creates a SearchTemplateController to control an SearchTemplate for testing.

Parameters
searchTemplate SearchTemplate

Returns
SearchTemplateController

performSearchSubmitted

public void performSearchSubmitted (String searchText)

Sends the search text as if the user submitted it.

Parameters
searchText String

performSearchTextChanged

public void performSearchTextChanged (String searchText)

Sends the search text as if the user entered it.

This method is not for copying user behavior of typing slowly, it will send the input to the search listener contained in the SearchTemplate being controlled.

In the real app, the host may send callbacks every 1 or few characters, this method will send the value provided. To copy host behavior you can call this method consecutively with parts of the input.

Parameters
searchText String

showKeyboardByDefault

public boolean showKeyboardByDefault ()

Verifies whether the keyboard is set to open by default.

This is set via calling SearchTemplate.Builder.setShowKeyboardByDefault(boolean).

Returns
boolean