FileDocCategorySizeDatePackage
InstanceofTest.javaAPI DocAndroid 1.5 API3983Wed May 06 22:42:02 BST 2009com.android.unit_tests

InstanceofTest

public class InstanceofTest extends TestCase

Fields Summary
protected A
mA
protected ChildOfAOne
mOne
protected ChildOfAOne
mTwo
protected ChildOfAOne
mThree
protected ChildOfAOne
mFour
protected ChildOfAFive
mFive
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();

        mA = new A();
        mOne = new ChildOfAOne();
        mTwo = new ChildOfATwo();
        mThree = new ChildOfAThree();
        mFour = new ChildOfAFour();
        mFive = new ChildOfAFive();
    
public voidtestDerivedFour()

        InterfaceFour four = mFour;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_four should not be a ChildOfAFive", four instanceof ChildOfAFive);
        }
    
public voidtestDerivedOne()

        InterfaceOne one = mOne;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_one should not be a ChildOfAFive", one instanceof ChildOfAFive);
        }
    
public voidtestDerivedThree()

        InterfaceThree three = mThree;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_three should not be a ChildOfAFive", three instanceof ChildOfAFive);
        }
    
public voidtestDerivedTwo()

        InterfaceTwo two = mTwo;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_two should not be a ChildOfAFive", two instanceof ChildOfAFive);
        }
    
public voidtestFailInterface()

        InterfaceOne one = mFive;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_five does not implement InterfaceFive", one instanceof InterfaceFive);
        }
    
public voidtestNoInterface()

        A a = mA;
        for (int i = 0; i < 100000; i++) {
            assertFalse("m_a should not be a ChildOfAFive", a instanceof ChildOfAFive);
        }
    
public voidtestSuccessClass()

        ChildOfAOne five = mFive;
        for (int i = 0; i < 100000; i++) {
            assertTrue("m_five is suppose to be a ChildOfAFive", five instanceof ChildOfAFive);
        }
    
public voidtestSuccessInterface()

        ChildOfAFive five = mFive;
        for (int i = 0; i < 100000; i++) {
            assertTrue("m_five is suppose to be a InterfaceFour", five instanceof InterfaceFour);
        }