From 857b0b6f4be9407d95da030ff96fb8d7ed519c0f Mon Sep 17 00:00:00 2001 From: Aaron Train Date: Fri, 31 Jan 2020 14:58:02 -0500 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/8015: fix UI test verifyContextCopyLink (https://github.com/mozilla-mobile/fenix/pull/8026) --- .../java/org/mozilla/fenix/ui/ContextMenusTest.kt | 4 ++-- .../java/org/mozilla/fenix/ui/robots/BrowserRobot.kt | 4 ++-- .../mozilla/fenix/ui/robots/NavigationToolbarRobot.kt | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt index 78b24b1e1e..a9510416d3 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt @@ -112,7 +112,7 @@ class ContextMenusTest { clickContextCopyLink() verifySnackBarText("Link copied to clipboard") }.openNavigationToolbar { - }.visitLinkFromClipboard(genericURL.url) { + }.visitLinkFromClipboard { verifyUrl(genericURL.url.toString()) } } @@ -169,7 +169,7 @@ class ContextMenusTest { clickContextCopyImageLocation() verifySnackBarText("Link copied to clipboard") }.openNavigationToolbar { - }.visitLinkFromClipboard(imageResource.url) { + }.visitLinkFromClipboard { verifyUrl(imageResource.url.toString()) } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index b0964dea34..bd80a3277f 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -38,14 +38,14 @@ class BrowserRobot { .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) } - fun verifyUrl(redirectUrl: String) { + fun verifyUrl(url: String) { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) mDevice.waitNotNull( Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime ) onView(withId(R.id.mozac_browser_toolbar_url_view)) - .check(matches(withText(containsString(redirectUrl)))) + .check(matches(withText(containsString(url)))) } fun verifyHelpUrl() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt index 4f5e6f4005..454eecd12b 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt @@ -54,7 +54,7 @@ class NavigationToolbarRobot { return BrowserRobot.Transition() } - fun visitLinkFromClipboard(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + fun visitLinkFromClipboard(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { mDevice.waitNotNull( Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_clear_view")), waitingTime @@ -62,11 +62,12 @@ class NavigationToolbarRobot { clearAddressBar().click() mDevice.waitNotNull( - Until.findObject(By.text(url.toString())), waitingTime + Until.findObject(By.res("org.mozilla.fenix.debug:id/clipboard_title")), + waitingTime ) mDevice.waitNotNull( - Until.findObject(By.res("org.mozilla.fenix.debug:id/fill_link_from_clipboard")), + Until.findObject(By.res("org.mozilla.fenix.debug:id/clipboard_url")), waitingTime ) fillLinkButton().click() @@ -87,5 +88,5 @@ private fun urlBar() = onView(ViewMatchers.withId(R.id.toolbar)) private fun awesomeBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_edit_url_view)) private fun threeDotButton() = onView(ViewMatchers.withContentDescription("Menu")) private fun newTab() = onView(ViewMatchers.withContentDescription("Add tab")) -private fun fillLinkButton() = onView(ViewMatchers.withId(R.id.fill_link_from_clipboard)) +private fun fillLinkButton() = onView(ViewMatchers.withId(R.id.clipboard_url)) private fun clearAddressBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_clear_view))