mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
* *.kt: bulk correction of formatting using ktlint --format * *.kt: replace wildcard imports and second stage auto format ktlint --format * QuizQuestionTest.kt: modified property names to camel case to meet ktlint standard * LevelControllerTest.kt: modified property names to camel case to meet ktlint standard * QuizActivityUnitTest.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: modified property names to camel case to meet ktlint standard * UploadWorker.kt: modified property names to camel case to meet ktlint standard * UploadClient.kt: modified property names to camel case to meet ktlint standard * BasePagingPresenter.kt: modified property names to camel case to meet ktlint standard * DescriptionEditActivity.kt: modified property names to camel case to meet ktlint standard * OnSwipeTouchListener.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: corrected excessive line length to meet ktlint standard * DepictedItem.kt: corrected property name format and catch format to for ktlint standard * UploadCategoryAdapter.kt: corrected class definition format to meet ktlint standard * CustomSelectorActivity.kt: reformatted function names to first letter lowercase to meet ktlint standard * MediaDetailFragmentUnitTests.kt: fix string literal indentation to meet ktlint standard * NotForUploadDao.kt: file renamed to match class name, new file NotForUploadStatusDao.kt * UploadedDao.kt: file renamed to match class name, new file UploadedStatusDao.kt * Urls.kt: fixed excessive line length for ktLint standard * Snak_partial.kt & Statement_partial.kt: refactored to remove underscores in class names to meet ktLint standard * *.kt: fixed consecutive KDOC error for ktLint * PageableBaseDataSourceTest.kt & UploadPresenterTest.kt: fixed excessive line lengths to meet ktLint standard * CheckboxTriStatesTest.kt: renamed file to match class name to meet ktLint standard * .kt: resolved backing-property-naming error in ktLint, made matching properties public, matched names and refactored * TestConnectionFactory.kt: fixed property naming to adhere to ktLint standard
73 lines
2.7 KiB
Kotlin
73 lines
2.7 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import android.app.Application
|
|
import android.content.ContentProviderClient
|
|
import android.content.Context
|
|
import androidx.collection.LruCache
|
|
import com.google.gson.Gson
|
|
import com.nhaarman.mockitokotlin2.mock
|
|
import fr.free.nrw.commons.auth.AccountUtil
|
|
import fr.free.nrw.commons.data.DBOpenHelper
|
|
import fr.free.nrw.commons.di.CommonsApplicationComponent
|
|
import fr.free.nrw.commons.di.CommonsApplicationModule
|
|
import fr.free.nrw.commons.di.DaggerCommonsApplicationComponent
|
|
import fr.free.nrw.commons.kvstore.JsonKvStore
|
|
import fr.free.nrw.commons.location.LocationServiceManager
|
|
|
|
class TestCommonsApplication : Application() {
|
|
private var mockApplicationComponent: CommonsApplicationComponent? = null
|
|
|
|
override fun onCreate() {
|
|
if (mockApplicationComponent == null) {
|
|
mockApplicationComponent =
|
|
DaggerCommonsApplicationComponent
|
|
.builder()
|
|
.appModule(MockCommonsApplicationModule(this))
|
|
.build()
|
|
}
|
|
super.onCreate()
|
|
setTheme(R.style.Theme_AppCompat)
|
|
context = applicationContext
|
|
}
|
|
|
|
companion object {
|
|
private var context: Context? = null
|
|
|
|
fun getContext(): Context? = context
|
|
}
|
|
}
|
|
|
|
@Suppress("MemberVisibilityCanBePrivate")
|
|
class MockCommonsApplicationModule(
|
|
appContext: Context,
|
|
) : CommonsApplicationModule(appContext) {
|
|
val accountUtil: AccountUtil = mock()
|
|
val defaultSharedPreferences: JsonKvStore = mock()
|
|
val locationServiceManager: LocationServiceManager = mock()
|
|
val mockDbOpenHelper: DBOpenHelper = mock()
|
|
val lruCache: LruCache<String, String> = mock()
|
|
val gson: Gson = Gson()
|
|
val categoryClient: ContentProviderClient = mock()
|
|
val contributionClient: ContentProviderClient = mock()
|
|
val modificationClient: ContentProviderClient = mock()
|
|
val uploadPrefs: JsonKvStore = mock()
|
|
|
|
override fun provideCategoryContentProviderClient(context: Context?): ContentProviderClient = categoryClient
|
|
|
|
override fun provideContributionContentProviderClient(context: Context?): ContentProviderClient = contributionClient
|
|
|
|
override fun provideModificationContentProviderClient(context: Context?): ContentProviderClient = modificationClient
|
|
|
|
override fun providesAccountUtil(context: Context): AccountUtil = accountUtil
|
|
|
|
override fun providesDefaultKvStore(
|
|
context: Context,
|
|
gson: Gson,
|
|
): JsonKvStore = defaultSharedPreferences
|
|
|
|
override fun provideLocationServiceManager(context: Context): LocationServiceManager = locationServiceManager
|
|
|
|
override fun provideDBOpenHelper(context: Context): DBOpenHelper = mockDbOpenHelper
|
|
|
|
override fun provideLruCache(): LruCache<String, String> = lruCache
|
|
}
|