1
0
Fork 0

sync-integration-history-bookmark-fenix-desktop (#7808)

clean code

remove unused import

fix reviewer comments
master
isabelrios 3 years ago committed by GitHub
parent 834d7e13cd
commit ee544dd3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 93
      app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt
  2. 25
      app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_bookmark_desktop.js
  3. 28
      app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_history_desktop.js
  4. 8
      app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py
  5. 8
      app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt

@ -9,35 +9,54 @@ import android.widget.EditText
import androidx.test.espresso.Espresso.onView
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.withText
import org.junit.Rule
import org.junit.Test
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.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import okhttp3.mockwebserver.MockWebServer
import org.hamcrest.Matchers.allOf
import org.junit.After
import org.junit.Before
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.ext.toUri
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")
class SyncIntegrationTest {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var mockWebServer: MockWebServer
@get:Rule
val activityTestRule = HomeActivityTestRule()
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
start()
}
}
@After
fun tearDown() {
mockWebServer.shutdown()
}
// History item Desktop -> Fenix
@Test
fun checkHistoryFromDesktopTest() {
@ -82,6 +101,7 @@ class SyncIntegrationTest {
}
}
// Login item Desktop -> Fenix
@Test
fun checkLoginsFromDesktopTest() {
homeScreen {
@ -113,30 +133,46 @@ class SyncIntegrationTest {
}
}
/* These tests will be running in the future
// once the test above runs successfully and
// the environment is stable
// History item Fenix -> Desktop
// Bookmark item Fenix -> Desktop
@Test
fun checkBookmarkFromDeviceTest() {
tapInToolBar()
typeInToolBar()
seeBookmark()
mDevice.pressBack()
signInFxSync()
val defaultWebPage = "example.com".toUri()!!
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage) {
}.openThreeDotMenu {
verifyAddBookmarkButton()
clickAddBookmarkButton()
}
browserScreen {
}.openThreeDotMenu {
}.openSettings {
}.openTurnOnSyncMenu {
useEmailInsteadButton()
typeEmail()
tapOnContinueButton()
typePassword()
sleep(TestAssetHelper.waitingTimeShort)
tapOnSignIn()
}
}
// Bookmark item Fenix -> Desktop
// History item Fenix -> Desktop
@Test
fun checkHistoryFromDeviceTest() {
tapInToolBar()
typeInToolBar()
sleep(TestAssetHelper.waitingTime)
mDevice.pressBack()
signInFxSync()
val defaultWebPage = "example.com".toUri()!!
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage) {
}.openThreeDotMenu {
}.openSettings {
}.openTurnOnSyncMenu {
useEmailInsteadButton()
typeEmail()
tapOnContinueButton()
typePassword()
sleep(TestAssetHelper.waitingTimeShort)
tapOnSignIn()
}
}
*/
// Useful functions for the tests
fun typeEmail() {
@ -170,11 +206,6 @@ class SyncIntegrationTest {
mDevice.pressEnter()
}
fun typeInToolBar() {
awesomeBar().perform(replaceText("example.com"),
pressImeActionButton())
}
fun historyAfterSyncIsShown() {
val historyEntry = mDevice.findObject(By.text("http://www.example.com/"))
historyEntry.isEnabled()
@ -185,12 +216,6 @@ class SyncIntegrationTest {
bookmarkEntry.isEnabled()
}
fun seeBookmark() {
mDevice.waitNotNull(Until.findObjects(By.text("Bookmark")), TestAssetHelper.waitingTime)
val bookmarkButton = mDevice.findObject(By.text("Bookmark"))
bookmarkButton.click()
}
fun tapReturnToPreviousApp() {
mDevice.waitNotNull(Until.findObjects(By.text("Settings")), TestAssetHelper.waitingTime)
mDevice.pressBack()
@ -218,7 +243,5 @@ class SyncIntegrationTest {
}
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 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')
gradlewbuild.test('checkHistoryFromDesktopTest')
def test_sync_bookmark_from_device(tps, gradlewbuild):
os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
def test_sync_bookmark_from_desktop(tps, gradlewbuild):
tps.run('test_bookmark.js')
gradlewbuild.test('checkBookmarkFromDesktopTest')
def test_sync_logins_from_device(tps, gradlewbuild):
os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
tps.run('test_logins.js')
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()
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…
Cancel
Save