Skip to content

Commit 303187a

Browse files
committed
imp(sync): add fdroid attribution in all model classes
1 parent 24fe5ac commit 303187a

File tree

15 files changed

+89
-219
lines changed

15 files changed

+89
-219
lines changed

core/database/src/test/java/com/looker/core/database/LocalizationTest.kt

-195
This file was deleted.

gradle/libs.versions.toml

+1
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,6 @@ looker-room = { id = "looker.room", version = "unspecified" }
124124
looker-serialization = { id = "looker.serialization", version = "unspecified" }
125125

126126
[bundles]
127+
test-unit = ["coroutines-test", "kotlin-test"]
127128
test-android = ["test-runner", "test-rules", "test-ext", "test-espresso-core", "coroutines-test", "kotlin-test"]
128129
test-ui = ["test-runner", "test-rules", "test-espresso-core", "test-uiautomator", "coroutines-test", "kotlin-test"]

sync/fdroid/src/androidTest/kotlin/com/looker/sync/fdroid/EntrySyncableTest.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ class EntrySyncableTest {
5555

5656
@Test
5757
fun benchmark_sync_full() = runTest(dispatcher) {
58-
memory(10) {
58+
val output = memory(10) {
5959
measureTimeMillis { syncable.sync(repo) }
6060
}
61+
println(output)
6162
}
6263

6364
@Test
6465
fun benchmark_entry_parser() = runTest(dispatcher) {
65-
memory(10) {
66+
val output = memory(10) {
6667
measureTimeMillis {
6768
parser.parse(
6869
file = FakeDownloader.downloadIndex(
@@ -75,6 +76,7 @@ class EntrySyncableTest {
7576
)
7677
}
7778
}
79+
println(output)
7880
}
7981

8082
@Test

sync/fdroid/src/androidTest/kotlin/com/looker/sync/fdroid/V1SyncableTest.kt

+33-15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Context
44
import androidx.test.ext.junit.runners.AndroidJUnit4
55
import androidx.test.platform.app.InstrumentationRegistry
66
import com.looker.core.domain.model.Repo
7+
import com.looker.sync.fdroid.common.IndexJarValidator
78
import com.looker.sync.fdroid.common.Izzy
89
import com.looker.sync.fdroid.common.JsonParser
910
import com.looker.sync.fdroid.common.downloadIndex
@@ -39,15 +40,11 @@ class V1SyncableTest {
3940
private lateinit var validator: IndexValidator
4041
private lateinit var repo: Repo
4142

42-
/**
43-
* In this particular test 1 package is removed and 36 packages are updated
44-
*/
45-
4643
@Before
4744
fun before() {
4845
context = InstrumentationRegistry.getInstrumentation().context
4946
dispatcher = StandardTestDispatcher()
50-
validator = FakeIndexValidator
47+
validator = IndexJarValidator(dispatcher)
5148
parser = V1Parser(dispatcher, JsonParser.parser, validator)
5249
v2Parser = V2Parser(dispatcher, JsonParser.parser)
5350
syncable = V1Syncable(context, FakeDownloader, dispatcher)
@@ -56,35 +53,56 @@ class V1SyncableTest {
5653

5754
@Test
5855
fun benchmark_sync_v1() = runTest(dispatcher) {
59-
memory(10) {
56+
val output = memory(10) {
6057
measureTimeMillis { syncable.sync(repo) }
6158
}
59+
println(output)
6260
}
6361

64-
6562
@Test
6663
fun benchmark_v1_parser() = runTest(dispatcher) {
67-
memory(10) {
64+
val file = FakeDownloader.downloadIndex(context, repo, "izzy", "index-v1.jar")
65+
val output = memory(10) {
6866
measureTimeMillis {
6967
parser.parse(
70-
file = FakeDownloader.downloadIndex(
71-
context = context,
72-
repo = repo,
73-
fileName = "izzy",
74-
url = "index-v1.jar"
75-
),
68+
file = file,
7669
repo = repo
7770
)
7871
}
7972
}
73+
println(output)
74+
}
75+
76+
@Test
77+
fun benchmark_v1_vs_v2_parser() = runTest(dispatcher) {
78+
val v1File = FakeDownloader.downloadIndex(context, repo, "izzy-v1", "index-v1.jar")
79+
val v2File = FakeDownloader.downloadIndex(context, repo, "izzy-v2", "index-v2.json")
80+
val output1 = memory(10) {
81+
measureTimeMillis {
82+
parser.parse(
83+
file = v1File,
84+
repo = repo
85+
)
86+
}
87+
}
88+
val output2 = memory(10) {
89+
measureTimeMillis {
90+
v2Parser.parse(
91+
file = v2File,
92+
repo = repo,
93+
)
94+
}
95+
}
96+
println(output1)
97+
println(output2)
8098
}
8199

82100
@Test
83101
fun v1tov2() = runTest(dispatcher) {
84102
testIndexConversion("index-v1.jar", "index-v2-updated.json")
85103
}
86104

87-
// @Test
105+
// @Test
88106
fun v1tov2FDroidRepo() = runTest(dispatcher) {
89107
testIndexConversion("fdroid-index-v1.jar", "fdroid-index-v2.json")
90108
}

sync/fdroid/src/androidTest/kotlin/com/looker/sync/fdroid/common/Benchmark.kt

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal inline fun memory(
77
repetition: Int,
88
extraMessage: String? = null,
99
block: () -> Long,
10-
) {
10+
): String {
1111
if (extraMessage != null) {
1212
println("=".repeat(50))
1313
println(extraMessage)
@@ -20,11 +20,16 @@ internal inline fun memory(
2020
times[iteration] = block().toDouble()
2121
}
2222
val meanAndDeviation = times.culledMeanAndDeviation()
23-
println("=".repeat(50))
24-
println(times.joinToString(" | "))
25-
println("${meanAndDeviation.first} ms ± ${meanAndDeviation.second.toFloat()} ms")
26-
println("=".repeat(50))
27-
println()
23+
return buildString {
24+
append("=".repeat(50))
25+
append("\n")
26+
append(times.joinToString(" | "))
27+
append("\n")
28+
append("${meanAndDeviation.first} ms ± ${meanAndDeviation.second.toFloat()} ms")
29+
append("\n")
30+
append("=".repeat(50))
31+
append("\n")
32+
}
2833
}
2934

3035
private fun DoubleArray.culledMeanAndDeviation(): Pair<Double, Double> {

sync/fdroid/src/main/kotlin/com/looker/sync/fdroid/v1/model/AppV1.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.looker.sync.fdroid.v1.model
22

3+
/*
4+
* AppV1 is licensed under the GPL 3.0 to FDroid Organization.
5+
* */
6+
37
import kotlinx.serialization.Serializable
48

59
@Serializable

sync/fdroid/src/main/kotlin/com/looker/sync/fdroid/v1/model/IndexV1.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.looker.sync.fdroid.v1.model
22

3+
/*
4+
* IndexV1 is licensed under the GPL 3.0 to FDroid Organization.
5+
* */
6+
37
import kotlinx.serialization.Serializable
48

59
@Serializable

sync/fdroid/src/main/kotlin/com/looker/sync/fdroid/v1/model/Localized.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.looker.sync.fdroid.v1.model
22

3+
/*
4+
* Localized is licensed under the GPL 3.0 to FDroid Organization.
5+
* */
6+
37
import kotlinx.serialization.Serializable
48

59
@Serializable

sync/fdroid/src/main/kotlin/com/looker/sync/fdroid/v1/model/PackageV1.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.looker.sync.fdroid.v1.model
22

3+
/*
4+
* PackageV1, PermissionV1 are licensed under the GPL 3.0 to FDroid Organization.
5+
* */
6+
37
import kotlinx.serialization.KSerializer
48
import kotlinx.serialization.SerialName
59
import kotlinx.serialization.Serializable

0 commit comments

Comments
 (0)