2019-10-03 18:30:55 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.helpers
|
|
|
|
|
2019-10-29 10:36:19 +01:00
|
|
|
import android.net.Uri
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
|
|
import androidx.test.espresso.action.ViewActions.longClick
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
2019-11-19 10:29:35 +01:00
|
|
|
import androidx.test.uiautomator.By
|
2019-10-03 18:30:55 +02:00
|
|
|
import androidx.test.uiautomator.UiScrollable
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
2019-11-19 10:29:35 +01:00
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
|
|
|
import org.mozilla.fenix.ui.robots.mDevice
|
2019-10-03 18:30:55 +02:00
|
|
|
|
|
|
|
object TestHelper {
|
|
|
|
fun scrollToElementByText(text: String): UiScrollable {
|
|
|
|
val appView = UiScrollable(UiSelector().scrollable(true))
|
|
|
|
appView.scrollTextIntoView(text)
|
|
|
|
return appView
|
|
|
|
}
|
2019-10-29 10:36:19 +01:00
|
|
|
|
|
|
|
fun longTapSelectItem(url: Uri) {
|
2019-11-19 10:29:35 +01:00
|
|
|
mDevice.waitNotNull(
|
|
|
|
Until.findObject(By.text(url.toString())),
|
|
|
|
TestAssetHelper.waitingTime
|
|
|
|
)
|
2019-10-29 10:36:19 +01:00
|
|
|
onView(withText(url.toString())).perform(longClick())
|
|
|
|
}
|
2019-10-03 18:30:55 +02:00
|
|
|
}
|