< prev index next >

tests/system/src/test/java/com/sun/glass/ui/monocle/TestLog.java

Print this page
rev 9491 : 8145203: Refactor systemTests for clear separation of tests
Reviewed-by: kcr

@@ -32,20 +32,24 @@
 import java.util.Formatter;
 import java.util.List;
 
 public class TestLog {
 
+    private static final boolean verbose = Boolean.getBoolean("verbose");
+    private static final double timeScale = Double.parseDouble(
+            System.getProperty("timeScale", "1"));
+
     private static final long DEFAULT_TIMEOUT = 3000l;
 
     private static final List<String> log = new ArrayList<>();
     private static final Object lock = new Object();
 
     private static long startTime = System.currentTimeMillis();
 
     public static void log(String s) {
         synchronized (lock) {
-            if (TestApplication.isVerbose()) {
+            if (verbose) {
                 System.out.println(timestamp() + " TestLog: " + s);
             }
             log.add(s);
             lock.notifyAll();
         }

@@ -153,11 +157,11 @@
 
     public static void assertLog(String s) {
         synchronized (lock) {
             if (!checkLog(s)) {
                 String err = "No line '" + s + "' in log";
-                if (TestApplication.isVerbose()) {
+                if (verbose) {
                     System.out.println(err);
                 }
                 throw new AssertionFailedError(err);
             }
         }

@@ -165,22 +169,22 @@
 
     public static void assertLogContaining(String s) {
         synchronized (lock) {
             if (!checkLogContaining(s)) {
                 String err = "No line containing '" + s + "' in log";
-                if (TestApplication.isVerbose()) {
+                if (verbose) {
                     System.out.println(err);
                 }
                 throw new AssertionFailedError(err);
             }
         }
     }
 
     private static String waitForLog(String[] s, long timeout, boolean exact) throws InterruptedException {
         long startTime = System.currentTimeMillis();
         long timeNow = startTime;
-        long endTime = timeNow + (long) (timeout * TestApplication.getTimeScale());
+        long endTime = timeNow + (long) (timeout * timeScale);
         String line;
         String logString = Arrays.toString(s).substring(1, Arrays.toString(s).length() - 1);
         synchronized (lock) {
             int index = 0;
             while ((line = checkLog(s, index, exact)) == null) {

@@ -190,11 +194,11 @@
                 }
                 timeNow = System.currentTimeMillis();
                 if (timeNow >= endTime) {
                     String message = "Timed out after " + (timeNow - startTime)
                             + "ms waiting for '" + logString + "'";
-                    if (!TestApplication.isVerbose()) {
+                    if (!verbose) {
                         System.out.flush();
                         System.err.flush();
                         for (String logLine: log) {
                             System.out.println(logLine);
                         }

@@ -203,11 +207,11 @@
                     throw new AssertionFailedError(message);
                 }
             }
         }
         long matchTime = System.currentTimeMillis() - startTime;
-        if (TestApplication.isVerbose()) {
+        if (verbose) {
             if (exact) {
                 System.out.println("TestLog matched '"
                         + logString + "' in "
                         + matchTime + "ms");
 
< prev index next >