Fix recycler view test (#3537)

This commit is contained in:
Adrian Cojocaru
2025-06-07 20:00:38 +03:00
committed by GitHub
parent b0e2e2ce85
commit 6704f0f80a
13 changed files with 42 additions and 30 deletions

View File

@@ -9,10 +9,10 @@ import org.junit.Test
import org.junit.runner.RunWith
/**
* Regression test that validates reopening an Activity with a GLSurfaceView
* Regression test that validates reopening an Activity with a SurfaceView
*/
@RunWith(AndroidJUnit4ClassRunner::class)
class GLSurfaceViewReopenTest : BaseIntegrationTest() {
class SurfaceViewReopenTest : BaseIntegrationTest() {
@get:Rule
var activityRule: ActivityTestRule<SimpleMapActivity> = ActivityTestRule(SimpleMapActivity::class.java)

View File

@@ -3,19 +3,19 @@ package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import org.maplibre.android.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import org.maplibre.android.testapp.activity.maplayout.SurfaceRecyclerViewActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
/**
* Regression test that validates if a GLSurfaceView surface can be recreated without crashing.
* Regression test that validates if a SurfaceView surface can be recreated without crashing.
*/
@RunWith(AndroidJUnit4ClassRunner::class)
class GLSurfaceViewReuseTest : BaseIntegrationTest() {
class SurfaceViewReuseTest : BaseIntegrationTest() {
@get:Rule
var activityRule: ActivityTestRule<GLSurfaceRecyclerViewActivity> = ActivityTestRule(GLSurfaceRecyclerViewActivity::class.java)
var activityRule: ActivityTestRule<SurfaceRecyclerViewActivity> = ActivityTestRule(SurfaceRecyclerViewActivity::class.java)
@Test
@LargeTest

View File

@@ -1129,10 +1129,10 @@
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
android:name=".activity.maplayout.GLSurfaceRecyclerViewActivity"
android:description="@string/description_recyclerview_glsurfaceview"
android:name=".activity.maplayout.SurfaceRecyclerViewActivity"
android:description="@string/description_recyclerview_surfaceview"
android:exported="true"
android:label="@string/activity_recyclerview_glsurfaceview">
android:label="@string/activity_recyclerview_surfaceview">
<meta-data
android:name="@string/category"
android:value="@string/category_integration" />

View File

@@ -9,16 +9,17 @@ import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.maps.MapView
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityRecyclerviewBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* TestActivity showcasing how to integrate multiple GLSurfaceView MapViews in a RecyclerView.
* TestActivity showcasing how to integrate multiple SurfaceView MapViews in a RecyclerView.
* <p>
* It requires calling the correct lifecycle methods when detaching and attaching the View to
* the RecyclerView with onViewAttachedToWindow and onViewDetachedFromWindow.
* </p>
*/
@SuppressLint("ClickableViewAccessibility")
open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
open class SurfaceRecyclerViewActivity : AppCompatActivity() {
lateinit var binding: ActivityRecyclerviewBinding
@@ -46,12 +47,12 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
return R.layout.item_map_gl
}
class ItemAdapter(private val activity: GLSurfaceRecyclerViewActivity, private val inflater: LayoutInflater) : androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>() {
class ItemAdapter(private val activity: SurfaceRecyclerViewActivity, private val inflater: LayoutInflater) : androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>() {
private val items: List<Any> = listOf(
"one", "two", "three", "four", "five", "seven", "eight", "nine", "ten",
"one", "two", "three", MapItem(TestStyles.DEMOTILES), "four", "five", MapItem(TestStyles.DEMOTILES), "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", "twenty-one"
"nineteen", "twenty", "twenty-one",
)
private var mapHolders: MutableList<MapHolder> = mutableListOf()

View File

@@ -7,7 +7,7 @@ import org.maplibre.android.testapp.R
* TestActivity showcasing how to integrate multiple TexureView MapViews in a RecyclerView.
*/
@SuppressLint("ClickableViewAccessibility")
class TextureRecyclerViewActivity : GLSurfaceRecyclerViewActivity() {
class TextureRecyclerViewActivity : SurfaceRecyclerViewActivity() {
override fun getMapItemLayoutId(): Int {
return R.layout.item_map_texture

View File

@@ -95,7 +95,7 @@
<string name="description_location_manual">Force location updates and don\'t rely on the engine</string>
<string name="description_location_activation_builder">Use LocationComponentActivationOptions to set options</string>
<string name="description_recyclerview_textureview">Show multiple TextureView MapViews as recyclerView items</string>
<string name="description_recyclerview_glsurfaceview">Show multiple GLSurfaceView MapViews as recyclerView items</string>
<string name="description_recyclerview_surfaceview">Show multiple SurfaceView MapViews as recyclerView items</string>
<string name="description_nested_viewpager">Show a MapView inside a viewpager inside a recyclerView</string>
<string name="description_performance_measurement">Show the use PerformanceEvent for performance measurements</string>
<string name="description_physical_circle">Use TurfTransformation#circle() to show a Cirlce expressed in physical units</string>

View File

@@ -91,7 +91,7 @@
<string name="activity_location_manual">Manual Location updates</string>
<string name="activity_location_activation_builder">Build Location Activation</string>
<string name="activity_recyclerview_textureview">RecyclerView TextureView</string>
<string name="activity_recyclerview_glsurfaceview">RecyclerView GLSurfaceView</string>
<string name="activity_recyclerview_surfaceview">RecyclerView SurfaceView</string>
<string name="activity_nested_viewpager">Nested ViewPager</string>
<string name="activity_performance_measurement">Performance Measurement</string>
<string name="activity_physical_circle">Physical Unit Circle</string>