sync-integration-history-bookmark-fenix-desktop (#7808)
clean code remove unused import fix reviewer commentsmaster
parent
834d7e13cd
commit
ee544dd3f1
|
@ -9,35 +9,54 @@ import android.widget.EditText
|
||||||
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.action.ViewActions.replaceText
|
|
||||||
import androidx.test.espresso.action.ViewActions.pressImeActionButton
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
import org.mozilla.fenix.ui.robots.homeScreen
|
|
||||||
import org.mozilla.fenix.ui.robots.accountSettings
|
|
||||||
import org.mozilla.fenix.ui.robots.settingsSubMenuLoginsAndPassword
|
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.uiautomator.UiDevice
|
import androidx.test.uiautomator.UiDevice
|
||||||
import androidx.test.uiautomator.UiSelector
|
import androidx.test.uiautomator.UiSelector
|
||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
import androidx.test.uiautomator.Until
|
import androidx.test.uiautomator.Until
|
||||||
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
import org.hamcrest.Matchers.allOf
|
import org.hamcrest.Matchers.allOf
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||||
|
import org.mozilla.fenix.helpers.ext.toUri
|
||||||
import org.mozilla.fenix.helpers.ext.waitNotNull
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
|
import org.mozilla.fenix.ui.robots.accountSettings
|
||||||
|
import org.mozilla.fenix.ui.robots.settingsSubMenuLoginsAndPassword
|
||||||
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||||
|
import org.mozilla.fenix.ui.robots.browserScreen
|
||||||
|
|
||||||
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||||
class SyncIntegrationTest {
|
class SyncIntegrationTest {
|
||||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
private lateinit var mockWebServer: MockWebServer
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityTestRule = HomeActivityTestRule()
|
val activityTestRule = HomeActivityTestRule()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
mockWebServer = MockWebServer().apply {
|
||||||
|
setDispatcher(AndroidAssetDispatcher())
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
mockWebServer.shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
// History item Desktop -> Fenix
|
// History item Desktop -> Fenix
|
||||||
@Test
|
@Test
|
||||||
fun checkHistoryFromDesktopTest() {
|
fun checkHistoryFromDesktopTest() {
|
||||||
|
@ -82,6 +101,7 @@ class SyncIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Login item Desktop -> Fenix
|
||||||
@Test
|
@Test
|
||||||
fun checkLoginsFromDesktopTest() {
|
fun checkLoginsFromDesktopTest() {
|
||||||
homeScreen {
|
homeScreen {
|
||||||
|
@ -113,30 +133,46 @@ class SyncIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These tests will be running in the future
|
// Bookmark item Fenix -> Desktop
|
||||||
// once the test above runs successfully and
|
@Test
|
||||||
// the environment is stable
|
fun checkBookmarkFromDeviceTest() {
|
||||||
|
val defaultWebPage = "example.com".toUri()!!
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(defaultWebPage) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
verifyAddBookmarkButton()
|
||||||
|
clickAddBookmarkButton()
|
||||||
|
}
|
||||||
|
browserScreen {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
}.openTurnOnSyncMenu {
|
||||||
|
useEmailInsteadButton()
|
||||||
|
typeEmail()
|
||||||
|
tapOnContinueButton()
|
||||||
|
typePassword()
|
||||||
|
sleep(TestAssetHelper.waitingTimeShort)
|
||||||
|
tapOnSignIn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// History item Fenix -> Desktop
|
// History item Fenix -> Desktop
|
||||||
@Test
|
@Test
|
||||||
fun checkBookmarkFromDeviceTest() {
|
|
||||||
tapInToolBar()
|
|
||||||
typeInToolBar()
|
|
||||||
seeBookmark()
|
|
||||||
mDevice.pressBack()
|
|
||||||
signInFxSync()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bookmark item Fenix -> Desktop
|
|
||||||
@Test
|
|
||||||
fun checkHistoryFromDeviceTest() {
|
fun checkHistoryFromDeviceTest() {
|
||||||
tapInToolBar()
|
val defaultWebPage = "example.com".toUri()!!
|
||||||
typeInToolBar()
|
navigationToolbar {
|
||||||
sleep(TestAssetHelper.waitingTime)
|
}.enterURLAndEnterToBrowser(defaultWebPage) {
|
||||||
mDevice.pressBack()
|
}.openThreeDotMenu {
|
||||||
signInFxSync()
|
}.openSettings {
|
||||||
|
}.openTurnOnSyncMenu {
|
||||||
|
useEmailInsteadButton()
|
||||||
|
typeEmail()
|
||||||
|
tapOnContinueButton()
|
||||||
|
typePassword()
|
||||||
|
sleep(TestAssetHelper.waitingTimeShort)
|
||||||
|
tapOnSignIn()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Useful functions for the tests
|
// Useful functions for the tests
|
||||||
fun typeEmail() {
|
fun typeEmail() {
|
||||||
|
@ -170,11 +206,6 @@ class SyncIntegrationTest {
|
||||||
mDevice.pressEnter()
|
mDevice.pressEnter()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun typeInToolBar() {
|
|
||||||
awesomeBar().perform(replaceText("example.com"),
|
|
||||||
pressImeActionButton())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun historyAfterSyncIsShown() {
|
fun historyAfterSyncIsShown() {
|
||||||
val historyEntry = mDevice.findObject(By.text("http://www.example.com/"))
|
val historyEntry = mDevice.findObject(By.text("http://www.example.com/"))
|
||||||
historyEntry.isEnabled()
|
historyEntry.isEnabled()
|
||||||
|
@ -185,12 +216,6 @@ class SyncIntegrationTest {
|
||||||
bookmarkEntry.isEnabled()
|
bookmarkEntry.isEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun seeBookmark() {
|
|
||||||
mDevice.waitNotNull(Until.findObjects(By.text("Bookmark")), TestAssetHelper.waitingTime)
|
|
||||||
val bookmarkButton = mDevice.findObject(By.text("Bookmark"))
|
|
||||||
bookmarkButton.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun tapReturnToPreviousApp() {
|
fun tapReturnToPreviousApp() {
|
||||||
mDevice.waitNotNull(Until.findObjects(By.text("Settings")), TestAssetHelper.waitingTime)
|
mDevice.waitNotNull(Until.findObjects(By.text("Settings")), TestAssetHelper.waitingTime)
|
||||||
mDevice.pressBack()
|
mDevice.pressBack()
|
||||||
|
@ -218,7 +243,5 @@ class SyncIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun settingsAccount() = onView(allOf(withText("Turn on Sync"))).perform(click())
|
fun settingsAccount() = onView(allOf(withText("Turn on Sync"))).perform(click())
|
||||||
fun tapInToolBar() = onView(withId(R.id.toolbar_wrapper))
|
|
||||||
fun awesomeBar() = onView(withId(R.id.mozac_browser_toolbar_edit_url_view))
|
|
||||||
fun useEmailInsteadButton() = onView(withId(R.id.signInEmailButton)).perform(click())
|
fun useEmailInsteadButton() = onView(withId(R.id.signInEmailButton)).perform(click())
|
||||||
fun enterAccountSettings() = onView(withId(R.id.email)).perform(click())
|
fun enterAccountSettings() = onView(withId(R.id.email)).perform(click())
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The list of phases mapped to their corresponding profiles. The object
|
||||||
|
* here must be in strict JSON format, as it will get parsed by the Python
|
||||||
|
* testrunner (no single quotes, extra comma's, etc).
|
||||||
|
*/
|
||||||
|
EnableEngines(["bookmarks"]);
|
||||||
|
|
||||||
|
var phases = { "phase1": "profile1" };
|
||||||
|
|
||||||
|
|
||||||
|
// expected bookmark state
|
||||||
|
var bookmarksExpected = {
|
||||||
|
"mobile": [{
|
||||||
|
uri: "http://www.example.com/",
|
||||||
|
title: "Example Domain"}]
|
||||||
|
};
|
||||||
|
|
||||||
|
// sync and verify bookmarks
|
||||||
|
Phase("phase1", [
|
||||||
|
[Sync],
|
||||||
|
[Bookmarks.verify, bookmarksExpected],
|
||||||
|
]);
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The list of phases mapped to their corresponding profiles. The object
|
||||||
|
* here must be in strict JSON format, as it will get parsed by the Python
|
||||||
|
* testrunner (no single quotes, extra comma's, etc).
|
||||||
|
*/
|
||||||
|
EnableEngines(["history"]);
|
||||||
|
|
||||||
|
var phases = { "phase1": "profile1" };
|
||||||
|
|
||||||
|
|
||||||
|
// expected history state
|
||||||
|
var historyExpected = [
|
||||||
|
{ uri: "http://www.example.com/",
|
||||||
|
visits: [
|
||||||
|
{ type: 1 },
|
||||||
|
{ type: 2 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// sync and verify history
|
||||||
|
Phase("phase1", [
|
||||||
|
[Sync],
|
||||||
|
[History.verify, historyExpected]
|
||||||
|
]);
|
|
@ -10,12 +10,14 @@ def test_sync_history_from_desktop(tps, gradlewbuild):
|
||||||
tps.run('test_history.js')
|
tps.run('test_history.js')
|
||||||
gradlewbuild.test('checkHistoryFromDesktopTest')
|
gradlewbuild.test('checkHistoryFromDesktopTest')
|
||||||
|
|
||||||
def test_sync_bookmark_from_device(tps, gradlewbuild):
|
def test_sync_bookmark_from_desktop(tps, gradlewbuild):
|
||||||
os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
|
|
||||||
tps.run('test_bookmark.js')
|
tps.run('test_bookmark.js')
|
||||||
gradlewbuild.test('checkBookmarkFromDesktopTest')
|
gradlewbuild.test('checkBookmarkFromDesktopTest')
|
||||||
|
|
||||||
def test_sync_logins_from_device(tps, gradlewbuild):
|
def test_sync_logins_from_device(tps, gradlewbuild):
|
||||||
os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
|
|
||||||
tps.run('test_logins.js')
|
tps.run('test_logins.js')
|
||||||
gradlewbuild.test('checkLoginsFromDesktopTest')
|
gradlewbuild.test('checkLoginsFromDesktopTest')
|
||||||
|
|
||||||
|
def test_sync_bookmark_from_device(tps, gradlewbuild):
|
||||||
|
gradlewbuild.test('checkBookmarkFromDeviceTest')
|
||||||
|
tps.run('test_bookmark_desktop.js')
|
||||||
|
|
|
@ -146,6 +146,14 @@ class SettingsRobot {
|
||||||
SettingsSubMenuLoginsAndPasswordRobot().interact()
|
SettingsSubMenuLoginsAndPasswordRobot().interact()
|
||||||
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
|
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openTurnOnSyncMenu(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition {
|
||||||
|
fun turnOnSyncButton() = onView(ViewMatchers.withText("Turn on Sync"))
|
||||||
|
turnOnSyncButton().click()
|
||||||
|
|
||||||
|
SettingsTurnOnSyncRobot().interact()
|
||||||
|
return SettingsTurnOnSyncRobot.Transition()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue