Move test files to separate project

This commit is contained in:
2015-10-18 16:35:57 +01:00
parent 7c1284333f
commit 900098c959
5 changed files with 5 additions and 150 deletions

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
<classpathentry sourcepath="C:/Users/Rik/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/4.2.0/6f6b127a5018e889a46067216a53485abb1b1f78/jna-4.2.0-sources.jar" kind="lib" path="C:/Users/Rik/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/4.2.0/812b976ed15bb1b0b3fc059fae927b0f76b39585/jna-4.2.0.jar" exported="true"/>
<classpathentry sourcepath="C:/Users/Rik/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/platform/3.5.2/bc6b5158219706865e4a527e2602301286842641/platform-3.5.2-sources.jar" kind="lib" path="C:/Users/Rik/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/platform/3.5.2/beac07d13858ef3697ceeab43897d70aeb5113c9/platform-3.5.2.jar" exported="true"/>
</classpath>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jna-test</name>
<name>jlibwinapi</name>
<comment></comment>
<projects>
</projects>

View File

@@ -1,13 +0,0 @@
package test;
public enum Amount {
DECREASE_MUCH ("--"),
DECREASE_LITTLE ("-"),
INCREASE_LITTLE ("+"),
INCREASE_MUCH ("++");
public String value;
Amount(String value) {
this.value = value;
}
}

View File

@@ -1,20 +0,0 @@
package test;
public enum Slider {
EXPOSURE,
CONTRAST,
HIGHLIGHTS,
SHADOWS,
BLACKS,
WHITES,
CLARITY,
VIBRANCE;
public String getLabel() {
String name = this.name();
return String.format("%s%s", name.substring(0, 1), name.toLowerCase().substring(1));
}
public String getLabel(Amount amount) {
return String.format("%s %s", getLabel(), amount.value);
}
}

View File

@@ -1,113 +0,0 @@
package test;
import java.util.HashMap;
import java.util.Random;
import org.synthuse.Api;
import org.synthuse.objects.MenuItem;
import com.sun.jna.platform.win32.WinDef.HWND;
public class Test {
protected Api api;
protected HashMap<Slider, HashMap<Amount, MenuItem>> sliderMap;
protected HashMap<Slider, HWND> valueMap;
public Test() {
api = new Api();
sliderMap = new HashMap<Slider, HashMap<Amount, MenuItem>>();
valueMap = new HashMap<Slider, HWND>();
}
public static void main(String[] args) throws Exception {
Test test = new Test();
test.start();
//test.moveSlider(Slider.CONTRAST, Amount.INCREASE_LITTLE);
for (int k = 0; k < 5; ++k) {
Slider slider = Slider.values()[new Random().nextInt(Slider.values().length)];
for (int j = 0; j < 5; ++j) {
for (int i = 0; i < 10; ++i) {
test.moveSlider(slider, Amount.INCREASE_LITTLE);
System.out.println(test.getValue(slider));
Thread.sleep(200);
}
Thread.sleep(400);
for (int i = 0; i < 10; ++i) {
test.moveSlider(slider, Amount.INCREASE_LITTLE);
Thread.sleep(200);
}
}
}
}
protected void moveSlider(Slider slider, Amount amount) throws Exception {
MenuItem menuItem = sliderMap.get(slider).get(amount);
api.activateItem(menuItem);
}
protected float getValue(Slider slider) {
if (valueMap.containsKey(slider)) {
HWND hWnd = valueMap.get(slider);
String text = Api.getWindowText(hWnd);
return Float.valueOf(text.replace(" ", ""));
} else {
return 0;
}
}
public void start() throws Exception {
// Find Lightroom window
HWND hWndTopWindow = api.findTopWindow("Lightroom", "AgWinMainFrame");
if (hWndTopWindow == null) {
throw new Exception("Can't find top window");
}
// Find menu options from Keyboard Tamer
String[] path = {"&File", "Pl&ug-in Extras", ""};
for (Slider slider : Slider.values()) {
HashMap<Amount, MenuItem> amountMap = new HashMap<Amount, MenuItem>();
for (Amount amount : Amount.values()) {
String label = slider.getLabel(amount);
path[2] = String.format(" %s", label);
MenuItem menuItem = api.loadMenuItem(hWndTopWindow, true, path);
amountMap.put(amount, menuItem);
}
sliderMap.put(slider, amountMap);
}
// Find develop sliders
path = new String[]{"", "Top", "Main", "Panel", "Last Panel", "View", "ClipView", "Accordion", "Accordion"};
HWND hWnd = api.findChildWindow(hWndTopWindow, path);
if (hWnd == null) {
throw new Exception("Can't find window");
}
for (HWND hWndLoop : api.findAllChildWindow(hWnd, "Collapsible")) {
path = new String[]{"Basic", "View"};
hWnd = api.findChildWindow(hWndLoop, path);
if (hWnd != null) {
Slider slider = null;
for (HWND hWndSubLoop : api.findAllChildWindow(hWnd, "")) {
//String className = Api.getWindowClassName(hWndSubLoop);
String text = Api.getWindowText(hWndSubLoop);
if (!text.contains("Bridge") && !text.contains("View") && text.length() > 0) {
if (slider != null) {
System.out.printf("%s = %s (%.2f)\n", slider.getLabel(), text, Float.valueOf(text.replace(" ", "")));
valueMap.put(slider, hWndSubLoop);
slider = null;
} else {
for (Slider sliderLoop : Slider.values()) {
if (sliderLoop.getLabel().equals(text)) {
slider = sliderLoop;
}
}
}
}
}
}
}
}
}