This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #1710: Create scaffolding for Robolectric tests
- Loading branch information
1 parent
b735cc9
commit 4dd43c3
Showing
28 changed files
with
239 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* 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 | ||
|
||
import org.mozilla.fenix.components.Components | ||
import org.mozilla.fenix.components.TestComponents | ||
|
||
class TestApplication : FenixApplication() { | ||
|
||
override val components: Components | ||
get() = TestComponents(this) | ||
|
||
override fun setupApplication() { | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/test/java/org/mozilla/fenix/components/TestBackgroundServices.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* 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.components | ||
|
||
import android.content.Context | ||
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage | ||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage | ||
import mozilla.components.feature.sync.BackgroundSyncManager | ||
|
||
class TestBackgroundServices( | ||
context: Context, | ||
historyStorage: PlacesHistoryStorage, | ||
bookmarksStorage: PlacesBookmarksStorage | ||
) : BackgroundServices(context, historyStorage, bookmarksStorage) { | ||
override val syncManager = BackgroundSyncManager("") | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/test/java/org/mozilla/fenix/components/TestComponents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.mozilla.fenix.components | ||
|
||
import android.content.Context | ||
import io.mockk.mockk | ||
|
||
class TestComponents(private val context: Context) : Components(context) { | ||
override val backgroundServices by lazy { | ||
mockk<BackgroundServices>(relaxed = true) | ||
} | ||
override val services by lazy { Services(backgroundServices.accountManager, useCases.tabsUseCases) } | ||
override val core by lazy { TestCore(context) } | ||
override val search by lazy { Search(context) } | ||
override val useCases by lazy { UseCases(context, core.sessionManager, search.searchEngineManager) } | ||
override val utils by lazy { | ||
Utilities( | ||
context, | ||
core.sessionManager, | ||
useCases.sessionUseCases, | ||
useCases.searchUseCases | ||
) | ||
} | ||
override val analytics by lazy { Analytics(context) } | ||
override val storage by lazy { Storage(context) } | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/test/java/org/mozilla/fenix/components/TestCore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* 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.components | ||
|
||
import android.content.Context | ||
import io.mockk.mockk | ||
import kotlinx.coroutines.ObsoleteCoroutinesApi | ||
import mozilla.components.browser.engine.gecko.GeckoEngine | ||
import mozilla.components.browser.session.SessionManager | ||
import org.mozilla.geckoview.GeckoRuntime | ||
|
||
@ObsoleteCoroutinesApi | ||
class TestCore(private val context: Context) : Core(context) { | ||
|
||
override val runtime = mockk<GeckoRuntime>(relaxed = true) | ||
override val engine = mockk<GeckoEngine>(relaxed = true) | ||
override val sessionManager = SessionManager(engine) | ||
} |
Oops, something went wrong.