Testing: LoadingDisplay - UQcsse3200/2024-studio-2 GitHub Wiki

LoadingDisplayTest

This test class is focused on verifying the behavior and functionality of the LoadingDisplay component. The LoadingDisplay manages the game's loading screen, showing progress through visual elements like the MoonActor and text messages, while interacting with various game services.

The tests make use of mocked services such as ResourceService, RenderService, and Stage to simulate how the LoadingDisplay would function in a real game environment. Here’s a breakdown of what each test is intended to do:

Test Cases:

Test Case 1: Display current loading messages from predefined list

  • Objective: Verify that the current loading message displayed is one of the valid predefined messages.
  • Test Case ID: TC-1
  • Description: Ensure that each time the LoadingDisplay updates, the message displayed is part of the predefined list of loading messages.
  • Preconditions: The LoadingDisplay has been initialized, and the list of messages is available.
  • Steps:
    1. Start the LoadingDisplay.
    2. Call the update() method.
    3. Get the current loading message.
  • Expected Result: The current message should always be one of the predefined loading messages.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 2: Moon progress is updated after time elapses

  • Objective: Verify that the progress displayed by the moon actor updates correctly based on elapsed time.
  • Test Case ID: TC-2
  • Description: As time progresses, the moon actor should update its progress in proportion to the total loading time.
  • Preconditions: The LoadingDisplay is updating, and time progresses.
  • Steps:
    1. Start the LoadingDisplay.
    2. Simulate several seconds of time passing by calling update() multiple times.
    3. Observe the moon actor’s progress.
  • Expected Result: After 3 seconds, the moon actor's progress should be at 50% of the total.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 3: Finish loading after a specific duration

  • Objective: Verify that the loading process completes after a designated amount of time has passed.
  • Test Case ID: TC-3
  • Description: Ensure that after simulating several seconds of game updates, the LoadingDisplay completes loading.
  • Preconditions: The LoadingDisplay is updating and time is simulated.
  • Steps:
    1. Start the LoadingDisplay.
    2. Simulate 6 seconds of time passing with update().
  • Expected Result: After 6 seconds, the LoadingDisplay should indicate that loading is finished.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 4: Moon actor opacity and blending

  • Objective: Verify that the moon actor’s opacity can be set and correctly blended into the background.
  • Test Case ID: TC-4
  • Description: Ensure that setting the moon actor’s opacity reflects correctly in the rendering.
  • Preconditions: The LoadingDisplay is running, and the moon actor is added to the stage.
  • Steps:
    1. Start the LoadingDisplay.
    2. Set the opacity of the moon actor.
    3. Observe the moon actor's opacity in the rendered output.
  • Expected Result: The moon actor should have the correct opacity and blend into the stage background.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 5: Display all loading messages over time

  • Objective: Ensure that all predefined loading messages are displayed over time during the loading process.
  • Test Case ID: TC-5
  • Description: As time passes, the loading display should cycle through and show all available messages at least once.
  • Preconditions: The LoadingDisplay is updating over time.
  • Steps:
    1. Start the LoadingDisplay.
    2. Simulate enough updates to display all loading messages.
  • Expected Result: All predefined loading messages should be displayed at least once.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 6: Ensure moon progress does not exceed 100%

  • Objective: Verify that the moon actor's progress bar never exceeds 100%.
  • Test Case ID: TC-6
  • Description: Even if time progresses beyond the total loading duration, the moon actor’s progress should be capped at full (100%).
  • Preconditions: The LoadingDisplay is updating and resource loading progress is at 100%.
  • Steps:
    1. Start the LoadingDisplay.
    2. Simulate more time than the total loading time.
  • Expected Result: The moon actor’s progress should not exceed 100%.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 7: Start with zero progress

  • Objective: Verify that the moon actor's progress starts at 0% when loading begins.
  • Test Case ID: TC-7
  • Description: When the loading screen first appears, the moon actor's progress should start at 0%.
  • Preconditions: The LoadingDisplay has just started and the resource progress is 0%.
  • Steps:
    1. Start the LoadingDisplay.
    2. Check the initial progress of the moon actor.
  • Expected Result: The moon actor’s progress should start at 0%.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 8: Moon actor should display full when progress is complete

  • Objective: Ensure that the moon actor displays full progress when resource loading is complete.
  • Test Case ID: TC-8
  • Description: When the resource loading progress reaches 100%, the moon actor should display full progress.
  • Preconditions: The resource loading progress has reached 100%.
  • Steps:
    1. Simulate full progress (100%) in the LoadingDisplay.
    2. Observe the moon actor’s progress.
  • Expected Result: The moon actor should display 100% progress.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 9: Clamp moon progress at 0% and 100%

  • Objective: Ensure that the moon actor’s progress is clamped between 0% and 100%.
  • Test Case ID: TC-9
  • Description: The moon actor’s progress should not drop below 0% or exceed 100%.
  • Preconditions: The moon actor's progress is being set manually.
  • Steps:
    1. Set the moon actor’s progress to a negative value.
    2. Set the moon actor’s progress to a value greater than 100%.
    3. Observe the clamping behavior.
  • Expected Result: The moon actor's progress should be clamped at 0% and 100% respectively.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.

Test Case 10: Clamp moon opacity between 0 and 1

  • Objective: Ensure that the moon actor’s opacity is clamped between 0 and 1.
  • Test Case ID: TC-10
  • Description: The opacity of the moon actor should not drop below 0 or exceed 1.
  • Preconditions: The moon actor’s opacity is being set manually.
  • Steps:
    1. Set the moon actor's opacity to a value below 0.
    2. Set the moon actor's opacity to a value above 1.
    3. Observe the clamping behavior.
  • Expected Result: The moon actor's opacity should be clamped between 0 and 1.
  • Actual Result: [after testing].
  • Status: [Pass/Fail].
  • Other Method: Unit Testing.