< prev index next >
tests/system/src/test/java/test/com/sun/glass/ui/monocle/LensUInput.java
Print this page
rev 9491 : 8145203: Refactor systemTests for clear separation of tests
Reviewed-by: kcr
@@ -21,12 +21,14 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package com.sun.glass.ui.monocle;
+package test.com.sun.glass.ui.monocle;
+import com.sun.glass.ui.monocle.LinuxInputShim;
+import com.sun.glass.ui.monocle.LinuxSystemShim;
import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import java.io.File;
import java.io.IOException;
@@ -35,12 +37,10 @@
import java.util.BitSet;
import java.util.concurrent.CountDownLatch;
public class LensUInput extends NativeUInput {
- private LinuxSystem system = LinuxSystem.getLinuxSystem();
-
private long fd = -1;
private long devFD = -1;
private String deviceName;
private short bustype, product, vendor, version;
private String devNode;
@@ -57,19 +57,19 @@
public void setup() {
if (isSetup) {
return;
}
try {
- system.loadLibrary();
- system.setenv("LENS_TEST_INPUT", INPUT_PATH, true);
+ LinuxSystemShim.loadLibrary();
+ LinuxSystemShim.setenv("LENS_TEST_INPUT", INPUT_PATH, true);
File pipe = new File(INPUT_PATH);
if (pipe.exists()) {
pipe.delete();
}
pipe.deleteOnExit();
- if (system.mkfifo(pipe.getPath(), LinuxSystem.S_IRWXU) != 0) {
- throw new IOException(system.getErrorMessage());
+ if (LinuxSystemShim.mkfifo(pipe.getPath(), LinuxSystemShim.S_IRWXU) != 0) {
+ throw new IOException(LinuxSystemShim.getErrorMessage());
}
isSetup = true;
} catch (IOException e) {
e.printStackTrace();
}
@@ -107,13 +107,13 @@
}
private void writeBytes(int length) throws IOException {
int offset = 0;
while (offset < length) {
- int bytesWritten = (int) system.write(fd, byteBuffer, offset, length);
+ int bytesWritten = (int) LinuxSystemShim.write(fd, byteBuffer, offset, length);
if (bytesWritten < 0) {
- throw new IOException(system.getErrorMessage());
+ throw new IOException(LinuxSystemShim.getErrorMessage());
} else {
offset += bytesWritten;
}
}
}
@@ -148,12 +148,12 @@
devNode = DEVNODE_PREFIX + (++devNodeSuffix);
File devNodeFile = new File(devNode);
if (devNodeFile.exists()) {
devNodeFile.delete();
}
- if (system.mkfifo(devNode, LinuxSystem.S_IRWXU) != 0) {
- throw new IOException(system.getErrorMessage());
+ if (LinuxSystemShim.mkfifo(devNode, LinuxSystemShim.S_IRWXU) != 0) {
+ throw new IOException(LinuxSystemShim.getErrorMessage());
}
writeInt(1); // attach device
writeShort(bustype);
writeShort(product);
writeShort(vendor);
@@ -161,38 +161,38 @@
writeString(deviceName);
writeString(devNode);
writeString("Test Input Device");
BitSet evBits = capabilities.get("ev");
if (evBits != null) {
- for (int i = 0; i < LinuxInput.EV_MAX; i++) {
+ for (int i = 0; i < LinuxInputShim.EV_MAX; i++) {
if (evBits.get(i)) {
writeInt(i);
}
}
}
writeInt(-1);
BitSet keyBits = capabilities.get("key");
if (keyBits != null) {
- for (int i = 0; i < LinuxInput.KEY_MAX; i++) {
+ for (int i = 0; i < LinuxInputShim.KEY_MAX; i++) {
if (keyBits.get(i)) {
writeInt(i);
}
}
}
writeInt(-1);
BitSet relBits = capabilities.get("rel");
if (relBits != null) {
- for (int i = 0; i < LinuxInput.REL_MAX; i++) {
+ for (int i = 0; i < LinuxInputShim.REL_MAX; i++) {
if (relBits.get(i)) {
writeInt(i);
}
}
}
writeInt(-1);
BitSet absBits = capabilities.get("abs");
if (absBits != null) {
- for (int i = 0; i < LinuxInput.ABS_MAX; i++) {
+ for (int i = 0; i < LinuxInputShim.ABS_MAX; i++) {
if (absBits.get(i)) {
writeInt(i);
int[] caps = absCaps.get(i);
if (caps == null) {
caps = new int[6];
@@ -213,68 +213,68 @@
}
@Override
protected void destroyDevice() throws IOException {
if (devFD != -1l) {
- system.close(devFD);
+ LinuxSystemShim.close(devFD);
devFD = -1;
}
new File(devNode).delete();
writeInt(2); // detach device
writeString(devNode);
}
private long openPipe(String path) throws IOException {
long timeOut = System.currentTimeMillis() + 10000l;
while (System.currentTimeMillis() < timeOut) {
- long pipeFD = system.open(path,
- LinuxSystem.O_WRONLY | LinuxSystem.O_NONBLOCK);
+ long pipeFD = LinuxSystemShim.open(path,
+ LinuxSystemShim.O_WRONLY | LinuxSystemShim.O_NONBLOCK);
if (pipeFD < 0l) {
- if (system.errno() == LinuxSystem.ENXIO) { // no reader on pipe
+ if (LinuxSystemShim.errno() == LinuxSystemShim.ENXIO) { // no reader on pipe
try {
Thread.sleep(100l);
} catch (InterruptedException e) { }
} else {
break;
}
} else {
return pipeFD;
}
}
- throw new IOException(system.getErrorMessage());
+ throw new IOException(LinuxSystemShim.getErrorMessage());
}
@Override
protected void openConnection() throws IOException {
fd = openPipe(INPUT_PATH);
}
@Override
protected void closeConnection() {
if (fd >= 0l) {
- system.close(fd);
+ LinuxSystemShim.close(fd);
fd = -1l;
}
}
@Override
public void write(ByteBuffer buffer) throws IOException {
int offset = 0;
while (offset < buffer.limit()) {
- int bytesWritten = (int) system.write(devFD, buffer, offset, buffer.limit());
+ int bytesWritten = (int) LinuxSystemShim.write(devFD, buffer, offset, buffer.limit());
if (bytesWritten < 0) {
- if (system.errno() == LinuxSystem.EAGAIN) {
+ if (LinuxSystemShim.errno() == LinuxSystemShim.EAGAIN) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
- throw new IOException(system.getErrorMessage());
+ throw new IOException(LinuxSystemShim.getErrorMessage());
}
} else {
offset += bytesWritten;
}
}
- system.ioctl(devFD, LinuxSystem.I_FLUSH, LinuxSystem.FLUSHRW);
+ LinuxSystemShim.ioctl(devFD, LinuxSystemShim.I_FLUSH, LinuxSystemShim.FLUSHRW);
}
}
< prev index next >