blob: be57fb3e2d51b62b2e7ae12f1f71da5190064b59 (
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
|
package com.mapbox.mapboxsdk.integration
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP
import android.support.test.InstrumentationRegistry
import android.support.test.uiautomator.*
import org.junit.Before
abstract class BaseIntegrationTest {
protected lateinit var device: UiDevice
@Before
open fun beforeTest() {
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
}
}
fun UiDevice.launchActivity(context: Context, clazz: Class<*>) {
val applicationPackage = InstrumentationRegistry.getTargetContext().packageName
val intent = Intent(context, clazz)
intent.addFlags(FLAG_ACTIVITY_SINGLE_TOP)
InstrumentationRegistry.getContext().startActivity(intent)
wait(Until.hasObject(By.pkg(applicationPackage).depth(0)), 5000)
}
fun UiDevice.scrollRecyclerViewTo(recycleItem: String) {
val appView = UiScrollable(UiSelector().scrollable(true))
appView.scrollIntoView(UiSelector().text(recycleItem))
}
|