summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BaseStyleTest.java
blob: 620e15579f522e17124ac78df14be95105ecee21 (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.style;

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 Test class for Style tests
 */
public class BaseStyleTest {

  protected static final 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);
      }
    });

  }

}