FileDocCategorySizeDatePackage
TestCriteria.javaAPI DocphoneME MR2 API (J2ME)5461Wed May 02 18:00:40 BST 2007com.sun.j2me.location

TestCriteria

public class TestCriteria extends com.sun.midp.i3test.TestCase
Tests for selecting location provider.

Fields Summary
private final int
testHorAcc
Test value of the horisontal accuracy
private final int
testVertAcc
Test value of the vertical accuracy
private final int
testPrefTime
Test value of the preferred response time
private final int
testPowCons
Test value of the power consumption
Constructors Summary
Methods Summary
voidTest1()
Body of the test 1

              
      
            Criteria testCriteria = new Criteria();
	    if (testCriteria == null) {
                fail("Criteria create error");
	    }
	    // Test default values
	    if (!(testCriteria.getHorizontalAccuracy() == 
	        Criteria.NO_REQUIREMENT)) {
                fail("Criteria: default value of horisontal accuracy" +
		    " is wrong");
	    }
	    if (!(testCriteria.getVerticalAccuracy() == 
	        Criteria.NO_REQUIREMENT)) {
                fail("Criteria: default value of vertical accuracy" +
		    " is wrong");
	    }
	    if (!(testCriteria.getPreferredResponseTime() == 
	        Criteria.NO_REQUIREMENT)) {
                fail("Criteria: default value of preferred response time" +
		    " is wrong");
	    }
	    if (!(testCriteria.getPreferredPowerConsumption() == 
	        Criteria.NO_REQUIREMENT)) {
                fail("Criteria: default value of power consumption" +
		    " is wrong");
	    }
	    if (!(testCriteria.isAllowedToCost() == true)) {
                fail("Criteria: on create should be allowed to cost");
	    }
	    if (!(testCriteria.isSpeedAndCourseRequired() == false)) {
                fail("Criteria: on create the speed and the course" +
		    " shouldn't be required");
	    }
	    if (!(testCriteria.isAltitudeRequired() == false)) {
                fail("Criteria: on create the altitude" +
		    " shouldn't be required");
	    }
	    if (!(testCriteria.isAddressInfoRequired() == false)) {
                fail("Criteria: on create the textual address info" +
		    " shouldn't be required");
            }
	    assertTrue("OK", true);
    
voidTest2()
Body of the test 2

            Criteria testCriteria = new Criteria();
	    assertTrue("OK", true);
            testCriteria.setHorizontalAccuracy(testHorAcc);
	    if (!(testCriteria.getHorizontalAccuracy() == testHorAcc)) {
                fail("Criteria: setting the new value of horisontal" +
		    " accuracy is wrong");
	    }
            testCriteria.setVerticalAccuracy(testVertAcc);
	    if (!(testCriteria.getVerticalAccuracy() == testVertAcc)) {
                fail("Criteria: setting the new value of vertical" +
		    " accuracy is wrong");
	    }
            testCriteria.setPreferredResponseTime(testPrefTime);
	    if (!(testCriteria.getPreferredResponseTime() == testPrefTime)) {
                fail("Criteria: setting the new value of preferred" +
		    " time is wrong");
	    }
            testCriteria.setPreferredPowerConsumption(testPowCons);
	    if (!(testCriteria.getPreferredPowerConsumption() 
	        == testPowCons)) {
                fail("Criteria: setting the new value of power" +
		    " consumption is wrong");
	    }
            testCriteria.setCostAllowed(false);
	    if (testCriteria.isAllowedToCost()) {
                fail("Criteria: switching off cost allowed" +
		    " setting is wrong");
	    }
            testCriteria.setSpeedAndCourseRequired(true);
	    if (!testCriteria.isSpeedAndCourseRequired()) {
                fail("Criteria: switching on requirement of" +
		    " course and speed is wrong");
	    }
            testCriteria.setAltitudeRequired(true);
	    if (!testCriteria.isAltitudeRequired()) {
                fail("Criteria: switching on requirement of" +
		    " altitude is wrong");
	    }
            testCriteria.setAddressInfoRequired(true);
	    if (!testCriteria.isAddressInfoRequired()) {
                fail("Criteria: switching on requirement of" +
		    " textual address information is wrong");
	    }
    
public voidrunTests()
Tests execute

        declare("TestCriteriaDefault");
	Test1();
        declare("TestCriteriaParameters");
	Test2();