Skip to content

Catch2 tests coverage for MapLayerBaseModel and MapLayerModel#7095

Open
kaustuvpokharel wants to merge 3 commits intomasterfrom
tests/mapLayerModel
Open

Catch2 tests coverage for MapLayerBaseModel and MapLayerModel#7095
kaustuvpokharel wants to merge 3 commits intomasterfrom
tests/mapLayerModel

Conversation

@kaustuvpokharel
Copy link
Collaborator

MapLayerBaseModel tests cover initial state, layer population on setProject, dynamic addition/removal via project signals, all five data roles, invalid index handling, list model parent contract, disabled state ignoring signal-driven changes, the disabled/project-switch/re-enable lifecycle, signal deduplication guards on setEnabled and setProject, and project switching
WHile,
MapLayerModel tests cover default state, alphabetical sorting, all geometry-type filters (PointLayer, LineLayer, PolygonLayer, NoGeometry, HasGeometry combined with PointLayer to reach the detectGeometry branch), filtersChanged signal deduplication, findLayer with valid/null/orphan inputs, get() with valid and invalid rows, disabled state, requiresTrackingAvailability with no TrackingModel, requiresTrackingAvailability with a TrackingModel present but no active tracking, and requiresTrackingAvailabilityChanged signal deduplication

##FIndings

  • WritableLayer filter is not tested, QgsVectorLayer exposes no public setter for read-only state; it is provider driven and cannot be forced from test code using a memory provider
  • Active tracking (Tracker::start) is also not tested here, since it requires a fully initialised QgsApplication stack which is not present in the unit test asofnow and causes a SIGSEGV

@qfield-fairy
Copy link
Collaborator

qfield-fairy commented Mar 1, 2026

🍎 MacOS DMG universal builds

Download a MacOS DMG universal build of this PR for testing.
(Built from commit a9532af)

📱 Android builds

Download an Android arm64 build of this PR for testing.
(Built from commit a9532af)

Other Android architectures

🪟 Windows builds

Download a Windows build of this PR for testing.
(Built from commit a9532af)

🐧 Linux AppImage builds

Download a Linux AppImage build of this PR for testing.
(Built from commit a9532af)

@nirvn
Copy link
Member

nirvn commented Mar 3, 2026

@kaustuvpokharel , you can test the writable filter by tweaking the readOnly property of the layer.

@nirvn
Copy link
Member

nirvn commented Mar 3, 2026

Active tracking (Tracker::start) is also not tested here, since it requires a fully initialised QgsApplication stack which is not present in the unit test asofnow and causes a SIGSEGV

@kaustuvpokharel , you can get that by adding a #define QFIELDTEST_MAIN at the top of your test_*.cpp file (e.g. this https://github.com/opengisch/QField/blob/master/test/test_tracking.cpp#L18 ). If that's done and there is still a crash, the cause is somewhere else.

Copy link
Member

@nirvn nirvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's in there looks good, I've added two comments to guide you to add the missing bits.

@kaustuvpokharel kaustuvpokharel self-assigned this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants