-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from kittinunf/kv/add-roborazzi-into-project
Add Test and implement basic foundation for Snapshot testing
- Loading branch information
Showing
15 changed files
with
233 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Gradle files | ||
.gradle/ | ||
build/ | ||
build/* | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
build/* | ||
!build/outputs/roborazzi/* |
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
Binary file added
BIN
+138 KB
...build/outputs/roborazzi/com.akexorcist.ruammij.MainActivityTest.overview_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+171 KB
...build/outputs/roborazzi/com.akexorcist.ruammij.MainActivityTest.overview_th.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
46 changes: 46 additions & 0 deletions
46
app/src/test/java/com/akexorcist/ruammij/InstrumentationTestRunner.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,46 @@ | ||
package com.akexorcist.ruammij | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import androidx.test.runner.AndroidJUnitRunner | ||
import com.akexorcist.ruammij.data.DeviceRepository | ||
import com.akexorcist.ruammij.di.AppModule | ||
import com.akexorcist.ruammij.fake.FakeDeviceRepository | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
import org.koin.core.context.startKoin | ||
import org.koin.core.context.stopKoin | ||
import org.koin.core.logger.Level | ||
import org.koin.dsl.module | ||
|
||
class InstrumentationTestRunner : AndroidJUnitRunner() { | ||
override fun newApplication( | ||
classLoader: ClassLoader?, | ||
className: String?, | ||
context: Context? | ||
): Application { | ||
return super.newApplication(classLoader, TestRuamMijApplication::class.java.name, context) | ||
} | ||
} | ||
|
||
private val modulesOverride = module { | ||
single<DeviceRepository> { | ||
FakeDeviceRepository() | ||
} | ||
} | ||
|
||
class TestRuamMijApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
startKoin { | ||
androidContext(this@TestRuamMijApplication) | ||
modules(AppModule.allModules) | ||
modules(modulesOverride) | ||
} | ||
} | ||
|
||
override fun onTerminate() { | ||
super.onTerminate() | ||
stopKoin() | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/test/java/com/akexorcist/ruammij/MainActivityTest.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,36 @@ | ||
package com.akexorcist.ruammij | ||
|
||
import android.R | ||
import androidx.test.core.app.ActivityScenario.launch | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import com.github.takahirom.roborazzi.captureRoboImage | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.koin.test.KoinTest | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
import org.robolectric.annotation.GraphicsMode | ||
|
||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
@RunWith(RobolectricTestRunner::class) | ||
class MainActivityTest : KoinTest { | ||
|
||
@Test | ||
@Config(qualifiers = "en-xlarge-long-hdpi") | ||
fun overview_en() { | ||
val activityScenario = launch(MainActivity::class.java) | ||
|
||
onView(withId(R.id.content)) | ||
.captureRoboImage() | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "th-xlarge-long-hdpi") | ||
fun overview_th() { | ||
val activityScenario = launch(MainActivity::class.java) | ||
|
||
onView(withId(R.id.content)) | ||
.captureRoboImage() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/test/java/com/akexorcist/ruammij/ModuleCheckTest.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,19 @@ | ||
package com.akexorcist.ruammij | ||
|
||
import com.akexorcist.ruammij.di.AppModule.allModules | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.koin.core.annotation.KoinExperimentalAPI | ||
import org.koin.test.AutoCloseKoinTest | ||
import org.koin.test.verify.verifyAll | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
@OptIn(KoinExperimentalAPI::class) | ||
class ModuleCheckTest : AutoCloseKoinTest() { | ||
|
||
@Test | ||
fun checkKoinModules() { | ||
allModules.verifyAll() | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
app/src/test/java/com/akexorcist/ruammij/fake/FakeDeviceRepository.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,50 @@ | ||
package com.akexorcist.ruammij.fake | ||
|
||
import com.akexorcist.ruammij.data.DeviceRepository | ||
import com.akexorcist.ruammij.data.InstalledApp | ||
import com.akexorcist.ruammij.data.database.SafeApp | ||
import com.akexorcist.ruammij.ui.overview.MediaProjectionApp | ||
|
||
class FakeDeviceRepository : DeviceRepository { | ||
override suspend fun getInstalledApps(forceRefresh: Boolean): List<InstalledApp> { | ||
return emptyList() | ||
} | ||
|
||
override suspend fun getSafeApps(forceRefresh: Boolean): List<SafeApp> { | ||
return emptyList() | ||
} | ||
|
||
override suspend fun markAsSafe(packageName: String) { | ||
} | ||
|
||
override suspend fun getInstalledApp( | ||
forceRefresh: Boolean, | ||
packageName: String | ||
): InstalledApp? { | ||
return null | ||
} | ||
|
||
override suspend fun getEnabledAccessibilityApps(forceRefresh: Boolean): List<InstalledApp> { | ||
return emptyList() | ||
} | ||
|
||
override suspend fun getAccessibilitySupportApps(forceRefresh: Boolean): List<InstalledApp> { | ||
return emptyList() | ||
} | ||
|
||
override suspend fun getRunningMediaProjectionApps(forceRefresh: Boolean): List<MediaProjectionApp> { | ||
return emptyList() | ||
} | ||
|
||
override suspend fun isUsbDebuggingEnabled(): Boolean { | ||
return true | ||
} | ||
|
||
override suspend fun isWirelessDebuggingEnabled(): Boolean? { | ||
return true | ||
} | ||
|
||
override suspend fun isDeveloperOptionsEnabled(): Boolean { | ||
return true | ||
} | ||
} |
Oops, something went wrong.