-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UI tests with DirectionsRoute test fixture
- Loading branch information
1 parent
4ab858b
commit 4956fcb
Showing
7 changed files
with
174 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/androidTest/java/testapp/action/NavigationViewAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package testapp.action; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.test.espresso.UiController; | ||
import android.support.test.espresso.ViewAction; | ||
import android.view.View; | ||
|
||
import com.mapbox.services.android.navigation.ui.v5.NavigationView; | ||
|
||
import org.hamcrest.Matcher; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
|
||
public class NavigationViewAction implements ViewAction { | ||
|
||
private OnInvokeActionListener invokeViewAction; | ||
private NavigationView navigationView; | ||
|
||
private NavigationViewAction(OnInvokeActionListener invokeViewAction, NavigationView navigationView) { | ||
this.invokeViewAction = invokeViewAction; | ||
this.navigationView = navigationView; | ||
} | ||
|
||
@Override | ||
public Matcher<View> getConstraints() { | ||
return isDisplayed(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return getClass().getSimpleName(); | ||
} | ||
|
||
@Override | ||
public void perform(UiController uiController, View view) { | ||
invokeViewAction.onInvokeAction(uiController, navigationView); | ||
} | ||
|
||
public static void invoke(NavigationView navigationView, OnInvokeActionListener invokeViewAction) { | ||
onView(withId(android.R.id.content)).perform(new NavigationViewAction(invokeViewAction, navigationView)); | ||
} | ||
|
||
public interface OnInvokeActionListener { | ||
void onInvokeAction(@NonNull UiController uiController, @NonNull NavigationView navigationView); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.