Test Plan for TextDisplay.java - UQcsse3200/2024-studio-3 GitHub Wiki
Test environment
Framework: JUnit 5
Dependencies:
TextDisplay: The main class under test.
Image, Label: Allows the image and text to be drawn to the screen
Stack, Table: Allows the label to be stacked on the image and position the elements in the right place
UI Component: the component which allows the text display to be drawn to the screen continuously
Test cases
Test Case 1: Text Display Initialization
Description: Verify that the TextDisplay initializes correctly with the necessary components and that it is invisible by default.
Preconditions: None.
Steps: Create an instance of TextDisplay. Call the create() method to set up the display components. Check that the visible property is false.
Expected Result: TextDisplay should initialize and be invisible.
Test Case 2: Set Text and Text Splitting
Description: Verify that setText correctly splits text into parts based on the textLimit.
Preconditions: Test Case 1 is runs with no errors
Steps: Call setText("This is a long sentence that should be split correctly"). Retrieve the split text using getText(). Expected Result: The text should be split into parts, where each part contains a maximum of 60 characters.
Test Case 3: Update Text Display (Typewriter Effect)
Description: Verify that the text is progressively displayed character by character with the typewriter effect.
Preconditions: Test Case 1 is runs with no errors, and setText has been called.
Steps: Call update() repeatedly, simulating time passing to trigger character updates. After a few updates, check the label text.
Expected Result: Characters from the first part of the text should be progressively displayed on the label.
Test Case 4: Text Visibility on Enter Key
Description: Verify that pressing the ENTER key correctly advances the displayed text and hides the display when all text parts are shown.
Preconditions: TextDisplay has been initialized, and multiple parts of text have been set.
Steps: Simulate pressing the ENTER key after all characters of the current part are displayed. Repeat until the last part is shown. Press ENTER after the final part is displayed.
Expected Result: The display should hide after the final part of the text is shown.
Test Case 5: Verify setVisible Method
Description: Verify that calling setVisible(true) or setVisible(false) correctly shows or hides the text display.
Preconditions: Test Case 1 is runs with no errors
Steps: Call setVisible(true) and check if the display is visible. Call setVisible(false) and check if the display is hidden.
Expected Result: The display should show or hide based on the method's parameter.
Test Case 6: Boundary Test for Empty Text
Description: Verify that setting an empty text string does not cause any errors and behaves as expected.
Preconditions: Test Case 1 is runs with no errors
Steps: Call setText(""). Check the contents of the text array.
Expected Result: The text array should be empty, and no crash should occur.