[Libreoffice-commits] core.git: 2 commits - connectivity/qa filter/qa framework/qa qadevOOo/runner

Noel Grandin noel at peralex.com
Fri Oct 16 01:56:19 PDT 2015


 connectivity/qa/complex/connectivity/FlatFileAccess.java            |    4 -
 filter/qa/complex/filter/detection/typeDetection/TypeDetection.java |   34 +++++-----
 framework/qa/complex/framework/recovery/RecoveryTest.java           |   10 +-
 qadevOOo/runner/complexlib/Assurance.java                           |   33 +++++----
 qadevOOo/runner/complexlib/ComplexTestCase.java                     |   10 +-
 5 files changed, 47 insertions(+), 44 deletions(-)

New commits:
commit 14bf708ef586b15dffed66ffaf524baf4d8fcbfa
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Oct 16 10:55:02 2015 +0200

    convert "continue" flag to an enum
    
    Change-Id: I160de1152978f301c514d9107c9e9082bab3cf05

diff --git a/connectivity/qa/complex/connectivity/FlatFileAccess.java b/connectivity/qa/complex/connectivity/FlatFileAccess.java
index aa2eed4..c7c961b 100644
--- a/connectivity/qa/complex/connectivity/FlatFileAccess.java
+++ b/connectivity/qa/complex/connectivity/FlatFileAccess.java
@@ -228,11 +228,11 @@ public class FlatFileAccess extends ComplexTestCase
             {
                 values.add( (T)i_getter.getValue( rowSet ) );
             }
-            assureEquals( i_context + ": " + i_failureDesc, i_expectedValues, values.toArray(), true );
+            assureEquals( i_context + ": " + i_failureDesc, i_expectedValues, values.toArray(), ContinueWithTest.YES );
         }
         catch( final SQLException e )
         {
-            failed( i_context + ": caught an exception: " + e.toString(), false );
+            failed( i_context + ": caught an exception: " + e.toString(), ContinueWithTest.NO );
         }
         finally
         {
diff --git a/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java b/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
index 5c87c22..e39e2bf 100644
--- a/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
+++ b/filter/qa/complex/filter/detection/typeDetection/TypeDetection.java
@@ -270,7 +270,7 @@ public class TypeDetection extends ComplexTestCase {
             }
 
         } catch (ClassCastException e){
-            failed(e.toString(), true);
+            failed(e.toString(), ContinueWithTest.YES);
         }
     }
 
@@ -296,7 +296,7 @@ public class TypeDetection extends ComplexTestCase {
             boolean fileTypeOK = helper.checkFileType(type, fileType);
 
             assure("\nURL-test         : " + fileAlias + ":\n\treturned type: '" + type +
-                   "'\n\texpected type: '" + fileType + "'",fileTypeOK ,true);
+                   "'\n\texpected type: '" + fileType + "'",fileTypeOK ,ContinueWithTest.YES);
     }
 
     /** Filles a MediaDescriptor with a <code>XInputStream</code> of the test
@@ -317,7 +317,7 @@ public class TypeDetection extends ComplexTestCase {
         try{
             xStream = helper.getFileStream( fileURL );
         } catch (NotConnectedException e) {
-            failed("Could not get XInputStream from file :'" + fileURL + "'",true);
+            failed("Could not get XInputStream from file :'" + fileURL + "'",ContinueWithTest.YES);
             return;
         }
 
@@ -332,7 +332,7 @@ public class TypeDetection extends ComplexTestCase {
             boolean fileTypeOK = helper.checkFileType(type, fileType);
 
             assure("\nXInputStream-test: " + fileAlias + ":\n\treturned type: '" + type +
-                   "'\n\texpected type: '" + fileType + "'", fileTypeOK, true);
+                   "'\n\texpected type: '" + fileType + "'", fileTypeOK, ContinueWithTest.YES);
 
     }
 
@@ -375,16 +375,16 @@ public class TypeDetection extends ComplexTestCase {
 
                     assure("\n" + fileAlias + ":\n\treturned type: '" + type +
                                     "'\n\texpected type: '" + expectedFileType + "'",
-                                    fileTypeOK, true);
+                                    fileTypeOK, ContinueWithTest.YES);
 
                     } catch (FileAliasNotFoundException e){
-                        failed(e.toString(),true);
+                        failed(e.toString(),ContinueWithTest.YES);
                     }
 
             }
 
         } catch (ClassCastException e){
-            failed(e.toString(), true);
+            failed(e.toString(), ContinueWithTest.YES);
         }
     }
 
@@ -429,16 +429,16 @@ public class TypeDetection extends ComplexTestCase {
 
                     assure("\n" + fileAlias + ":\n\treturned type: '" + type +
                                     "'\n\texpected type: '" + expectedType + "'",
-                                    fileTypeOK,true);
+                                    fileTypeOK,ContinueWithTest.YES);
 
                 } catch (FileAliasNotFoundException e){
-                    failed(e.toString(),true);
+                    failed(e.toString(),ContinueWithTest.YES);
                 }
 
             }
 
         } catch (ClassCastException e){
-            failed(e.toString(), true);
+            failed(e.toString(), ContinueWithTest.YES);
         }
     }
 
@@ -474,16 +474,16 @@ public class TypeDetection extends ComplexTestCase {
 
                     assure("\n" + fileAlias + ":\n\treturned type: '" + type +
                                     "'\t\nexpected type: '" + fileType + "'",
-                                    fileTypeOK, true);
+                                    fileTypeOK, ContinueWithTest.YES);
 
                 } catch (FileAliasNotFoundException e){
-                    failed(e.toString(),true);
+                    failed(e.toString(),ContinueWithTest.YES);
                 }
 
             }
 
         } catch (ClassCastException e){
-            failed(e.toString(), true);
+            failed(e.toString(), ContinueWithTest.YES);
         }
      }
 
@@ -531,15 +531,15 @@ public class TypeDetection extends ComplexTestCase {
                 }
 
                 if (file.canWrite() && bReadOnly)
-                    assure("\nStreamLoader: file '"+ fileURL +"' is writable but out-Parameter does contain 'ReadOnly' property",false ,true);
+                    assure("\nStreamLoader: file '"+ fileURL +"' is writable but out-Parameter does contain 'ReadOnly' property", false, ContinueWithTest.YES);
                 else if ((!file.canWrite()) && (!bReadOnly))
-                    assure("\nStreamLoader: file '"+ fileURL +"'is readonly but out-Parameter does not contain 'ReadOnly' property",false ,true);
-                else assure("all ok",true,true);
+                    assure("\nStreamLoader: file '"+ fileURL +"'is readonly but out-Parameter does not contain 'ReadOnly' property", false, ContinueWithTest.YES);
+                else assure("all ok", true, ContinueWithTest.YES);
 
             }
 
          } catch (ClassCastException e){
-            failed(e.toString(), true);
+            failed(e.toString(), ContinueWithTest.YES);
         }
 
      }
diff --git a/framework/qa/complex/framework/recovery/RecoveryTest.java b/framework/qa/complex/framework/recovery/RecoveryTest.java
index c45661d..4605820 100644
--- a/framework/qa/complex/framework/recovery/RecoveryTest.java
+++ b/framework/qa/complex/framework/recovery/RecoveryTest.java
@@ -323,7 +323,7 @@ public class RecoveryTest extends ComplexTestCase {
             XDialog oDialog = null;
             oDialog = rt.getActiveDialogAfterStartup(xMSF);
 
-            assure("could not get Recovery Dialog at start of office", (oDialog != null), CONTINUE);
+            assure("could not get Recovery Dialog at start of office", (oDialog != null), ContinueWithTest.YES);
 
             XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, oDialog);
             log.println("got the following dialog: '" +oDialog.getTitle() + "'");
@@ -427,7 +427,7 @@ public class RecoveryTest extends ComplexTestCase {
                 XWindow oDialog = null;
                 oDialog = rt.getActiveWindow(xMSF);
 
-                assure("could not get 'Save Documents' Dialog: ", (oDialog != null), CONTINUE);
+                assure("could not get 'Save Documents' Dialog: ", (oDialog != null), ContinueWithTest.YES);
 
                 UITools oUITools = new UITools(oDialog);
 
@@ -438,7 +438,7 @@ public class RecoveryTest extends ComplexTestCase {
                 try{
                     documents = oUITools.getListBoxItems(listBoxName);
                 } catch (java.lang.Exception e){
-                    failed("could not get the document names from the 'Save Documents' dialog", CONTINUE);
+                    failed("could not get the document names from the 'Save Documents' dialog", ContinueWithTest.YES);
                 }
                 log.println("there are " + documents.length + " documents to save");
                 log.println("The following documents will be saved:");
@@ -451,12 +451,12 @@ public class RecoveryTest extends ComplexTestCase {
                 try{
                     oUITools.setTextEditFiledText("Save to", tempURL);
                 } catch (java.lang.Exception e){
-                    failed("could not set target directory for saving documents at 'Save Documents' dialog", CONTINUE);
+                    failed("could not set target directory for saving documents at 'Save Documents' dialog", ContinueWithTest.YES);
                 }
                 try{
                     oUITools.clickButton("OK");
                 } catch (java.lang.Exception e){
-                    failed("could not click 'OK' at 'Save Documents' dialog", CONTINUE);
+                    failed("could not click 'OK' at 'Save Documents' dialog", ContinueWithTest.YES);
                 }
             }
         } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java
index d3c98e3..4fbf375 100644
--- a/qadevOOo/runner/complexlib/Assurance.java
+++ b/qadevOOo/runner/complexlib/Assurance.java
@@ -24,7 +24,10 @@ package complexlib;
  */
 public class Assurance
 {
-    public static final boolean CONTINUE = true;
+    /** Used to indicate that we should continue with test method, even if check fails */
+    public enum ContinueWithTest {
+        YES, NO
+    }
 
     /** State of the current test method **/
     protected boolean bSuccessful = true;
@@ -39,7 +42,7 @@ public class Assurance
      * @param s The condition that should be true.
      */
     protected void assure(boolean s) {
-        assure("Assure failed.", s, false);
+        assure("Assure failed.", s, ContinueWithTest.NO);
     }
 
     /**
@@ -49,7 +52,7 @@ public class Assurance
      * @param s The condition that should be true.
      */
     protected void assure(String msg, boolean s) {
-        assure(msg, s, false);
+        assure(msg, s, ContinueWithTest.NO);
     }
 
     /**
@@ -59,7 +62,7 @@ public class Assurance
      * @param actual specifies the actual int value
      */
     protected void assureEquals( String message, int expected, int actual ) {
-        assureEquals( message, Integer.valueOf( expected ), Integer.valueOf( actual ), false );
+        assureEquals( message, Integer.valueOf( expected ), Integer.valueOf( actual ), ContinueWithTest.NO );
     }
 
     /**
@@ -69,13 +72,13 @@ public class Assurance
      * @param actual specifies the actual string value
      */
     protected void assureEquals( String message, String expected, String actual ) {
-        assureEquals( message, expected, actual, false );
+        assureEquals( message, expected, actual, ContinueWithTest.NO );
     }
 
     /**
      * assures the two given sequences are of equal length, and have equal content
      */
-    public <T> void assureEquals( String i_message, T[] i_expected, T[] i_actual, boolean i_continue )
+    public <T> void assureEquals( String i_message, T[] i_expected, T[] i_actual, ContinueWithTest i_continue )
     {
         if ( i_expected.length != i_actual.length )
             failed( i_message + ": expected element count: " + i_expected.length + ", actual element count: " + i_actual.length );
@@ -91,7 +94,7 @@ public class Assurance
      * @param msg The message of the failure.
      */
     protected void failed(String msg) {
-        assure(msg, false, false);
+        assure(msg, false, ContinueWithTest.NO);
     }
 
     /**
@@ -103,19 +106,19 @@ public class Assurance
      * The current method will of course marked as failed.
      * @param msg The message that is evaluated.
      * @param s The condition that should be true.
-     * @param cont Continue with test method, even if s is false.
+     * @param cont if YES, continue with test method, even if s is false.
      */
-    protected void assure(String msg, boolean s, boolean cont) {
+    protected void assure(String msg, boolean s, ContinueWithTest cont) {
         bSuccessful &= s;
         if (!s) {
             message += msg + "\r\n";
-            if (!cont) {
+            if (cont == ContinueWithTest.NO) {
                 throw new AssureException(msg);
             }
         }
     }
 
-    private void assureEquals( String message, Object expected, Object actual, boolean cont ) {
+    private void assureEquals( String message, Object expected, Object actual, ContinueWithTest cont ) {
         assure( message + " (expected: " + expected.toString() + ", actual: " + actual.toString() + ")",
             expected.equals( actual ), cont );
     }
@@ -128,9 +131,9 @@ public class Assurance
      * method will continue.<br>
      * The current method will of course marked as failed.
      * @param msg The message that is evaluated.
-     * @param cont Continue with test method, even if s is false.
+     * @param cont if YES, continue with test method, even if s is false.
      */
-    protected void failed(String msg, boolean cont) {
+    protected void failed(String msg, ContinueWithTest cont) {
         assure(msg, false, cont);
     }
 
commit a3a89c15230317710ba32753c0eafdb4733730ef
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Oct 16 10:45:52 2015 +0200

    rename state to bSuccessful in Assurance
    
    Change-Id: Ifc86275163a78dd1a61b207f3c6c55d9bf5902d7

diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java
index 9e7d269..d3c98e3 100644
--- a/qadevOOo/runner/complexlib/Assurance.java
+++ b/qadevOOo/runner/complexlib/Assurance.java
@@ -27,7 +27,7 @@ public class Assurance
     public static final boolean CONTINUE = true;
 
     /** State of the current test method **/
-    protected boolean state = true;
+    protected boolean bSuccessful = true;
 
     /** The message if the test did fail **/
     protected String message = null;
@@ -106,7 +106,7 @@ public class Assurance
      * @param cont Continue with test method, even if s is false.
      */
     protected void assure(String msg, boolean s, boolean cont) {
-        state &= s;
+        bSuccessful &= s;
         if (!s) {
             message += msg + "\r\n";
             if (!cont) {
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java
index 124107a..dd8afc6 100644
--- a/qadevOOo/runner/complexlib/ComplexTestCase.java
+++ b/qadevOOo/runner/complexlib/ComplexTestCase.java
@@ -65,14 +65,14 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
         catch (java.lang.reflect.InvocationTargetException e)
         {
             Throwable t = e.getTargetException();
-            if (!(t instanceof RuntimeException) || state)
+            if (!(t instanceof RuntimeException) || bSuccessful)
             {
                 log.println(t.toString());
                 if (message == null)
                 {
                     message = "Exception in before() method.\n\r" + t.getMessage();
                 }
-                state = false;
+                bSuccessful = false;
                 t.printStackTrace((PrintWriter) log);
             }
         }
@@ -99,7 +99,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
             DescEntry subEntry = _entry.SubEntries[i];
             if (m_bBeforeCalled)
             {
-                state = true;
+                bSuccessful = true;
                 message = "";
             }
             else
@@ -200,8 +200,8 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
                 subEntry.ErrorMsg = (msg == null ? "" : msg);
                 continue;
             }
-            subEntry.State = (state ? "PASSED.OK" : message);
-            subEntry.hasErrorMsg = !state;
+            subEntry.State = (bSuccessful ? "PASSED.OK" : message);
+            subEntry.hasErrorMsg = !bSuccessful;
             subEntry.ErrorMsg = message;
         }
     }


More information about the Libreoffice-commits mailing list