Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
fenix
Commits
ee544dd3
Unverified
Commit
ee544dd3
authored
Feb 11, 2020
by
isabelrios
Committed by
GitHub
Feb 11, 2020
Browse files
sync-integration-history-bookmark-fenix-desktop (#7808)
clean code remove unused import fix reviewer comments
parent
834d7e13
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/src/androidTest/java/org/mozilla/fenix/syncintegration/SyncIntegrationTest.kt
View file @
ee544dd3
...
...
@@ -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
())
app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_bookmark_desktop.js
0 → 100644
View file @
ee544dd3
/* 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
],
]);
app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_history_desktop.js
0 → 100644
View file @
ee544dd3
/* 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
]
]);
app/src/androidTest/java/org/mozilla/fenix/syncintegration/test_integration.py
View file @
ee544dd3
...
...
@@ -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'
)
app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt
View file @
ee544dd3
...
...
@@ -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
()
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment