summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
blob: b918801296a277948fc593efef3072ca7d06413a (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
package com.mapbox.mapboxsdk.integration

import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import android.support.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Regression test that validates MapFragment integration with a ViewPager
 */
@RunWith(AndroidJUnit4::class)
class ViewPagerScrollTest : BaseIntegrationTest() {

  @get:Rule
  var activityRule: ActivityTestRule<ViewPagerActivity> = ActivityTestRule(ViewPagerActivity::class.java)

  @Test
  @LargeTest
  fun scrollViewPager() {
    for (i in 1..4) {
      clickTab(i)
    }

    for (i in 3 downTo 0) {
      clickTab(i)
    }
  }

  private fun clickTab(index: Int) {
    device.findObject(UiSelector().text("Page $index")).click()
  }
}