Created
June 27, 2019 16:37
-
-
Save AaronMT/1ecf15564e8ac5f899493ccd2272e654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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/. */ | |
@file:Suppress("TooManyFunctions") | |
package org.mozilla.fenix.ui.robots | |
import android.net.Uri | |
import androidx.test.espresso.Espresso.onView | |
import androidx.test.espresso.action.ViewActions.* | |
import androidx.test.espresso.matcher.ViewMatchers | |
import androidx.test.platform.app.InstrumentationRegistry | |
import androidx.test.uiautomator.UiDevice | |
import org.mozilla.fenix.R | |
/** | |
* Implementation of Robot Pattern for the URL toolbar. | |
*/ | |
class URLBarRobot { | |
class Transition { | |
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | |
fun enterURL(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { | |
mDevice.waitForIdle() | |
urlBar().perform(click()) | |
awesomeBar().perform(replaceText(url.toString()), pressImeActionButton()) | |
BrowserRobot().interact() | |
return BrowserRobot.Transition() | |
} | |
} | |
} | |
fun URLBar(interact: URLBarRobot.() -> Unit): URLBarRobot.Transition { | |
URLBarRobot.interact() | |
return URLBarRobot.Transition() | |
} | |
private fun urlBar() = onView(ViewMatchers.withId(R.id.toolbar)) | |
private fun awesomeBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_edit_url_view)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment