Loading services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class VibratorControlServiceTest { @Mock private PackageManagerInternal mPackageManagerInternalMock; private TestLooper mTestLooper; private FakeVibratorController mFakeVibratorController; private VibratorControlService mVibratorControlService; private VibrationSettings mVibrationSettings; Loading @@ -74,6 +75,7 @@ public class VibratorControlServiceTest { @Before public void setUp() throws Exception { mTestLooper = new TestLooper(); when(mPackageManagerInternalMock.getSystemUiServiceComponent()) .thenReturn(new ComponentName("", "")); LocalServices.removeServiceForTest(PackageManagerInternal.class); Loading @@ -83,7 +85,7 @@ public class VibratorControlServiceTest { mVibrationSettings = new VibrationSettings( ApplicationProvider.getApplicationContext(), new Handler(testLooper.getLooper())); mFakeVibratorController = new FakeVibratorController(); mFakeVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControlService = new VibratorControlService(new VibratorControllerHolder(), mMockVibrationScaler, mVibrationSettings, mLock); } Loading @@ -108,13 +110,13 @@ public class VibratorControlServiceTest { @Test public void testUnregisterVibratorController_providingAnInvalidController_ignoresRequest() throws RemoteException { FakeVibratorController fakeController1 = new FakeVibratorController(); FakeVibratorController fakeController2 = new FakeVibratorController(); mVibratorControlService.registerVibratorController(fakeController1); mVibratorControlService.unregisterVibratorController(fakeController2); FakeVibratorController controller1 = new FakeVibratorController(mTestLooper.getLooper()); FakeVibratorController controller2 = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControlService.registerVibratorController(controller1); mVibratorControlService.unregisterVibratorController(controller2); verifyZeroInteractions(mMockVibrationScaler); assertThat(fakeController1.isLinkedToDeath).isTrue(); assertThat(controller1.isLinkedToDeath).isTrue(); } @Test Loading services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java +11 −10 Original line number Diff line number Diff line Loading @@ -18,23 +18,26 @@ package com.android.server.vibrator; import static com.google.common.truth.Truth.assertThat; import android.os.RemoteException; import android.os.test.TestLooper; import org.junit.Before; import org.junit.Test; public class VibratorControllerHolderTest { private final FakeVibratorController mFakeVibratorController = new FakeVibratorController(); private TestLooper mTestLooper; private FakeVibratorController mFakeVibratorController; private VibratorControllerHolder mVibratorControllerHolder; @Before public void setUp() throws Exception { mTestLooper = new TestLooper(); mFakeVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControllerHolder = new VibratorControllerHolder(); } @Test public void testSetVibratorController_linksVibratorControllerToDeath() throws RemoteException { public void testSetVibratorController_linksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); assertThat(mVibratorControllerHolder.getVibratorController()) .isEqualTo(mFakeVibratorController); Loading @@ -42,8 +45,7 @@ public class VibratorControllerHolderTest { } @Test public void testSetVibratorController_setControllerToNull_unlinksVibratorControllerToDeath() throws RemoteException { public void testSetVibratorController_setControllerToNull_unlinksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); mVibratorControllerHolder.setVibratorController(null); assertThat(mFakeVibratorController.isLinkedToDeath).isFalse(); Loading @@ -51,8 +53,7 @@ public class VibratorControllerHolderTest { } @Test public void testBinderDied_withValidController_unlinksVibratorControllerToDeath() throws RemoteException { public void testBinderDied_withValidController_unlinksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); mVibratorControllerHolder.binderDied(mFakeVibratorController); assertThat(mFakeVibratorController.isLinkedToDeath).isFalse(); Loading @@ -60,10 +61,10 @@ public class VibratorControllerHolderTest { } @Test public void testBinderDied_withInvalidController_ignoresRequest() throws RemoteException { public void testBinderDied_withInvalidController_ignoresRequest() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); FakeVibratorController imposterVibratorController = new FakeVibratorController(); FakeVibratorController imposterVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControllerHolder.binderDied(imposterVibratorController); assertThat(mFakeVibratorController.isLinkedToDeath).isTrue(); assertThat(mVibratorControllerHolder.getVibratorController()) Loading Loading
services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class VibratorControlServiceTest { @Mock private PackageManagerInternal mPackageManagerInternalMock; private TestLooper mTestLooper; private FakeVibratorController mFakeVibratorController; private VibratorControlService mVibratorControlService; private VibrationSettings mVibrationSettings; Loading @@ -74,6 +75,7 @@ public class VibratorControlServiceTest { @Before public void setUp() throws Exception { mTestLooper = new TestLooper(); when(mPackageManagerInternalMock.getSystemUiServiceComponent()) .thenReturn(new ComponentName("", "")); LocalServices.removeServiceForTest(PackageManagerInternal.class); Loading @@ -83,7 +85,7 @@ public class VibratorControlServiceTest { mVibrationSettings = new VibrationSettings( ApplicationProvider.getApplicationContext(), new Handler(testLooper.getLooper())); mFakeVibratorController = new FakeVibratorController(); mFakeVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControlService = new VibratorControlService(new VibratorControllerHolder(), mMockVibrationScaler, mVibrationSettings, mLock); } Loading @@ -108,13 +110,13 @@ public class VibratorControlServiceTest { @Test public void testUnregisterVibratorController_providingAnInvalidController_ignoresRequest() throws RemoteException { FakeVibratorController fakeController1 = new FakeVibratorController(); FakeVibratorController fakeController2 = new FakeVibratorController(); mVibratorControlService.registerVibratorController(fakeController1); mVibratorControlService.unregisterVibratorController(fakeController2); FakeVibratorController controller1 = new FakeVibratorController(mTestLooper.getLooper()); FakeVibratorController controller2 = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControlService.registerVibratorController(controller1); mVibratorControlService.unregisterVibratorController(controller2); verifyZeroInteractions(mMockVibrationScaler); assertThat(fakeController1.isLinkedToDeath).isTrue(); assertThat(controller1.isLinkedToDeath).isTrue(); } @Test Loading
services/tests/vibrator/src/com/android/server/vibrator/VibratorControllerHolderTest.java +11 −10 Original line number Diff line number Diff line Loading @@ -18,23 +18,26 @@ package com.android.server.vibrator; import static com.google.common.truth.Truth.assertThat; import android.os.RemoteException; import android.os.test.TestLooper; import org.junit.Before; import org.junit.Test; public class VibratorControllerHolderTest { private final FakeVibratorController mFakeVibratorController = new FakeVibratorController(); private TestLooper mTestLooper; private FakeVibratorController mFakeVibratorController; private VibratorControllerHolder mVibratorControllerHolder; @Before public void setUp() throws Exception { mTestLooper = new TestLooper(); mFakeVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControllerHolder = new VibratorControllerHolder(); } @Test public void testSetVibratorController_linksVibratorControllerToDeath() throws RemoteException { public void testSetVibratorController_linksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); assertThat(mVibratorControllerHolder.getVibratorController()) .isEqualTo(mFakeVibratorController); Loading @@ -42,8 +45,7 @@ public class VibratorControllerHolderTest { } @Test public void testSetVibratorController_setControllerToNull_unlinksVibratorControllerToDeath() throws RemoteException { public void testSetVibratorController_setControllerToNull_unlinksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); mVibratorControllerHolder.setVibratorController(null); assertThat(mFakeVibratorController.isLinkedToDeath).isFalse(); Loading @@ -51,8 +53,7 @@ public class VibratorControllerHolderTest { } @Test public void testBinderDied_withValidController_unlinksVibratorControllerToDeath() throws RemoteException { public void testBinderDied_withValidController_unlinksVibratorControllerToDeath() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); mVibratorControllerHolder.binderDied(mFakeVibratorController); assertThat(mFakeVibratorController.isLinkedToDeath).isFalse(); Loading @@ -60,10 +61,10 @@ public class VibratorControllerHolderTest { } @Test public void testBinderDied_withInvalidController_ignoresRequest() throws RemoteException { public void testBinderDied_withInvalidController_ignoresRequest() { mVibratorControllerHolder.setVibratorController(mFakeVibratorController); FakeVibratorController imposterVibratorController = new FakeVibratorController(); FakeVibratorController imposterVibratorController = new FakeVibratorController(mTestLooper.getLooper()); mVibratorControllerHolder.binderDied(imposterVibratorController); assertThat(mFakeVibratorController.isLinkedToDeath).isTrue(); assertThat(mVibratorControllerHolder.getVibratorController()) Loading