summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2020-06-12 13:46:19 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2020-06-12 13:46:19 -0400
commitfe0b4dd829c6f2c1598102638f877b1da8595276 (patch)
treee558eddb1d78aecfc847927ad2ae586c19c077c3 /android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset
parent1b15fb34eceec0b7715477c23f9073824638719c (diff)
downloadsdl_android-fe0b4dd829c6f2c1598102638f877b1da8595276.tar.gz
Fix unit tests
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset')
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java17
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java95
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java92
3 files changed, 81 insertions, 123 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java
index 1a9efffbe..31f16b315 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java
@@ -35,6 +35,7 @@
package com.smartdevicelink.managers.screen.choiceset;
+import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.file.FileManager;
@@ -52,7 +53,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.concurrent.LinkedBlockingQueue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -64,6 +64,7 @@ import static org.mockito.Mockito.when;
public class ChoiceSetManagerTests extends AndroidTestCase2 {
private ChoiceSetManager csm;
+ Taskmaster taskmaster;
@Override
public void setUp() throws Exception{
@@ -71,6 +72,8 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
ISdl internalInterface = mock(ISdl.class);
FileManager fileManager = mock(FileManager.class);
+ taskmaster = new Taskmaster.Builder().build();
+ when(internalInterface.getTaskmaster()).thenReturn(taskmaster);
csm = new ChoiceSetManager(internalInterface, fileManager);
assertEquals(csm.getState(), BaseSubManager.SETTING_UP);
@@ -83,7 +86,6 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
assertNotNull(csm.preloadedChoices);
assertNotNull(csm.pendingPreloadChoices);
assertNotNull(csm.operationQueue);
- assertNotNull(csm.executor);
assertNotNull(csm.hmiListener);
assertNotNull(csm.onDisplayCapabilityListener);
assertNull(csm.pendingPresentOperation);
@@ -100,10 +102,9 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
assertNull(csm.pendingPresentationSet);
assertNull(csm.pendingPresentOperation);
- assertEquals(csm.operationQueue.size(), 0);
+ assertEquals(csm.operationQueue.getTasksAsList().size(), 0);
assertEquals(csm.nextChoiceId, 1);
- assertTrue(csm.executor.isShutdown());
assertFalse(csm.isVROptional);
assertEquals(csm.getState(), BaseSubManager.SHUTDOWN);
@@ -242,6 +243,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
public void testPresentingKeyboardShouldReturnCancelIDIfKeyboardCanBeSent() {
ISdl internalInterface = mock(ISdl.class);
+ when(internalInterface.getTaskmaster()).thenReturn(taskmaster);
FileManager fileManager = mock(FileManager.class);
ChoiceSetManager newCSM = new ChoiceSetManager(internalInterface, fileManager);
@@ -254,6 +256,7 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
public void testPresentingKeyboardShouldNotReturnCancelIDIfKeyboardCannotBeSent() {
ISdl internalInterface = mock(ISdl.class);
+ when(internalInterface.getTaskmaster()).thenReturn(taskmaster);
FileManager fileManager = mock(FileManager.class);
ChoiceSetManager newCSM = new ChoiceSetManager(internalInterface, fileManager);
@@ -278,17 +281,13 @@ public class ChoiceSetManagerTests extends AndroidTestCase2 {
// Currently executing operation
PresentKeyboardOperation testKeyboardOp = mock(PresentKeyboardOperation.class);
- doReturn(true).when(testKeyboardOp).isExecuting();
doReturn(96).when(testKeyboardOp).getCancelID();
csm.currentlyPresentedKeyboardOperation = testKeyboardOp;
// Queued operations
PresentKeyboardOperation testKeyboardOp2 = mock(PresentKeyboardOperation.class);
- doReturn(true).when(testKeyboardOp2).isExecuting();
doReturn(testCancelID).when(testKeyboardOp2).getCancelID();
- LinkedBlockingQueue<Runnable> testOperationQueue = new LinkedBlockingQueue<>();
- testOperationQueue.add(testKeyboardOp2);
- csm.operationQueue = testOperationQueue;
+ csm.currentlyPresentedKeyboardOperation = testKeyboardOp2;
// Queued operation should be canceled
csm.dismissKeyboard(testCancelID);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java
index d8cf5be9d..e3031376f 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java
@@ -35,6 +35,9 @@
package com.smartdevicelink.managers.screen.choiceset;
+import com.livio.taskmaster.Queue;
+import com.livio.taskmaster.Task;
+import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
@@ -54,9 +57,6 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.util.Collections;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
@@ -74,7 +74,8 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
private KeyboardListener keyboardListener;
private ChoiceSetSelectionListener choiceSetSelectionListener;
- private ExecutorService executor;
+ private Taskmaster taskmaster;
+ private Queue queue;
@Override
public void setUp() throws Exception{
@@ -89,7 +90,9 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
cell1.setChoiceId(0);
choiceSet = new ChoiceSet("Test", Collections.singletonList(cell1), choiceSetSelectionListener);
- executor = Executors.newCachedThreadPool();
+ taskmaster = new Taskmaster.Builder().build();
+ queue = taskmaster.createQueue("test", 100, false);
+ taskmaster.start();
}
@Override
@@ -135,18 +138,22 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
assertEquals(presentChoiceSetOperation.selectedCellRow, Integer.valueOf(0));
}
+ private void sleep() {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
public void testCancelingChoiceSetSuccessfullyIfThreadIsRunning(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
- executor.execute(presentChoiceSetOperation);
+ queue.add(presentChoiceSetOperation, false);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ sleep();
- assertTrue(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentChoiceSetOperation.getState());
choiceSet.cancel();
Answer<Void> cancelInteractionAnswer = new Answer<Void>() {
@@ -170,22 +177,16 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
verify(internalInterface, times(1)).sendRPC(any(CancelInteraction.class));
verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class));
- assertTrue(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentChoiceSetOperation.getState());
}
public void testCancelingChoiceSetUnsuccessfullyIfThreadIsRunning(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
- executor.execute(presentChoiceSetOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentChoiceSetOperation, false);
+ sleep();
- assertTrue(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentChoiceSetOperation.getState());
choiceSet.cancel();
Answer<Void> cancelInteractionAnswer = new Answer<Void>() {
@@ -209,9 +210,7 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
verify(internalInterface, times(1)).sendRPC(any(CancelInteraction.class));
verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class));
- assertTrue(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentChoiceSetOperation.getState());
}
public void testCancelingChoiceSetIfThreadHasFinished(){
@@ -219,37 +218,27 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
presentChoiceSetOperation.finishOperation();
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertTrue(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.FINISHED, presentChoiceSetOperation.getState());
choiceSet.cancel();
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertTrue(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.FINISHED, presentChoiceSetOperation.getState());
}
public void testCancelingChoiceSetIfThreadHasNotYetRun(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.BLOCKED, presentChoiceSetOperation.getState());
choiceSet.cancel();
// Once the operation has started
- executor.execute(presentChoiceSetOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentChoiceSetOperation, false);
+ sleep();
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertTrue(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.CANCELED, presentChoiceSetOperation.getState());
// Make sure neither a `CancelInteraction` or `PerformInteraction` RPC is ever sent
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
@@ -260,14 +249,10 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
// Cancel Interaction is only supported on RPC specs v.6.0.0+
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3));
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
- executor.execute(presentChoiceSetOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentChoiceSetOperation, false);
+ sleep();
- assertTrue(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentChoiceSetOperation.getState());
choiceSet.cancel();
@@ -280,23 +265,17 @@ public class PresentChoiceSetOperationTests extends AndroidTestCase2 {
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3));
presentChoiceSetOperation = new PresentChoiceSetOperation(internalInterface, choiceSet, InteractionMode.MANUAL_ONLY, null, null, choiceSetSelectionListener, Test.GENERAL_INTEGER);
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertFalse(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.BLOCKED, presentChoiceSetOperation.getState());
choiceSet.cancel();
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
// Once the operation has started
- executor.execute(presentChoiceSetOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentChoiceSetOperation, false);
+ sleep();
- assertFalse(presentChoiceSetOperation.isExecuting());
- assertTrue(presentChoiceSetOperation.isFinished());
- assertFalse(presentChoiceSetOperation.isCancelled());
+ assertEquals(Task.CANCELED, presentChoiceSetOperation.getState());
// Make sure neither a `CancelInteraction` or `PerformInteraction` RPC is ever sent
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java
index 486a1c361..72fd81bbc 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java
@@ -35,6 +35,9 @@
package com.smartdevicelink.managers.screen.choiceset;
+import com.livio.taskmaster.Queue;
+import com.livio.taskmaster.Task;
+import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
@@ -53,10 +56,6 @@ import com.smartdevicelink.test.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -71,7 +70,8 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
private KeyboardListener keyboardListener;
private ISdl internalInterface;
- private ExecutorService executor;
+ private Taskmaster taskmaster;
+ private Queue queue;
@Override
public void setUp() throws Exception{
@@ -95,7 +95,9 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
};
doAnswer(setGlobalPropertiesAnswer).when(internalInterface).sendRPC(any(SetGlobalProperties.class));
- executor = Executors.newCachedThreadPool();
+ taskmaster = new Taskmaster.Builder().build();
+ queue = taskmaster.createQueue("test", 100, false);
+ taskmaster.start();
}
@Override
@@ -123,17 +125,21 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
assertEquals(pi.getCancelID(), Test.GENERAL_INTEGER);
}
+ private void sleep() {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
public void testCancelingKeyboardSuccessfullyIfThreadIsRunning(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
- executor.execute(presentKeyboardOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentKeyboardOperation, false);
+ sleep();
- assertTrue(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentKeyboardOperation.getState());
presentKeyboardOperation.dismissKeyboard();
Answer<Void> cancelInteractionAnswer = new Answer<Void>() {
@@ -157,18 +163,14 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
verify(internalInterface, times(1)).sendRPC(any(CancelInteraction.class));
verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class));
- assertTrue(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentKeyboardOperation.getState());
}
public void testCancelingKeyboardUnsuccessfullyIfThreadIsRunning(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
- executor.execute(presentKeyboardOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentKeyboardOperation, false);
+ sleep();
presentKeyboardOperation.dismissKeyboard();
Answer<Void> cancelInteractionAnswer = new Answer<Void>() {
@@ -192,9 +194,7 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
verify(internalInterface, times(1)).sendRPC(any(CancelInteraction.class));
verify(internalInterface, times(1)).sendRPC(any(PerformInteraction.class));
- assertTrue(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentKeyboardOperation.getState());
}
public void testCancelingKeyboardIfThreadHasFinished(){
@@ -202,37 +202,27 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
presentKeyboardOperation.finishOperation();
- assertFalse(presentKeyboardOperation.isExecuting());
- assertTrue(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.FINISHED, presentKeyboardOperation.getState());
presentKeyboardOperation.dismissKeyboard();
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
- assertFalse(presentKeyboardOperation.isExecuting());
- assertTrue(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.FINISHED, presentKeyboardOperation.getState());
}
public void testCancelingKeyboardIfThreadHasNotYetRun(){
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
- assertFalse(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.BLOCKED, presentKeyboardOperation.getState());
presentKeyboardOperation.dismissKeyboard();
// Once the operation has started
- executor.execute(presentKeyboardOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentKeyboardOperation, false);
+ sleep();
- assertFalse(presentKeyboardOperation.isExecuting());
- assertTrue(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.CANCELED, presentKeyboardOperation.getState());
// Make sure neither a `CancelInteraction` or `PerformInteraction` RPC is ever sent
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
@@ -243,14 +233,10 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
// Cancel Interaction is only supported on RPC specs v.6.0.0+
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3));
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
- executor.execute(presentKeyboardOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentKeyboardOperation, false);
+ sleep();
- assertTrue(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.IN_PROGRESS, presentKeyboardOperation.getState());
presentKeyboardOperation.dismissKeyboard();
@@ -263,23 +249,17 @@ public class PresentKeyboardOperationTests extends AndroidTestCase2 {
when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 3));
presentKeyboardOperation = new PresentKeyboardOperation(internalInterface, null, "Test", null, null, Test.GENERAL_INTEGER);
- assertFalse(presentKeyboardOperation.isExecuting());
- assertFalse(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.BLOCKED, presentKeyboardOperation.getState());
presentKeyboardOperation.dismissKeyboard();
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));
// Once the operation has started
- executor.execute(presentKeyboardOperation);
- try {
- executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (InterruptedException e) {}
+ queue.add(presentKeyboardOperation, false);
+ sleep();
- assertFalse(presentKeyboardOperation.isExecuting());
- assertTrue(presentKeyboardOperation.isFinished());
- assertFalse(presentKeyboardOperation.isCancelled());
+ assertEquals(Task.CANCELED, presentKeyboardOperation.getState());
// Make sure neither a `CancelInteraction` or `PerformInteraction` RPC is ever sent
verify(internalInterface, never()).sendRPC(any(CancelInteraction.class));