Test Plan for Station Progress Display - UQcsse3200/2024-studio-3 GitHub Wiki

1. Introduction

This test plan outlines the test cases for the StationProgressDisplay class. The StationProgressDisplay is responsible for creating and managing the visual representation of a progress bar for stations in the game, indicating the chop/cook percentage of items held in the station.

2. Test Objectives

  • Verify the correct initialization of the StationProgressDisplay
  • Ensure proper creation and management of UI elements
  • Test the updating of the display based on different item states and components
  • Verify the correct drawing of the progress bar
  • Test the proper disposal of resources
  • Verify edge cases and error handling

3. Test Cases

3.1 Initialization Tests

3.1.1 Correct Initialization

  • Test Method: testCreate()
  • Objective: Verify that the StationProgressDisplay initializes correctly with all required components.
  • Expected Result: The component should initialize with correct textures, position, scale, and initial values for barPercentage and displayBar.

3.2 Update Tests

3.2.1 Update with No Item

  • Test Method: testUpdate_NoItem()
  • Objective: Ensure that the display is reset when there is no item in the station.
  • Expected Result: The barPercentage should be reset to 0.0f and displayBar should be false.

3.2.2 Update with ChopIngredientComponent (Incomplete)

  • Test Method: testUpdate_WithChopIngredientComponent_Incomplete()
  • Objective: Verify correct update when an item with an incomplete ChopIngredientComponent is present.
  • Expected Result: The barPercentage should reflect the completion percentage and displayBar should be true.

3.2.3 Update with ChopIngredientComponent (Complete)

  • Test Method: testUpdate_WithChopIngredientComponent_Complete()
  • Objective: Verify correct update when an item with a complete ChopIngredientComponent is present.
  • Expected Result: The barPercentage should be 1.0f, displayBar should be false, and the updateInventory event should be triggered.

3.2.4 Update with CookIngredientComponent (Incomplete)

  • Test Method: testUpdate_WithCookIngredientComponent_Incomplete()
  • Objective: Verify correct update when an item with an incomplete CookIngredientComponent is present.
  • Expected Result: The barPercentage should reflect the completion percentage and displayBar should be true.

3.2.5 Update with CookIngredientComponent (Complete and Still Cooking)

  • Test Method: testUpdate_WithCookIngredientComponent_CompleteCooking()
  • Objective: Verify correct update when an item is fully cooked but still in the cooking state.
  • Expected Result: The barPercentage should be 1.0f and displayBar should be true.

3.2.6 Update with Item Without Relevant Components

  • Test Method: testUpdate_ItemWithoutRelevantComponents()
  • Objective: Verify correct update when an item without ChopIngredientComponent or CookIngredientComponent is present.
  • Expected Result: The barPercentage should be reset to 0.0f and displayBar should be false.

3.3 Drawing Tests

3.3.1 Draw with Display Bar

  • Test Method: testDraw_DisplayBar()
  • Objective: Ensure that the progress bar is correctly drawn when it should be displayed.
  • Expected Result: The SpriteBatch.draw method should be called with correct parameters for both bar outline and fill.

3.3.2 Draw without Display Bar

  • Test Method: testDraw_NoDisplayBar()
  • Objective: Verify that nothing is drawn when the display bar should not be shown.
  • Expected Result: The SpriteBatch.draw method should not be called.

3.4 Resource Management Tests

3.4.1 Proper Disposal

  • Test Method: testDispose()
  • Objective: Ensure that all resources are properly disposed of when the component is disposed.
  • Expected Result: All textures should be disposed and the component should be unregistered from the RenderService.

3.5 Utility Method Tests

3.5.1 Get Layer

  • Test Method: testGetLayer()
  • Objective: Verify that the correct rendering layer is returned.
  • Expected Result: The method should return 3.

3.5.2 Set Stage

  • Test Method: testSetStage()
  • Objective: Ensure that the setStage method doesn't throw any exceptions.
  • Expected Result: The method should complete without throwing any exceptions.

4. Test Execution

All tests should be executed as part of the test suite in StationProgressDisplayTest.java. The testing framework (JUnit) will report on the success or failure of each test case.

5. Conclusion

This test plan covers the core functionality of the StationProgressDisplay, including initialization, updating based on different item states, drawing, resource management, and utility methods. Successful execution of all test cases will provide confidence in the robustness and correctness of the StationProgressDisplay implementation.