blob: e432d5f576ef02a1c1c8babfd46ee637d84048e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package com.mapbox.mapboxsdk.testapp;
import android.app.Activity;
import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
/**
* Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2
*/
public class BaseTest {
protected final static String HOME_BUTTON_STRING = "Navigate up";
/*
* Shortcuts for common UI tests
*/
protected void checkViewIsDisplayed(int id) {
onView(withId(id))
.check(matches(isDisplayed()));
}
/*
* Screenshots logic
*/
protected void takeNamedScreenshot(final Activity activity, final String name) {
// Screenshots need to be taken on the UI thread
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
ScreenshotUtil.take(activity, name);
}
});
}
}
|