CTS tests for CommandRequest & supportsCommands() API in VoiceInteractor.

Change-Id: I8c808909bf9cfb3c3d4cb16abb73a13dde0dfe93
diff --git a/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java b/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java
index 4ef0c03..ff3bcfd 100644
--- a/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java
+++ b/tests/tests/voiceinteraction/common/src/android/voiceinteraction/common/Utils.java
@@ -34,6 +34,7 @@
         PICKOPTION_REQUEST_CANCEL_TEST,
         COMMANDREQUEST_TEST,
         COMMANDREQUEST_CANCEL_TEST,
+        SUPPORTS_COMMANDS_TEST,
     }
     public static final String TESTCASE_TYPE = "testcase_type";
     public static final String TESTINFO = "testinfo";
@@ -51,6 +52,7 @@
     public static final String ABORT_REQUEST_SUCCESS = "abort ok";
     public static final String PICKOPTION_REQUEST_SUCCESS = "pickoption ok";
     public static final String COMMANDREQUEST_SUCCESS = "commandrequest ok";
+    public static final String SUPPORTS_COMMANDS_SUCCESS = "supportsCommands ok";
 
     public static final String CONFIRMATION_REQUEST_CANCEL_SUCCESS = "confirm cancel ok";
     public static final String COMPLETION_REQUEST_CANCEL_SUCCESS = "completion canel ok";
diff --git a/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainInteractionSession.java b/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainInteractionSession.java
index a5068e0..eeb4047 100644
--- a/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainInteractionSession.java
+++ b/tests/tests/voiceinteraction/service/src/android/voiceinteraction/service/MainInteractionSession.java
@@ -84,7 +84,7 @@
         Log.i(TAG, "in onGetSupportedCommands");
         for (int idx = 0; idx < commands.length; idx++) {
             results[idx] = Utils.TEST_COMMAND.equals(commands[idx]);
-            Log.i(TAG, "command is " + commands[idx]);
+            Log.i(TAG, "command " + commands[idx] + ", support = " + results[idx]);
         }
         return results;
     }
diff --git a/tests/tests/voiceinteraction/src/android/voiceinteraction/cts/VoiceInteractionTest.java b/tests/tests/voiceinteraction/src/android/voiceinteraction/cts/VoiceInteractionTest.java
index 2badb27..0fa89e1 100644
--- a/tests/tests/voiceinteraction/src/android/voiceinteraction/cts/VoiceInteractionTest.java
+++ b/tests/tests/voiceinteraction/src/android/voiceinteraction/cts/VoiceInteractionTest.java
@@ -91,7 +91,7 @@
                 verifySingleTestcaseResult(t, singleResult);
             }
         }
-        assertEquals(2, numFails);
+        assertEquals(0, numFails);
         mTestActivity.finish();
     }
 
@@ -128,6 +128,9 @@
           case PICKOPTION_REQUEST_TEST:
               assertTrue(result.equals(Utils.PICKOPTION_REQUEST_SUCCESS));
               break;
+          case SUPPORTS_COMMANDS_TEST:
+              assertTrue(result.equals(Utils.SUPPORTS_COMMANDS_SUCCESS));
+              break;
           default:
               Log.wtf(TAG, "not expected");
               break;
diff --git a/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java b/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
index 47ec2236..1ef6a5c 100644
--- a/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
+++ b/tests/tests/voiceinteraction/testapp/src/android/voiceinteraction/testapp/TestApp.java
@@ -92,6 +92,19 @@
 
           case COMMANDREQUEST_TEST:
           case COMMANDREQUEST_CANCEL_TEST:
+              commandRequest();
+              break;
+
+          case SUPPORTS_COMMANDS_TEST:
+              String[] commands = {Utils.TEST_COMMAND};
+              boolean[] supported = mInteractor.supportsCommands(commands);
+              Log.i(TAG, "from supportsCommands: " + supported);
+              if (supported.length == 1 && supported[0]) {
+                addTestResult(Utils.SUPPORTS_COMMANDS_SUCCESS);
+              } else {
+                addTestResult(Utils.TEST_ERROR + " supported commands failure!");
+              }
+              saveTestResults();
               continueTests();
               break;
         }
@@ -234,10 +247,6 @@
     }
 
     private void commandRequest() {
-        // uncomment these lines once CommandRequest is working. b/22124996
-//        Log.i(TAG, "from supportsCommands: " + mInteractor.supportsCommands(commands));
-//        String[] commands = {Utils.TEST_COMMAND};
-
         CommandRequest req = new VoiceInteractor.CommandRequest(Utils.TEST_COMMAND, mTestinfo) {
             @Override
             public void onCancel() {