Instrumtation test fix (#37)

This commit is contained in:
2024-07-07 21:03:04 +01:00
committed by GitHub
parent 0c7dedcc82
commit 0aff414b1c
8 changed files with 14 additions and 68 deletions

View File

@@ -16,7 +16,7 @@ import com.appttude.h_mal.atlas_weather.data.room.AppDatabase
import com.appttude.h_mal.atlas_weather.data.room.Converter import com.appttude.h_mal.atlas_weather.data.room.Converter
import java.io.BufferedReader import java.io.BufferedReader
class TestAppClass : AtlasApp() { class TestAppClass : AppClass() {
private val idlingResources = CountingIdlingResource("Data_loader") private val idlingResources = CountingIdlingResource("Data_loader")
private val mockingNetworkInterceptor = MockingNetworkInterceptor(idlingResources) private val mockingNetworkInterceptor = MockingNetworkInterceptor(idlingResources)
@@ -64,4 +64,15 @@ class TestAppClass : AtlasApp() {
locationProvider.addLocationToList(location, lat, long) locationProvider.addLocationToList(location, lat, long)
} }
fun removeLocation(location: String) {
locationProvider.removeLocationFromList(location)
}
fun removeLocation(lat: Double, long: Double) {
locationProvider.removeLocationFromList(lat, long)
}
fun clearDatabase() {
database.getWeatherDao().deleteAll()
}
} }

View File

@@ -27,6 +27,7 @@ class SnapshotCaptureTest : BaseTest<MainActivity>(MainActivity::class.java) {
super.testFinished() super.testFinished()
clearLocation("London") clearLocation("London")
clearDatabase() clearDatabase()
clearPrefs()
} }

View File

@@ -5,7 +5,6 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application <application
android:name="com.appttude.h_mal.atlas_weather.application.AtlasApp"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"

View File

@@ -1,46 +0,0 @@
package com.appttude.h_mal.atlas_weather.application
import com.appttude.h_mal.atlas_weather.service.notification.NotificationHelper
import com.appttude.h_mal.atlas_weather.service.notification.NotificationService
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.provider
import org.kodein.di.generic.singleton
open class AtlasApp : AppClass() {
private lateinit var notificationService: NotificationService
override val flavourModule = super.flavourModule.copy {
bind() from singleton {
NotificationHelper(
instance(),
instance(),
)
}
bind() from singleton {
NotificationService(this@AtlasApp).apply { notificationService = this }
}
bind() from provider {
ApplicationViewModelFactory(
this@AtlasApp,
instance(),
instance(),
instance(),
instance()
)
}
}
// override fun onCreate() {
// super.onCreate()
// notificationService.schedulePushNotifications()
// }
fun scheduleNotifications() = notificationService.schedulePushNotifications()
fun unscheduleNotifications() = notificationService.unschedulePushNotifications()
}

View File

@@ -18,6 +18,7 @@
android:required="true" /> android:required="true" />
<application <application
android:name="com.appttude.h_mal.atlas_weather.application.AppClass"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="MissingApplicationIcon" /> tools:ignore="MissingApplicationIcon" />

View File

@@ -3,7 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<application <application
android:name="com.appttude.h_mal.atlas_weather.application.MonoApp"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"

View File

@@ -1,19 +0,0 @@
package com.appttude.h_mal.atlas_weather.application
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.provider
open class MonoApp : AppClass() {
override val flavourModule = super.flavourModule.copy {
bind() from provider {
ApplicationViewModelFactory(
this@MonoApp,
instance(),
instance(),
instance(),
)
}
}
}