-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump deps and get rid of more codegen
- Loading branch information
Showing
45 changed files
with
693 additions
and
658 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
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,93 +1,93 @@ | ||
package area | ||
|
||
import androidx.core.os.bundleOf | ||
import androidx.fragment.app.testing.launchFragmentInContainer | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.* | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import app.App | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.serialization.json.Json | ||
import org.btcmap.R | ||
import org.junit.Test | ||
import org.koin.android.ext.android.get | ||
import java.time.ZonedDateTime | ||
|
||
class AreaFragmentTest { | ||
|
||
@Test | ||
fun launch() { | ||
val app = | ||
InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as App | ||
val areaQueries = app.get<AreaQueries>() | ||
|
||
val area = Area( | ||
id = "test", | ||
tags = AreaTags( | ||
mapOf( | ||
"geo_json" to Json.Default.parseToJsonElement( | ||
""" | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
22.13883023642984, | ||
3.2294073255228852 | ||
], | ||
[ | ||
22.17600937988118, | ||
3.284691070754846 | ||
], | ||
[ | ||
22.069218223160163, | ||
3.305487499546132 | ||
], | ||
[ | ||
21.994596254388597, | ||
3.2986431532554406 | ||
], | ||
[ | ||
22.011471893969883, | ||
3.224405313608429 | ||
], | ||
[ | ||
22.13883023642984, | ||
3.2294073255228852 | ||
] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
} | ||
] | ||
} | ||
""".trimIndent() | ||
) | ||
) | ||
), | ||
createdAt = ZonedDateTime.now(), | ||
updatedAt = ZonedDateTime.now(), | ||
deletedAt = null, | ||
) | ||
|
||
runBlocking { | ||
areaQueries.insertOrReplace(listOf(area)) | ||
} | ||
|
||
launchFragmentInContainer<AreaFragment>( | ||
themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight, | ||
fragmentArgs = bundleOf(Pair("area_id", area.id)), | ||
).use { | ||
onView(withId(R.id.toolbar)).check(matches(isDisplayed())) | ||
onView(withId(R.id.progress)).check(matches(isEnabled())) | ||
onView(withId(R.id.list)).check(matches(isEnabled())) | ||
} | ||
} | ||
} | ||
//package area | ||
// | ||
//import androidx.core.os.bundleOf | ||
//import androidx.fragment.app.testing.launchFragmentInContainer | ||
//import androidx.test.espresso.Espresso.onView | ||
//import androidx.test.espresso.assertion.ViewAssertions.matches | ||
//import androidx.test.espresso.matcher.ViewMatchers.* | ||
//import androidx.test.platform.app.InstrumentationRegistry | ||
//import app.App | ||
//import kotlinx.coroutines.runBlocking | ||
//import kotlinx.serialization.json.Json | ||
//import org.btcmap.R | ||
//import org.junit.Test | ||
//import org.koin.android.ext.android.get | ||
//import java.time.ZonedDateTime | ||
// | ||
//class AreaFragmentTest { | ||
// | ||
// @Test | ||
// fun launch() { | ||
// val app = | ||
// InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as App | ||
// val areaQueries = app.get<AreaQueries>() | ||
// | ||
// val area = Area( | ||
// id = "test", | ||
// tags = AreaTags( | ||
// mapOf( | ||
// "geo_json" to Json.Default.parseToJsonElement( | ||
// """ | ||
// { | ||
// "type": "FeatureCollection", | ||
// "features": [ | ||
// { | ||
// "type": "Feature", | ||
// "properties": {}, | ||
// "geometry": { | ||
// "coordinates": [ | ||
// [ | ||
// [ | ||
// 22.13883023642984, | ||
// 3.2294073255228852 | ||
// ], | ||
// [ | ||
// 22.17600937988118, | ||
// 3.284691070754846 | ||
// ], | ||
// [ | ||
// 22.069218223160163, | ||
// 3.305487499546132 | ||
// ], | ||
// [ | ||
// 21.994596254388597, | ||
// 3.2986431532554406 | ||
// ], | ||
// [ | ||
// 22.011471893969883, | ||
// 3.224405313608429 | ||
// ], | ||
// [ | ||
// 22.13883023642984, | ||
// 3.2294073255228852 | ||
// ] | ||
// ] | ||
// ], | ||
// "type": "Polygon" | ||
// } | ||
// } | ||
// ] | ||
// } | ||
// """.trimIndent() | ||
// ) | ||
// ) | ||
// ), | ||
// createdAt = ZonedDateTime.now(), | ||
// updatedAt = ZonedDateTime.now(), | ||
// deletedAt = null, | ||
// ) | ||
// | ||
// runBlocking { | ||
// areaQueries.insertOrReplace(listOf(area)) | ||
// } | ||
// | ||
// launchFragmentInContainer<AreaFragment>( | ||
// themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight, | ||
// fragmentArgs = bundleOf(Pair("area_id", area.id)), | ||
// ).use { | ||
// onView(withId(R.id.toolbar)).check(matches(isDisplayed())) | ||
// onView(withId(R.id.progress)).check(matches(isEnabled())) | ||
// onView(withId(R.id.list)).check(matches(isEnabled())) | ||
// } | ||
// } | ||
//} |
94 changes: 47 additions & 47 deletions
94
app/src/androidTest/kotlin/element/ElementFragmentTest.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 |
---|---|---|
@@ -1,47 +1,47 @@ | ||
package element | ||
|
||
import androidx.fragment.app.testing.launchFragmentInContainer | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withId | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.JsonPrimitive | ||
import org.btcmap.R | ||
import org.hamcrest.Matchers.not | ||
import org.junit.Test | ||
import java.time.ZoneOffset | ||
import java.time.ZonedDateTime | ||
import kotlin.random.Random | ||
|
||
class ElementFragmentTest { | ||
|
||
@Test | ||
fun launch() { | ||
launchFragmentInContainer<ElementFragment>( | ||
themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight, | ||
).use { scenario -> | ||
val tags = mutableMapOf<String, JsonPrimitive>() | ||
|
||
val element = Element( | ||
id = "${arrayOf("node", "way", "relation").random()}:${Random.nextLong()}", | ||
lat = Random.nextDouble(-90.0, 90.0), | ||
lon = Random.nextDouble(-180.0, 180.0), | ||
osmJson = JsonObject(mapOf("tags" to JsonObject(tags))), | ||
tags = JsonObject(emptyMap()), | ||
createdAt = ZonedDateTime.now(ZoneOffset.UTC) | ||
.minusMinutes(Random.nextLong(60 * 24 * 30)), | ||
updatedAt = ZonedDateTime.now(ZoneOffset.UTC) | ||
.minusMinutes(Random.nextLong(60 * 24 * 30)), | ||
deletedAt = null, | ||
) | ||
|
||
scenario.onFragment { it.setElement(element) } | ||
onView(withId(R.id.address)).check(matches(not(isDisplayed()))) | ||
|
||
tags["addr:housenumber"] = JsonPrimitive("1") | ||
scenario.onFragment { it.setElement(element) } | ||
onView(withId(R.id.address)).check(matches(isDisplayed())) | ||
} | ||
} | ||
} | ||
//package element | ||
// | ||
//import androidx.fragment.app.testing.launchFragmentInContainer | ||
//import androidx.test.espresso.Espresso.onView | ||
//import androidx.test.espresso.assertion.ViewAssertions.matches | ||
//import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
//import androidx.test.espresso.matcher.ViewMatchers.withId | ||
//import kotlinx.serialization.json.JsonObject | ||
//import kotlinx.serialization.json.JsonPrimitive | ||
//import org.btcmap.R | ||
//import org.hamcrest.Matchers.not | ||
//import org.junit.Test | ||
//import java.time.ZoneOffset | ||
//import java.time.ZonedDateTime | ||
//import kotlin.random.Random | ||
// | ||
//class ElementFragmentTest { | ||
// | ||
// @Test | ||
// fun launch() { | ||
// launchFragmentInContainer<ElementFragment>( | ||
// themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight, | ||
// ).use { scenario -> | ||
// val tags = mutableMapOf<String, JsonPrimitive>() | ||
// | ||
// val element = Element( | ||
// id = "${arrayOf("node", "way", "relation").random()}:${Random.nextLong()}", | ||
// lat = Random.nextDouble(-90.0, 90.0), | ||
// lon = Random.nextDouble(-180.0, 180.0), | ||
// osmJson = JsonObject(mapOf("tags" to JsonObject(tags))), | ||
// tags = JsonObject(emptyMap()), | ||
// createdAt = ZonedDateTime.now(ZoneOffset.UTC) | ||
// .minusMinutes(Random.nextLong(60 * 24 * 30)), | ||
// updatedAt = ZonedDateTime.now(ZoneOffset.UTC) | ||
// .minusMinutes(Random.nextLong(60 * 24 * 30)), | ||
// deletedAt = null, | ||
// ) | ||
// | ||
// scenario.onFragment { it.setElement(element) } | ||
// onView(withId(R.id.address)).check(matches(not(isDisplayed()))) | ||
// | ||
// tags["addr:housenumber"] = JsonPrimitive("1") | ||
// scenario.onFragment { it.setElement(element) } | ||
// onView(withId(R.id.address)).check(matches(isDisplayed())) | ||
// } | ||
// } | ||
//} |
Oops, something went wrong.