FileDocCategorySizeDatePackage
CameraUtilsDecoratorTest.javaAPI DocAndroid 5.1 API5358Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest.unit

CameraUtilsDecoratorTest

public class CameraUtilsDecoratorTest extends TestCase
adb shell am instrument -e class 'com.android.mediaframeworktest.unit.CameraUtilsDecoratorTest' \ -w com.android.mediaframeworktest/.MediaFrameworkUnitTestRunner

Fields Summary
private DummyListener
mDummyListener
private DummyInterface
mIface
Constructors Summary
Methods Summary
public voidsetUp()

        mDummyListener = new DummyListener();
        mIface = Decorator.newInstance(new DummyImpl(), mDummyListener);
    
public voidtestDecorator()


        // TODO rewrite this using mocks

        assertTrue(mIface.addValues(1, 2, 3) == 6);
        assertTrue(mDummyListener.beforeCalled);
        assertTrue(mDummyListener.afterCalled);

        int resultValue = (Integer)mDummyListener.resultValue;
        assertTrue(resultValue == 6);
        assertTrue(mDummyListener.finallyCalled);
        assertFalse(mDummyListener.catchCalled);
    
public voidtestDecoratorExceptions()


        boolean gotExceptions = false;
        try {
            mIface.raiseException();
        } catch (Exception e) {
            gotExceptions = true;
            assertTrue(e.getMessage() == "Test exception");
        }
        assertTrue(gotExceptions);
        assertTrue(mDummyListener.beforeCalled);
        assertFalse(mDummyListener.afterCalled);
        assertTrue(mDummyListener.catchCalled);
        assertTrue(mDummyListener.finallyCalled);
    
public voidtestDecoratorRaisesException()


        boolean gotExceptions = false;
        try {
            mDummyListener.raiseException = true;
            mIface.addValues(1, 2, 3);
            Assert.fail("unreachable");
        } catch (UnsupportedOperationException e) {
            gotExceptions = true;
            assertTrue(e.getMessage() == "Test exception");
        }
        assertTrue(gotExceptions);
        assertTrue(mDummyListener.beforeCalled);
        assertTrue(mDummyListener.afterCalled);
        assertFalse(mDummyListener.catchCalled);
        assertTrue(mDummyListener.finallyCalled);
    
public voidtestDecoratorUnsupportedOperationException()


        boolean gotExceptions = false;
        try {
            mIface.raiseUnsupportedOperationException();
        } catch (UnsupportedOperationException e) {
            gotExceptions = true;
            assertTrue(e.getMessage() == "Test exception");
        }
        assertTrue(gotExceptions);
        assertTrue(mDummyListener.beforeCalled);
        assertFalse(mDummyListener.afterCalled);
        assertTrue(mDummyListener.catchCalled);
        assertTrue(mDummyListener.finallyCalled);