@@ -0,0 +1,1949 @@
+package com.fuzz.indicator;%0A%0Aimport android.database.DataSetObserver;%0Aimport android.view.ViewTreeObserver;%0A%0Aimport com.fuzz.indicator.proxy.StateProxy;%0Aimport com.fuzz.indicator.proxy.UnavailableProxy;%0A%0Aimport org.junit.Test;%0A%0Aimport static org.mockito.ArgumentMatchers.any;%0Aimport static org.mockito.Mockito.doCallRealMethod;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * Test of whether calls to %7B@link StateProxy#associateWith%7D are always mirrored by%0A * calls to %7B@link StateProxy#disassociateFrom%7D.%0A *%0A * @author Philip Cohn-Cort (Fuzz)%0A */%0Apublic class StateProxyBalancingTest %7B%0A%0A    @Test%0A    public void associateThenDisassociateWithNoChanges() throws Exception %7B%0A        CutoutViewIndicator indicator = mock(CutoutViewIndicator.class);%0A%0A%0A        // Setup%0A%0A        indicator.dataSetObserver = mock(DataSetObserver.class);%0A        indicator.stateProxy = new UnavailableProxy();%0A        ViewTreeObserver vtoMock = mock(ViewTreeObserver.class);%0A%0A        when(indicator.getViewTreeObserver()).thenReturn(vtoMock);%0A        doCallRealMethod().when(indicator).setStateProxy(any(StateProxy.class));%0A%0A        StateProxy proxyA = mock(StateProxy.class);%0A        when(proxyA.canObserve(any(DataSetObserver.class))).thenReturn(false);%0A%0A        StateProxy proxyB = mock(StateProxy.class);%0A        when(proxyB.canObserve(any(DataSetObserver.class))).thenReturn(true);%0A%0A%0A        // The test%0A%0A        indicator.setStateProxy(proxyA);%0A%0A        verify(proxyA).canObserve(any(DataSetObserver.class));%0A        verify(proxyA, never()).associateWith(any(DataSetObserver.class));%0A%0A        indicator.setStateProxy(proxyB);%0A%0A        verify(proxyA, never()).disassociateFrom(any(DataSetObserver.class));%0A%0A        verify(proxyB).canObserve(any(DataSetObserver.class));%0A        verify(proxyB).associateWith(any(DataSetObserver.class));%0A    %7D%0A%7D%0A

Test whether StateProxies are associated and disassociated correctly