jdk-24/test/jdk/sanity/client/SwingSet/src/TestHelpers.java
Vikrant Agarwal eaf0662ffc 8200605: Create test for GridBagLayoutDemo
Reviewed-by: serb, shurailine
2018-06-19 12:04:01 +05:30

50 lines
1.7 KiB
Java

import java.awt.Dimension;
import java.awt.Point;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import javax.swing.UIManager;
import org.netbeans.jemmy.operators.ComponentOperator;
import org.testng.annotations.DataProvider;
public class TestHelpers {
/**
* A DataProvider having the class name of all the available look and feels
*
* @return a 2d Object array containing the class name of all the available
* look and feels
*/
@DataProvider(name = "availableLookAndFeels")
public static Object[][] provideAvailableLookAndFeels() {
UIManager.LookAndFeelInfo LookAndFeelInfos[]
= UIManager.getInstalledLookAndFeels();
Object[][] lookAndFeels = new Object[LookAndFeelInfos.length][1];
for (int i = 0; i < LookAndFeelInfos.length; i++) {
lookAndFeels[i][0] = LookAndFeelInfos[i].getClassName();
}
return lookAndFeels;
}
public static void checkChangeLocation(ComponentOperator component,
Point finalLocation) {
Point initialLocation = component.getLocation();
component.setLocation(finalLocation);
component.waitComponentLocation(finalLocation);
component.setLocation(initialLocation);
component.waitComponentLocation(initialLocation);
}
public static void checkChangeSize(ComponentOperator component,
Dimension dimensionFinal) {
Dimension dimensionInitial = component.getSize();
component.setSize(dimensionFinal);
component.waitComponentSize(dimensionFinal);
component.setSize(dimensionInitial);
component.waitComponentSize(dimensionInitial);
}
}