Test Plan for MainGameOrderTicketDisplay - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUnit 5
  • Dependencies:
    • MainGameOrderTicketDisplay: The main class under test.
    • ServiceLocator: Manages the services used in the game.
    • RenderService, DocketService, EventHandler: Mocked services to isolate the class under test.
    • Stage, OrthographicCamera, Viewport: Mocked components of the rendering system.

Test Cases

  1. Initialisation Test
    • Purpose: Verify that MainGameOrderTicketDisplay is properly initialised.
    • Setup:
      • Initialise MainGameOrderTicketDisplay with mocked dependencies (RenderService, DocketService, Stage, Viewport, EventHandler).
      • Simulate the create() method call.
    • Expected Outcome:
      • Lists (tableArrayList, startTimeArrayList, etc.) should be initialised and empty.
      • Event listeners should be registered correctly.
  2. Adding Order Tickets
    • Purpose: Test the addition of order tickets to the display.
    • Setup:
      • Call the addActors() method to simulate adding order tickets.
      • Repeat the process to ensure multiple tickets can be added.
    • Expected Outcome:
      • The tableArrayList should have the correct number of entries after multiple additions.
      • Tables should be added to the stage, and their properties (position, size) should be correct.
  3. Removing Order Tickets
    • Purpose: Ensure that order tickets can be removed from the display.
    • Setup:
      • Add several tickets using addActors().
      • Clear the tableArrayList.
    • Expected Outcome:
      • The tableArrayList should be empty after clearing.
      • No exceptions should be thrown, and resources should be cleaned up correctly.
  4. Default Sizes of Non-Enlarged and Enlarged Dockets
    • Purpose: Ensure that order tickets other than the last one are not enlarged and only one ticket is enlarged.
    • Setup:
      • Add multiple tickets using addActors().
      • Call updateDocketSizes() and inspect each ticket.
    • Expected Outcome:
      • All tickets except the last one should have the default size (120x150 units).
      • Last ticket should have the enlarged size. Both are dynamically calculated via current window viewport values.
  5. Enlargement of Last Docket
    • Purpose: Verify that the last order ticket in the list is enlarged correctly.
    • Setup:
      • Add multiple tickets to the list.
      • Call updateDocketSizes() to trigger the resizing logic.
    • Expected Outcome:
      • The last ticket should be resized to a larger dimension (1.7 times greater than normal docket dimensions).
      • The position of the last ticket should be dynamically adjusted according to the viewport dimensions.
  6. Shifting Dockets Left
    • Purpose: Test the behaviour when shifting the order tickets left.
    • Setup:
      • Add several tickets to the list.
      • Call shiftDocketsLeft() to simulate the shift.
    • Expected Outcome:
      • The first ticket should move to the end of the list.
      • All positions and sizes should be updated correctly.
  7. Shifting Dockets Right
    • Purpose: Test the behaviour when shifting the order tickets right.
    • Setup:
      • Add several tickets to the list.
      • Call shiftDocketsRight() to simulate the shift.
    • Expected Outcome:
      • The last ticket should move to the beginning of the list.
      • All positions and sizes should be updated correctly.
  8. Countdown Timer Update
    • Purpose: Verify that the countdown timer for each order ticket updates correctly.
    • Setup:
      • Add a ticket and simulate time passing using TimeUtils.timeSinceMillis().
      • Call the update() method to trigger the timer logic.
    • Expected Outcome:
      • The timer label for each ticket should update to reflect the remaining time.
      • Tickets should be removed when their timer expires.
  9. Test <meal_name>
    • Purpose: Verify that the meal image doesn't return null and recipe exists.
    • Setup:
      • Set recipe as <meal_name>.
      • Create() and addActors() and get the first value in the table array.
    • Expected Outcome:
      • The table should not return null.
  10. Disposing Resources
    • Purpose: Ensure that all resources are correctly disposed of when the dispose() method is called.
    • Setup:
      • Add several tickets and call the dispose() method.
    • Expected Outcome:
      • All lists should be cleared, and resources (like tables) should be removed from the stage.
      • No memory leaks should remain.

Notes

  • Assumptions:
    • The game environment is properly set up, and the ServiceLocator is correctly registering services.
    • The tests assume that Stage, Viewport, RenderService, and other dependencies are correctly mocked and provide the necessary functionality for the MainGameOrderTicketDisplay class to operate.
  • Error Handling:
    • The test plan covers cases where no tickets are present to shift (left or right) and checks that appropriate warnings are logged without exceptions being thrown.
  • Visual Testing:
    • It should also be noted that testing was also conducted visually throughout the implementation process, as much of our feature is UI-based.

The following video demonstrates the resizing functionality of dockets and meal images.

docket_and_meal_image_resize.mov
⚠️ **GitHub.com Fallback** ⚠️