mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Styling: added missing unit tests
This commit is contained in:
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.AfterAll;
|
|||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import com.formdev.flatlaf.icons.*;
|
import com.formdev.flatlaf.icons.*;
|
||||||
|
import com.formdev.flatlaf.ui.FlatInternalFrameUI.FlatInternalFrameBorder;
|
||||||
import com.formdev.flatlaf.ui.TestFlatStyling.CustomCheckBoxIcon;
|
import com.formdev.flatlaf.ui.TestFlatStyling.CustomCheckBoxIcon;
|
||||||
import com.formdev.flatlaf.ui.TestFlatStyling.CustomIcon;
|
import com.formdev.flatlaf.ui.TestFlatStyling.CustomIcon;
|
||||||
import com.formdev.flatlaf.ui.TestFlatStyling.CustomRadioButtonIcon;
|
import com.formdev.flatlaf.ui.TestFlatStyling.CustomRadioButtonIcon;
|
||||||
@@ -1165,6 +1166,64 @@ public class TestFlatStyleableInfo
|
|||||||
assertMapEquals( expected, border.getStyleableInfos() );
|
assertMapEquals( expected, border.getStyleableInfos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatDropShadowBorder() {
|
||||||
|
FlatDropShadowBorder border = new FlatDropShadowBorder();
|
||||||
|
|
||||||
|
Map<String, Class<?>> expected = expectedMap(
|
||||||
|
"shadowColor", Color.class,
|
||||||
|
"shadowInsets", Insets.class,
|
||||||
|
"shadowOpacity", float.class
|
||||||
|
);
|
||||||
|
|
||||||
|
assertMapEquals( expected, border.getStyleableInfos() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatMenuBarBorder() {
|
||||||
|
FlatMenuBarBorder border = new FlatMenuBarBorder();
|
||||||
|
|
||||||
|
Map<String, Class<?>> expected = expectedMap(
|
||||||
|
"borderColor", Color.class
|
||||||
|
);
|
||||||
|
|
||||||
|
assertMapEquals( expected, border.getStyleableInfos() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatPopupMenuBorder() {
|
||||||
|
FlatPopupMenuBorder border = new FlatPopupMenuBorder();
|
||||||
|
|
||||||
|
Map<String, Class<?>> expected = expectedMap(
|
||||||
|
"borderInsets", Insets.class,
|
||||||
|
"borderColor", Color.class
|
||||||
|
);
|
||||||
|
|
||||||
|
assertMapEquals( expected, border.getStyleableInfos() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatInternalFrameBorder() {
|
||||||
|
FlatInternalFrameBorder border = new FlatInternalFrameBorder();
|
||||||
|
|
||||||
|
Map<String, Class<?>> expected = expectedMap(
|
||||||
|
"activeBorderColor", Color.class,
|
||||||
|
"inactiveBorderColor", Color.class,
|
||||||
|
"borderLineWidth", int.class,
|
||||||
|
"dropShadowPainted", boolean.class,
|
||||||
|
"borderMargins", Insets.class,
|
||||||
|
|
||||||
|
"activeDropShadowColor", Color.class,
|
||||||
|
"activeDropShadowInsets", Insets.class,
|
||||||
|
"activeDropShadowOpacity", float.class,
|
||||||
|
"inactiveDropShadowColor", Color.class,
|
||||||
|
"inactiveDropShadowInsets", Insets.class,
|
||||||
|
"inactiveDropShadowOpacity", float.class
|
||||||
|
);
|
||||||
|
|
||||||
|
assertMapEquals( expected, border.getStyleableInfos() );
|
||||||
|
}
|
||||||
|
|
||||||
//---- icons --------------------------------------------------------------
|
//---- icons --------------------------------------------------------------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1380,4 +1439,25 @@ public class TestFlatStyleableInfo
|
|||||||
|
|
||||||
assertMapEquals( expected, icon.getStyleableInfos() );
|
assertMapEquals( expected, icon.getStyleableInfos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatTabbedPaneCloseIcon() {
|
||||||
|
FlatTabbedPaneCloseIcon icon = new FlatTabbedPaneCloseIcon();
|
||||||
|
|
||||||
|
Map<String, Class<?>> expected = expectedMap(
|
||||||
|
"closeSize", Dimension.class,
|
||||||
|
"closeArc", int.class,
|
||||||
|
"closeCrossPlainSize", float.class,
|
||||||
|
"closeCrossFilledSize", float.class,
|
||||||
|
"closeCrossLineWidth", float.class,
|
||||||
|
"closeBackground", Color.class,
|
||||||
|
"closeForeground", Color.class,
|
||||||
|
"closeHoverBackground", Color.class,
|
||||||
|
"closeHoverForeground", Color.class,
|
||||||
|
"closePressedBackground", Color.class,
|
||||||
|
"closePressedForeground", Color.class
|
||||||
|
);
|
||||||
|
|
||||||
|
assertMapEquals( expected, icon.getStyleableInfos() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,57 +27,15 @@ import java.awt.Graphics;
|
|||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.*;
|
||||||
import javax.swing.Icon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JCheckBoxMenuItem;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JEditorPane;
|
|
||||||
import javax.swing.JFormattedTextField;
|
|
||||||
import javax.swing.JInternalFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPasswordField;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JProgressBar;
|
|
||||||
import javax.swing.JRadioButton;
|
|
||||||
import javax.swing.JRadioButtonMenuItem;
|
|
||||||
import javax.swing.JScrollBar;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.JSplitPane;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.JTextPane;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.JToolBar;
|
|
||||||
import javax.swing.JTree;
|
|
||||||
import javax.swing.table.JTableHeader;
|
import javax.swing.table.JTableHeader;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import com.formdev.flatlaf.icons.FlatCapsLockIcon;
|
import com.formdev.flatlaf.icons.*;
|
||||||
import com.formdev.flatlaf.icons.FlatCheckBoxIcon;
|
import com.formdev.flatlaf.ui.FlatInternalFrameUI.FlatInternalFrameBorder;
|
||||||
import com.formdev.flatlaf.icons.FlatCheckBoxMenuItemIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatClearIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatHelpButtonIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatMenuArrowIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatRadioButtonIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatRadioButtonMenuItemIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatSearchIcon;
|
|
||||||
import com.formdev.flatlaf.icons.FlatSearchWithHistoryIcon;
|
|
||||||
import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableObject;
|
import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableObject;
|
||||||
import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI;
|
import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI;
|
||||||
import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException;
|
import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException;
|
||||||
@@ -1161,6 +1119,48 @@ public class TestFlatStyleableValue
|
|||||||
testValue( border, "custom.borderColor", Color.WHITE );
|
testValue( border, "custom.borderColor", Color.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatDropShadowBorder() {
|
||||||
|
FlatDropShadowBorder border = new FlatDropShadowBorder();
|
||||||
|
|
||||||
|
testValue( border, "shadowColor", Color.WHITE );
|
||||||
|
testValue( border, "shadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
testValue( border, "shadowOpacity", 1.23f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatMenuBarBorder() {
|
||||||
|
FlatMenuBarBorder border = new FlatMenuBarBorder();
|
||||||
|
|
||||||
|
testValue( border, "borderColor", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatPopupMenuBorder() {
|
||||||
|
FlatPopupMenuBorder border = new FlatPopupMenuBorder();
|
||||||
|
|
||||||
|
testValue( border, "borderInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
testValue( border, "borderColor", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatInternalFrameBorder() {
|
||||||
|
FlatInternalFrameBorder border = new FlatInternalFrameBorder();
|
||||||
|
|
||||||
|
testValue( border, "activeBorderColor", Color.WHITE );
|
||||||
|
testValue( border, "inactiveBorderColor", Color.WHITE );
|
||||||
|
testValue( border, "borderLineWidth", 123 );
|
||||||
|
testValue( border, "dropShadowPainted", false );
|
||||||
|
testValue( border, "borderMargins", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
|
||||||
|
testValue( border, "activeDropShadowColor", Color.WHITE );
|
||||||
|
testValue( border, "activeDropShadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
testValue( border, "activeDropShadowOpacity", 1.23f );
|
||||||
|
testValue( border, "inactiveDropShadowColor", Color.WHITE );
|
||||||
|
testValue( border, "inactiveDropShadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
testValue( border, "inactiveDropShadowOpacity", 1.23f );
|
||||||
|
}
|
||||||
|
|
||||||
//---- icons --------------------------------------------------------------
|
//---- icons --------------------------------------------------------------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1330,6 +1330,23 @@ public class TestFlatStyleableValue
|
|||||||
testValue( icon, "capsLockIconColor", Color.WHITE );
|
testValue( icon, "capsLockIconColor", Color.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatTabbedPaneCloseIcon() {
|
||||||
|
FlatTabbedPaneCloseIcon icon = new FlatTabbedPaneCloseIcon();
|
||||||
|
|
||||||
|
testValue( icon, "closeSize", new Dimension( 1, 2 ) );
|
||||||
|
testValue( icon, "closeArc", 123 );
|
||||||
|
testValue( icon, "closeCrossPlainSize", 1.23f );
|
||||||
|
testValue( icon, "closeCrossFilledSize", 1.23f );
|
||||||
|
testValue( icon, "closeCrossLineWidth", 1.23f );
|
||||||
|
testValue( icon, "closeBackground", Color.WHITE );
|
||||||
|
testValue( icon, "closeForeground", Color.WHITE );
|
||||||
|
testValue( icon, "closeHoverBackground", Color.WHITE );
|
||||||
|
testValue( icon, "closeHoverForeground", Color.WHITE );
|
||||||
|
testValue( icon, "closePressedBackground", Color.WHITE );
|
||||||
|
testValue( icon, "closePressedForeground", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
//---- class TestIcon -----------------------------------------------------
|
//---- class TestIcon -----------------------------------------------------
|
||||||
|
|
||||||
@SuppressWarnings( "EqualsHashCode" ) // Error Prone
|
@SuppressWarnings( "EqualsHashCode" ) // Error Prone
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.BeforeAll;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import com.formdev.flatlaf.FlatLaf;
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.icons.*;
|
import com.formdev.flatlaf.icons.*;
|
||||||
|
import com.formdev.flatlaf.ui.FlatInternalFrameUI.FlatInternalFrameBorder;
|
||||||
import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException;
|
import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException;
|
||||||
import com.formdev.flatlaf.util.ColorFunctions;
|
import com.formdev.flatlaf.util.ColorFunctions;
|
||||||
|
|
||||||
@@ -1423,6 +1424,48 @@ public class TestFlatStyling
|
|||||||
border.applyStyleProperty( "custom.borderColor", Color.WHITE );
|
border.applyStyleProperty( "custom.borderColor", Color.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatDropShadowBorder() {
|
||||||
|
FlatDropShadowBorder border = new FlatDropShadowBorder();
|
||||||
|
|
||||||
|
border.applyStyleProperty( "shadowColor", Color.WHITE );
|
||||||
|
border.applyStyleProperty( "shadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
border.applyStyleProperty( "shadowOpacity", 1.23f );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatMenuBarBorder() {
|
||||||
|
FlatMenuBarBorder border = new FlatMenuBarBorder();
|
||||||
|
|
||||||
|
border.applyStyleProperty( "borderColor", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatPopupMenuBorder() {
|
||||||
|
FlatPopupMenuBorder border = new FlatPopupMenuBorder();
|
||||||
|
|
||||||
|
border.applyStyleProperty( "borderInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
border.applyStyleProperty( "borderColor", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatInternalFrameBorder() {
|
||||||
|
FlatInternalFrameBorder border = new FlatInternalFrameBorder();
|
||||||
|
|
||||||
|
border.applyStyleProperty( "activeBorderColor", Color.WHITE );
|
||||||
|
border.applyStyleProperty( "inactiveBorderColor", Color.WHITE );
|
||||||
|
border.applyStyleProperty( "borderLineWidth", 123 );
|
||||||
|
border.applyStyleProperty( "dropShadowPainted", false );
|
||||||
|
border.applyStyleProperty( "borderMargins", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
|
||||||
|
border.applyStyleProperty( "activeDropShadowColor", Color.WHITE );
|
||||||
|
border.applyStyleProperty( "activeDropShadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
border.applyStyleProperty( "activeDropShadowOpacity", 1.23f );
|
||||||
|
border.applyStyleProperty( "inactiveDropShadowColor", Color.WHITE );
|
||||||
|
border.applyStyleProperty( "inactiveDropShadowInsets", new Insets( 1, 2, 3, 4 ) );
|
||||||
|
border.applyStyleProperty( "inactiveDropShadowOpacity", 1.23f );
|
||||||
|
}
|
||||||
|
|
||||||
//---- icons --------------------------------------------------------------
|
//---- icons --------------------------------------------------------------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1592,6 +1635,23 @@ public class TestFlatStyling
|
|||||||
icon.applyStyleProperty( "capsLockIconColor", Color.WHITE );
|
icon.applyStyleProperty( "capsLockIconColor", Color.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatTabbedPaneCloseIcon() {
|
||||||
|
FlatTabbedPaneCloseIcon icon = new FlatTabbedPaneCloseIcon();
|
||||||
|
|
||||||
|
icon.applyStyleProperty( "closeSize", new Dimension( 1, 2 ) );
|
||||||
|
icon.applyStyleProperty( "closeArc", 123 );
|
||||||
|
icon.applyStyleProperty( "closeCrossPlainSize", 1.23f );
|
||||||
|
icon.applyStyleProperty( "closeCrossFilledSize", 1.23f );
|
||||||
|
icon.applyStyleProperty( "closeCrossLineWidth", 1.23f );
|
||||||
|
icon.applyStyleProperty( "closeBackground", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "closeForeground", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "closeHoverBackground", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "closeHoverForeground", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "closePressedBackground", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "closePressedForeground", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
//---- enums --------------------------------------------------------------
|
//---- enums --------------------------------------------------------------
|
||||||
|
|
||||||
enum SomeEnum { enumValue1, enumValue2 }
|
enum SomeEnum { enumValue1, enumValue2 }
|
||||||
|
|||||||
Reference in New Issue
Block a user