androidTest: Test exodus_trackers.json file
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -49,7 +49,8 @@ android {
|
||||
versionCode = 61
|
||||
versionName = "4.6.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunner = "com.aurora.store.HiltInstrumentationTestRunner"
|
||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -183,7 +184,10 @@ dependencies {
|
||||
|
||||
//Test
|
||||
testImplementation(libs.junit)
|
||||
testImplementation(libs.androidx.junit)
|
||||
testImplementation(libs.google.truth)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.google.truth)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
//Hilt
|
||||
@@ -192,11 +196,14 @@ dependencies {
|
||||
implementation(libs.hilt.android.core)
|
||||
implementation(libs.hilt.androidx.work)
|
||||
|
||||
kspAndroidTest(libs.hilt.android.compiler)
|
||||
androidTestImplementation(libs.hilt.android.testing)
|
||||
|
||||
//Room
|
||||
ksp(libs.androidx.room.compiler)
|
||||
implementation(libs.androidx.room.ktx)
|
||||
implementation(libs.androidx.room.runtime)
|
||||
|
||||
// LeakCanary
|
||||
debugImplementation(libs.squareup.leakcanary.android)
|
||||
debugImplementation(libs.squareup.leakcanary.android)
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.aurora.aurorastore", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.aurora.store
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.test.runner.AndroidJUnitRunner
|
||||
import dagger.hilt.android.testing.HiltTestApplication
|
||||
|
||||
class HiltInstrumentationTestRunner: AndroidJUnitRunner() {
|
||||
|
||||
override fun newApplication(
|
||||
cl: ClassLoader?,
|
||||
className: String?,
|
||||
context: Context?
|
||||
): Application {
|
||||
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.aurora.store.data.providers
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.hilt.android.testing.HiltAndroidRule
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import javax.inject.Inject
|
||||
import org.json.JSONObject
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@HiltAndroidTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExodusDataProviderTest {
|
||||
|
||||
@get:Rule
|
||||
var hiltAndroidRule = HiltAndroidRule(this)
|
||||
|
||||
@Inject
|
||||
lateinit var exodusTrackers: JSONObject
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
hiltAndroidRule.inject()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTrackersJsonIsNotEmpty() {
|
||||
assertThat(exodusTrackers.toString()).isNotEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTrackersJsonContainsTrackers() {
|
||||
val trackers = mapOf(
|
||||
"com.facebook.flipper" to 392,
|
||||
"com.google.analytics." to 48,
|
||||
"com.google.firebase.firebase_analytics" to 49,
|
||||
"com.google.ads." to 312
|
||||
)
|
||||
trackers.forEach { (codeSignature, id) ->
|
||||
assertThat(
|
||||
exodusTrackers.getJSONObject(id.toString())
|
||||
.getString("code_signature")
|
||||
.contains(codeSignature)
|
||||
).isTrue()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ roomVersion = "2.6.1"
|
||||
shimmerVersion = "0.5.0"
|
||||
shizukuVersion = "13.1.5"
|
||||
swiperefreshlayoutVersion = "1.1.0"
|
||||
truth = "1.4.4"
|
||||
viewpager2Version = "1.1.0"
|
||||
workVersion = "2.9.1"
|
||||
|
||||
@@ -42,7 +43,7 @@ androidx-browser = { module = "androidx.browser:browser", version.ref = "browser
|
||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreVersion" }
|
||||
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoVersion" }
|
||||
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "junitVersion" }
|
||||
androidx-junit = { module = "androidx.test.ext:junit-ktx", version.ref = "junitVersion" }
|
||||
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifeVersion" }
|
||||
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifeVersion" }
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
@@ -69,8 +70,10 @@ github-topjohnwu-libsu = { module = "com.github.topjohnwu.libsu:core", version.r
|
||||
google-android-material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
|
||||
google-gson = { module = "com.google.code.gson:gson", version.ref = "gsonVersion" }
|
||||
google-protobuf-javalite = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobufJavaliteVersion" }
|
||||
google-truth = { module = "com.google.truth:truth", version.ref = "truth" }
|
||||
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltVersion" }
|
||||
hilt-android-core = { module = "com.google.dagger:hilt-android", version.ref = "hiltVersion" }
|
||||
hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hiltVersion" }
|
||||
hilt-androidx-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltWorkVersion" }
|
||||
hilt-androidx-work = { module = "androidx.hilt:hilt-work", version.ref = "hiltWorkVersion" }
|
||||
junit = { module = "junit:junit", version.ref = "junit" }
|
||||
|
||||
Reference in New Issue
Block a user