Skip to content

Commit

Permalink
chore: add DockingDesktopTest
Browse files Browse the repository at this point in the history
  • Loading branch information
miurahr committed Sep 24, 2024
1 parent cda6260 commit a935fdd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.vlsolutions.swing.docking;

import com.vlsolutions.swing.TestBase;
import com.vlsolutions.swing.sample.MySplitDockApp;
import org.assertj.swing.fixture.FrameFixture;
import org.junit.Test;

import javax.swing.*;

import java.awt.*;
import java.lang.reflect.InvocationTargetException;

import static org.junit.Assert.*;

public class DockingDesktopTest extends TestBase {
@Override
protected void onSetUp() {
application = createDockedApplication(MySplitDockApp.class);
window = new FrameFixture(robot(), application);
window.show();
}

@Test
public void testFloating() throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(() -> {
application.setVisible(true);
application.getDesktop().setFloating(application.getTreePanel(), true);
});
assertTrue(application.getDesktop().getDockableState(application.getTreePanel()).isFloating());
}

@Test
public void testFloatingPoint() throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(() -> {
application.setVisible(true);
Point p = application.getDesktop().getBounds().getLocation();
application.getDesktop().setFloating(application.getTreePanel(), true, p);
});
assertEquals(DockableState.Location.FLOATING, application.getTreePanel().getDockKey().getLocation());
assertTrue(application.getDesktop().getDockableState(application.getTreePanel()).isFloating());
}

@Test
public void testMaximize() throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(() -> {
application.setVisible(true);
application.getDesktop().maximize(application.getTreePanel());
});
assertTrue(application.getDesktop().getDockableState(application.getTreePanel()).isMaximized());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ public abstract class DockedApplication extends JFrame {
MyTree treePanel = new MyTree();
MyGridOfButtons buttonGrid = new MyGridOfButtons();
MyJTable tablePanel = new MyJTable();

public DockingDesktop getDesktop() {
return desk;
}

public MyTree getTreePanel() {
return treePanel;
}
}

0 comments on commit a935fdd

Please sign in to comment.