Skip to content

nsgotest: StatusBarConfig drops Immersive, so tests cannot see mobile.Immersive or a layer's StatusBar.Immersive #2255

Done

Description

@houko

Context

#1124 (landed in #1141, HarmonyOS in #2014) added immersive full screen: mobile.Immersive(cx, on) (mobile/mobile.go:68-75) patches core.StatusBarSetting{Immersive: ...}, and a screen or modal can set StatusBar: core.StatusBarSetting{Immersive: core.ToggleOn} (docs/public/en/navigation.md:42-44). The core resolves the layers into driver.StatusBarConfig, which carries Immersive (core/statusbar.go:52), and sends it as a driver.ItemStatusBar mount item (core/statusbar.go:133-137).

nsgotest drops that field. nsgotest.StatusBarConfig has only Style, Hidden and Animated (nsgotest/surface_records.go:78-83), and the model copies the mount item without it:

case driver.ItemStatusBar:
	a.StatusBar = StatusBarConfig{Style: it.StatusBar.Style, Hidden: it.StatusBar.Hidden, Animated: it.StatusBar.Animated}

(nsgotest/model.go:1146-1147). App.StatusBar ("the status bar the app last set", nsgotest/nsgotest.go:528-529) is the only place a test can read the resolved status bar.

Why it matters

A test cannot check that an app asked for immersive full screen, or that it returned to the regular bars. Calling mobile.Immersive(cx, true) and then mobile.Immersive(cx, false) records the same StatusBarConfig{Style: StatusBarAuto} both times, so a test sees no difference between a game in full screen and one that never asked. The same holds for a screen or modal whose StatusBar sets Immersive, and for TSX's statusBar={{ immersive: true }}, so the layering rules (a shown screen overriding the window default, the setting ending when the modal closes) are untestable without a device or emulator.

A game layer built on NSGo (nsgo-dev/game) turns immersive mode on while a level plays and off on its pause and menu screens; it wants to assert that switch in nsgo test the way it already asserts Hidden and Style.

Proposal

Add Immersive bool to nsgotest.StatusBarConfig and copy it.StatusBar.Immersive in the driver.ItemStatusBar case of nsgotest/model.go. The field documents the same resolved value the platform hosts receive.

Acceptance

  • nsgotest.StatusBarConfig has an Immersive field, and App.StatusBar.Immersive is true after mobile.Immersive(cx, true) and false after mobile.Immersive(cx, false).
  • A screen or modal whose StatusBar sets Immersive: core.ToggleOn reports Immersive while it is shown, and the window's setting comes back when it closes.
  • An nsgotest test covers both cases, and docs/public/en/testing.md and docs/public/zh mention the field if the testing docs list StatusBar's fields.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions