javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt/gauge/GaugeTest.java
changeset 79 2f468c1958d0
parent 23 98ccebc37403
equal deleted inserted replaced
76:4ad59aaee882 79:2f468c1958d0
    87 
    87 
    88     public static java.util.Vector methodNames()
    88     public static java.util.Vector methodNames()
    89     {
    89     {
    90         java.util.Vector methodNames = new java.util.Vector();
    90         java.util.Vector methodNames = new java.util.Vector();
    91         methodNames.addElement("testAccessors");
    91         methodNames.addElement("testAccessors");
       
    92         methodNames.addElement("gaugeCurrentValuesTest");
    92         return methodNames;
    93         return methodNames;
    93     }
    94     }
    94 
    95 
    95     protected void runTest() throws Throwable
    96     protected void runTest() throws Throwable
    96     {
    97     {
    97         if(getName().equals("testAccessors")) testAccessors();
    98         if(getName().equals("testAccessors")) testAccessors();
       
    99         else if(getName().equals("gaugeCurrentValuesTest")) gaugeCurrentValuesTest();
    98         else super.runTest();
   100         else super.runTest();
    99     }
   101     }
   100     /**
   102     /**
   101      * Tests the gauge accessor methods.
   103      * Tests the gauge accessor methods.
   102      */
   104      */
   202         assertTrue("Minimum width was zero or negative, case 4.",
   204         assertTrue("Minimum width was zero or negative, case 4.",
   203                    gauge4.getMinimumWidth() > 0);
   205                    gauge4.getMinimumWidth() > 0);
   204         //print("labeled interactive minimum width: "
   206         //print("labeled interactive minimum width: "
   205         //        + gauge4.getMinimumWidth());
   207         //        + gauge4.getMinimumWidth());
   206     }
   208     }
       
   209 
       
   210     /**
       
   211      * Tests Non-interactive INDEFINITE Gauge with different current values.
       
   212      * <p>
       
   213     * Test passes if current values of the Gauge will not be changed.
       
   214      * <p>
       
   215     * Test fails if current values of the Gauge will be changed.
       
   216     * <p>
       
   217      */
       
   218     public void gaugeCurrentValuesTest()
       
   219     {
       
   220         Gauge  gaugeObj;
       
   221         int[]  values = {Gauge.CONTINUOUS_IDLE, Gauge.CONTINUOUS_RUNNING,
       
   222                          Gauge.INCREMENTAL_IDLE, Gauge.INCREMENTAL_UPDATING};
       
   223 
       
   224         for (int i=0; i != values.length; ++i) 
       
   225         {
       
   226             gaugeObj = new Gauge("MT Gauge", false, Gauge.INDEFINITE, values[i]);
       
   227 
       
   228             gaugeObj.setMaxValue(Gauge.INDEFINITE);
       
   229 
       
   230             if (gaugeObj.getMaxValue() != Gauge.INDEFINITE) 
       
   231             {
       
   232                 String s = "Test FAILED\n Passed: Gauge.INDEFINITE ("+
       
   233                 Gauge.INDEFINITE+"), got:" + gaugeObj.getMaxValue();
       
   234                 fail("1. "+s);
       
   235             }
       
   236 
       
   237             if (gaugeObj.getValue() != values[i]) 
       
   238             {
       
   239                 String s = "Test FAILED\n Current value was changed. Was: " +
       
   240                 values[i] + ", became: "+gaugeObj.getValue();
       
   241                 fail("2. "+s);
       
   242             }
       
   243         }
       
   244     }
   207 }
   245 }