From 034100bcf49d8169b3d37ff40ec2ebf0abddfdb0 Mon Sep 17 00:00:00 2001 From: mcatta Date: Mon, 16 Oct 2023 10:40:14 +0200 Subject: [PATCH] test: add application test --- .../sleep/di/SleepifyApplicationTest.kt | 43 +++++++++++++++++++ .../notification/PlayerNotificationService.kt | 6 +-- .../sleep/buildtools/jacoco/JacocoOptions.kt | 2 +- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 app/src/androidTest/java/dev/marcocattaneo/sleep/di/SleepifyApplicationTest.kt diff --git a/app/src/androidTest/java/dev/marcocattaneo/sleep/di/SleepifyApplicationTest.kt b/app/src/androidTest/java/dev/marcocattaneo/sleep/di/SleepifyApplicationTest.kt new file mode 100644 index 0000000..662361c --- /dev/null +++ b/app/src/androidTest/java/dev/marcocattaneo/sleep/di/SleepifyApplicationTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2023 Marco Cattaneo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.marcocattaneo.sleep.di + +import androidx.test.ext.junit.rules.ActivityScenarioRule +import dev.marcocattaneo.sleep.MainActivity +import org.junit.Assert.* +import org.junit.Rule +import org.junit.Test + + +internal class SleepifyApplicationTest { + + @get:Rule + var rule: ActivityScenarioRule = ActivityScenarioRule(MainActivity::class.java) + + @Test + fun testOnCreate() { + // Given + val scenario = rule.scenario + + // When + scenario.onActivity { activity -> + // then + assertEquals(SleepifyApplication::class.java, activity.application::class.java) + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/dev/marcocattaneo/sleep/ui/notification/PlayerNotificationService.kt b/app/src/main/java/dev/marcocattaneo/sleep/ui/notification/PlayerNotificationService.kt index d4e5390..c60de1d 100644 --- a/app/src/main/java/dev/marcocattaneo/sleep/ui/notification/PlayerNotificationService.kt +++ b/app/src/main/java/dev/marcocattaneo/sleep/ui/notification/PlayerNotificationService.kt @@ -32,11 +32,11 @@ import javax.inject.Inject class PlayerNotificationService : Service() { sealed class Action(val key: String) { - object PLAY : Action("dev.marcocattaneo.sleep.PlayerNotificationService.PLAY") + data object PLAY : Action("dev.marcocattaneo.sleep.PlayerNotificationService.PLAY") - object PAUSE : Action("dev.marcocattaneo.sleep.PlayerNotificationService.PAUSE") + data object PAUSE : Action("dev.marcocattaneo.sleep.PlayerNotificationService.PAUSE") - object STOP : Action("dev.marcocattaneo.sleep.PlayerNotificationService.STOP") + data object STOP : Action("dev.marcocattaneo.sleep.PlayerNotificationService.STOP") } @Inject diff --git a/build-tools/jacoco/src/main/kotlin/sleep/buildtools/jacoco/JacocoOptions.kt b/build-tools/jacoco/src/main/kotlin/sleep/buildtools/jacoco/JacocoOptions.kt index d1d6b3d..681ea65 100644 --- a/build-tools/jacoco/src/main/kotlin/sleep/buildtools/jacoco/JacocoOptions.kt +++ b/build-tools/jacoco/src/main/kotlin/sleep/buildtools/jacoco/JacocoOptions.kt @@ -16,7 +16,7 @@ package sleep.buildtools.jacoco -object JacocoOptions { +internal object JacocoOptions { val EXCLUDED_FILES = listOf( // data binding "android/databinding/**/*.class",