forked from umontreal-diro/Makelangelo-software
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
189710d
commit 4e7f89a
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/com/marginallyclever/makelangelo/CollapsiblePanelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.marginallyclever.makelangelo; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class CollapsiblePanelTest { | ||
|
||
private CollapsiblePanel collapsiblePanel; | ||
private JFrame testFrame; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
testFrame = new JFrame(); | ||
collapsiblePanel = new CollapsiblePanel(testFrame, "Test Panel", 400, true); | ||
} | ||
|
||
|
||
@Test | ||
void testAddComponent() { | ||
JButton testButton = new JButton("Test Button"); | ||
collapsiblePanel.add(testButton); | ||
assertEquals(1, collapsiblePanel.getComponentCount(), "There should be one component in the panel."); | ||
assertFalse(testButton.isVisible(), "The component should be hidden by default."); | ||
} | ||
|
||
@Test | ||
void testToggleVisibility() { | ||
JButton testButton = new JButton("Test Button"); | ||
collapsiblePanel.add(testButton); | ||
|
||
// Simulate click to expand | ||
collapsiblePanel.toggleVisibility(true); | ||
assertTrue(testButton.isVisible(), "The button should be visible after expanding."); | ||
|
||
// Simulate click to collapse | ||
collapsiblePanel.toggleVisibility(false); | ||
assertFalse(testButton.isVisible(), "The button should be hidden after collapsing."); | ||
} | ||
|
||
@Test | ||
void testSetTitle() { | ||
collapsiblePanel.setTitle("New Title"); | ||
assertEquals("New Title", collapsiblePanel.getTitle(), "The title should be updated."); | ||
} | ||
} |