adventuregamestudio / ags-test-games

Games for automatic tests
MIT License
1 stars 3 forks source link

Cursor tests #13

Open ivan-mogilko opened 2 months ago

ivan-mogilko commented 2 months ago

Need cursor tests, using screenshot method to compare the graphic and graphical position.

Something like:

  1. Having a default graphic, test that the position matches mouse.x, mouse.y. Move cursor around with Mouse.SetPosition and assert that cursor position changes.
  2. Mode switch resulting in graphic change.
  3. Changing graphic by script command.
  4. Assigning a view (Mouse.ChangeModeView) and asserting that it changes animation frames over time (short animation to reduce test time).
  5. Specific test: ensure that cursor is drawn after a room change. Perhaps this suits for "Engine Render" tests more than for the "cursor" tests. Idea is that the engine might drop parts of the object caches on a room change, and so this test will assert that cursor got correctly recreated afterwards.
ivan-mogilko commented 5 days ago

Special cursor case is inventory cursor that has extra hotspot gfx drawn upon it. Currently this is implemented by creating a temporary bitmap and combining 2 images on it. Because of such approach, this cursor image does not have a matching sprite number. When player cycles cursors with active inventory on, the cursor texture has to be updated between sprites that have an identifying number and one that does not. This is a special case that has to be tested too.

Recently there was a bug, which caused engine to paint this temporary cursor bitmap over other cached cursor textures, if their size matched, because it did not realize that previous texture has a identifier (so it's associated with a persistent sprite) while new sprite does not (so it's a temporary generated image).

Of course, it's also possible to change this implementation in the engine, maybe allocating this inventory cursor as a dynamic sprite with a number. But it's still proper to have a test.