Loading services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.shadow.api.Shadow.extract; import static org.testng.Assert.fail; import static org.testng.Assert.expectThrows; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.util.Collections.emptyList; Loading Loading @@ -1941,6 +1942,29 @@ public class KeyValueBackupTaskTest { task.markCancel(); } @Test public void testHandleCancel_callsMarkCancelAndWaitCancel() throws Exception { TransportMock transportMock = setUpInitializedTransport(mTransport); setUpAgentWithData(PACKAGE_1); KeyValueBackupTask task = spy(createKeyValueBackupTask(transportMock, PACKAGE_1)); doNothing().when(task).waitCancel(); task.handleCancel(true); InOrder inOrder = inOrder(task); inOrder.verify(task).markCancel(); inOrder.verify(task).waitCancel(); } @Test public void testHandleCancel_whenCancelAllFalse_throws() throws Exception { TransportMock transportMock = setUpInitializedTransport(mTransport); setUpAgentWithData(PACKAGE_1); KeyValueBackupTask task = createKeyValueBackupTask(transportMock, PACKAGE_1); expectThrows(IllegalArgumentException.class, () -> task.handleCancel(false)); } private void runTask(KeyValueBackupTask task) { // Pretend we are not on the main-thread to prevent RemoteCall from complaining mShadowMainLooper.setCurrentThread(false); Loading Loading
services/robotests/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.shadow.api.Shadow.extract; import static org.testng.Assert.fail; import static org.testng.Assert.expectThrows; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.util.Collections.emptyList; Loading Loading @@ -1941,6 +1942,29 @@ public class KeyValueBackupTaskTest { task.markCancel(); } @Test public void testHandleCancel_callsMarkCancelAndWaitCancel() throws Exception { TransportMock transportMock = setUpInitializedTransport(mTransport); setUpAgentWithData(PACKAGE_1); KeyValueBackupTask task = spy(createKeyValueBackupTask(transportMock, PACKAGE_1)); doNothing().when(task).waitCancel(); task.handleCancel(true); InOrder inOrder = inOrder(task); inOrder.verify(task).markCancel(); inOrder.verify(task).waitCancel(); } @Test public void testHandleCancel_whenCancelAllFalse_throws() throws Exception { TransportMock transportMock = setUpInitializedTransport(mTransport); setUpAgentWithData(PACKAGE_1); KeyValueBackupTask task = createKeyValueBackupTask(transportMock, PACKAGE_1); expectThrows(IllegalArgumentException.class, () -> task.handleCancel(false)); } private void runTask(KeyValueBackupTask task) { // Pretend we are not on the main-thread to prevent RemoteCall from complaining mShadowMainLooper.setCurrentThread(false); Loading