For #22569: Remove allopen plugin and Mockable annotations
parent
b41542dc5e
commit
8de4c0b4db
@ -1,20 +0,0 @@
|
||||
/* 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.utils
|
||||
|
||||
// Annotations for testing.
|
||||
|
||||
/**
|
||||
* Annotate a class with [OpenClass] to open a class for mocking purposes while keeping it final in release builds
|
||||
*/
|
||||
@Target(AnnotationTarget.ANNOTATION_CLASS)
|
||||
annotation class OpenClass
|
||||
|
||||
/**
|
||||
* Annotate a class with [Mockable] to make it extensible in debug builds
|
||||
*/
|
||||
@OpenClass
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class Mockable
|
@ -1,39 +0,0 @@
|
||||
/* 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 org.mozilla.fenix.helpers.perf.TestStrictModeManager
|
||||
import org.mozilla.fenix.utils.ClipboardHandler
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
class TestComponents(private val context: Context) : Components(context) {
|
||||
override val backgroundServices by lazy {
|
||||
mockk<BackgroundServices>(relaxed = true)
|
||||
}
|
||||
override val services by lazy { Services(context, backgroundServices.accountManager) }
|
||||
override val core by lazy { TestCore(context, analytics.crashReporter) }
|
||||
@Suppress("Deprecation")
|
||||
override val useCases by lazy {
|
||||
UseCases(
|
||||
context,
|
||||
core.engine,
|
||||
core.store,
|
||||
core.webAppShortcutManager,
|
||||
core.topSitesStorage,
|
||||
core.bookmarksStorage,
|
||||
core.historyStorage
|
||||
)
|
||||
}
|
||||
override val intentProcessors by lazy { mockk<IntentProcessors>(relaxed = true) }
|
||||
override val analytics by lazy { Analytics(context) }
|
||||
|
||||
override val clipboardHandler by lazy { ClipboardHandler(context) }
|
||||
|
||||
override val settings by lazy { mockk<Settings>(relaxed = true) }
|
||||
|
||||
override val strictMode by lazy { TestStrictModeManager() }
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/* 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.every
|
||||
import io.mockk.mockk
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
|
||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
|
||||
import mozilla.components.concept.base.crash.CrashReporting
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.concept.engine.Settings
|
||||
import mozilla.components.concept.fetch.Client
|
||||
import mozilla.components.feature.pwa.WebAppShortcutManager
|
||||
import mozilla.components.feature.top.sites.DefaultTopSitesStorage
|
||||
|
||||
class TestCore(context: Context, crashReporter: CrashReporting) : Core(
|
||||
context,
|
||||
crashReporter,
|
||||
mockk()
|
||||
) {
|
||||
|
||||
override val engine = mockk<Engine>(relaxed = true) {
|
||||
every { this@mockk getProperty "settings" } returns mockk<Settings>(relaxed = true)
|
||||
}
|
||||
override val store = mockk<BrowserStore>()
|
||||
override val client = mockk<Client>()
|
||||
override val webAppShortcutManager = mockk<WebAppShortcutManager>()
|
||||
override val thumbnailStorage = mockk<ThumbnailStorage>()
|
||||
override val topSitesStorage = mockk<DefaultTopSitesStorage>()
|
||||
override val bookmarksStorage = mockk<PlacesBookmarksStorage>()
|
||||
override val historyStorage = mockk<PlacesHistoryStorage>()
|
||||
}
|
Loading…
Reference in New Issue