Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fenix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
The Tor Project
Applications
fenix
Commits
672462f2
Commit
672462f2
authored
5 years ago
by
Sourabh
Committed by
Jeff Boek
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add tests for DefaultQuickActionSheetController (#4835)
parent
aab35784
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/test/java/org/mozilla/fenix/quickactionsheet/DefaultQuickActionSheetControllerTest.kt
+80
-0
80 additions, 0 deletions
...quickactionsheet/DefaultQuickActionSheetControllerTest.kt
with
80 additions
and
0 deletions
app/src/test/java/org/mozilla/fenix/quickactionsheet/DefaultQuickActionSheetControllerTest.kt
0 → 100644
+
80
−
0
View file @
672462f2
/*
* 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/.
*/
package
org.mozilla.fenix.quickactionsheet
import
androidx.navigation.NavController
import
io.mockk.every
import
io.mockk.mockk
import
io.mockk.verify
import
mozilla.components.browser.session.Session
import
mozilla.components.feature.app.links.AppLinksUseCases
import
org.junit.Before
import
org.junit.Test
import
org.mozilla.fenix.HomeActivity
import
org.mozilla.fenix.R
import
org.mozilla.fenix.browser.BrowserFragmentDirections
import
org.mozilla.fenix.components.metrics.Event
import
org.mozilla.fenix.components.metrics.MetricController
import
org.mozilla.fenix.ext.metrics
import
org.mozilla.fenix.ext.nav
import
org.mozilla.fenix.utils.ItsNotBrokenSnack
class
DefaultQuickActionSheetControllerTest
{
private
val
context
:
HomeActivity
=
mockk
(
relaxed
=
true
)
private
val
navController
:
NavController
=
mockk
(
relaxed
=
true
)
private
val
currentSession
:
Session
=
mockk
(
relaxed
=
true
)
private
val
appLinksUseCases
:
AppLinksUseCases
=
mockk
(
relaxed
=
true
)
private
val
bookmarkTapped
:
(
Session
)
->
Unit
=
mockk
(
relaxed
=
true
)
private
val
metrics
:
MetricController
=
mockk
(
relaxed
=
true
)
private
lateinit
var
controller
:
DefaultQuickActionSheetController
@Before
fun
setUp
()
{
controller
=
DefaultQuickActionSheetController
(
context
,
navController
,
currentSession
,
appLinksUseCases
,
bookmarkTapped
)
every
{
context
.
metrics
}
returns
metrics
}
@Test
fun
handleShare
()
{
controller
.
handleShare
()
verify
{
metrics
.
track
(
Event
.
QuickActionSheetShareTapped
)
}
verify
{
navController
.
nav
(
R
.
id
.
browserFragment
,
BrowserFragmentDirections
.
actionBrowserFragmentToShareFragment
(
currentSession
.
url
))
}
}
@Test
fun
handleDownload
()
{
controller
.
handleDownload
()
verify
{
metrics
.
track
(
Event
.
QuickActionSheetDownloadTapped
)
}
verify
{
ItsNotBrokenSnack
(
context
).
showSnackbar
(
issueNumber
=
"348"
)
}
}
@Test
fun
handleBookmark
()
{
controller
.
handleBookmark
()
verify
{
metrics
.
track
(
Event
.
QuickActionSheetBookmarkTapped
)
}
verify
{
bookmarkTapped
(
currentSession
)
}
}
@Test
fun
handleOpenLink
()
{
controller
.
handleOpenLink
()
verify
{
metrics
.
track
(
Event
.
QuickActionSheetOpenInAppTapped
)
}
verify
{
appLinksUseCases
.
appLinkRedirect
.
invoke
(
currentSession
.
url
)
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment