Fix 4970300 OpenMAX AL and OpenSL ES libs checked in CTS

This CL reorganizes the native media tests for OpenSL ES and
 OpenMAX AL into two independent tests as they cannot share
 the same test set up.
The goal of these tests is simply to verify basic presence
 of the XA and SL libraries on the device under test by
 testing basic object creation.
The existing OpenSL ES tests are only moved, and OpenMAX AL
 test of engine and output mix creation are added.

Change-Id: Ic16166393513ef06ce153f4f423c593f80c129a8
diff --git a/tests/tests/nativemedia/Android.mk b/tests/tests/nativemedia/Android.mk
index 928ebcd..1d4ec7f 100644
--- a/tests/tests/nativemedia/Android.mk
+++ b/tests/tests/nativemedia/Android.mk
@@ -1,34 +1 @@
-# Build the unit tests.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
-    bionic \
-    bionic/libstdc++/include \
-    external/gtest/include \
-    system/media/wilhelm/include \
-    external/stlport/stlport \
-    system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
-    src/SLObjectCreationTest.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-  libutils \
-  libOpenSLES \
-  libstlport
-
-LOCAL_STATIC_LIBRARIES := \
-    libOpenSLESUT \
-    libgtest
-
-LOCAL_CFLAGS += -DXP_UNIX
-
-LOCAL_MODULE:= NativeMediaTest
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
-include $(BUILD_EXECUTABLE)
\ No newline at end of file
+include $(call all-subdir-makefiles)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
new file mode 100644
index 0000000..b68976e
--- /dev/null
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -0,0 +1,32 @@
+# Build the unit tests.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_C_INCLUDES:= \
+    bionic \
+    bionic/libstdc++/include \
+    external/gtest/include \
+    system/media/wilhelm/include \
+    external/stlport/stlport \
+    system/media/wilhelm/src/ut
+
+LOCAL_SRC_FILES:= \
+    src/SLObjectCreationTest.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+  libutils \
+  libOpenSLES \
+  libstlport
+
+LOCAL_STATIC_LIBRARIES := \
+    libOpenSLESUT \
+    libgtest
+
+LOCAL_MODULE:= NativeMediaTest_SL
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+
+include $(BUILD_EXECUTABLE)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/src/SLObjectCreationTest.cpp b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
similarity index 100%
rename from tests/tests/nativemedia/src/SLObjectCreationTest.cpp
rename to tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
new file mode 100644
index 0000000..36c7f6c
--- /dev/null
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -0,0 +1,31 @@
+# Build the unit tests.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_C_INCLUDES:= \
+    bionic \
+    bionic/libstdc++/include \
+    external/gtest/include \
+    system/media/wilhelm/include \
+    external/stlport/stlport \
+    system/media/wilhelm/src/ut
+
+LOCAL_SRC_FILES:= \
+    src/XAObjectCreationTest.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+  libutils \
+  libOpenMAXAL \
+  libstlport
+
+LOCAL_STATIC_LIBRARIES := \
+    libgtest
+
+LOCAL_MODULE:= NativeMediaTest_XA
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+
+include $(BUILD_EXECUTABLE)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
new file mode 100644
index 0000000..3ff84c2
--- /dev/null
+++ b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test for testing the creation of OpenMAX AL objects.
+ * The tests verify the creation and completion of the call to Realize() for the following objects:
+ *   - Engine
+ *   - OutputMix
+ */
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "XAObjectCreationTest"
+
+#include <utils/Log.h>
+#include "OMXAL/OpenMAXAL.h"
+#include "OMXAL/OpenMAXAL_Android.h"
+//#include <android/native_window_jni.h>
+#include <gtest/gtest.h>
+
+//-----------------------------------------------------------------
+/* Checks for error and displays the error code if any */
+bool IsOk(XAresult res) {
+    if (XA_RESULT_SUCCESS != res) {
+        fprintf(stderr, "IsOk failure: 0x%x, exiting\n", res);
+        return false;
+    }
+    return true;
+}
+
+//-----------------------------------------------------------------
+class XAObjectCreationTest : public ::testing::Test {
+
+protected:
+    XAresult res;
+    XAObjectItf engineObj, outputMixObj, mediaPlayerObj;
+    XAEngineItf engineItf;
+
+    XADataSource mediaSource;
+    XADataSink   audioSink;
+    XADataLocator_URI locatorUriSrc;
+    XADataLocator_AndroidBufferQueue locatorAbqSrc;
+    XADataLocator_AndroidFD locatorFdSrc;
+    XADataFormat_MIME formatMimeSrc;
+
+    XADataLocator_OutputMix locatorOutputmixSink;
+    XADataFormat_PCM formatPcmSink;
+
+    XADataLocator_NativeDisplay locatorVideoSink;
+    XADataSink imageSink;
+
+    //ANativeWindow* pNativeWindow;
+
+    XAObjectCreationTest() { }
+
+    virtual ~XAObjectCreationTest() { }
+
+    /* Test setup*/
+    virtual void SetUp() {
+        ALOGV("Test Setup()");
+        res = XA_RESULT_UNKNOWN_ERROR;
+        engineItf = NULL;
+        engineObj = NULL;
+        outputMixObj = NULL;
+        mediaPlayerObj = NULL;
+        // Engine creation
+        res = xaCreateEngine(&engineObj, 0, NULL, 0, NULL, NULL);
+        ASSERT_TRUE(IsOk(res));
+        res = (*engineObj)->Realize(engineObj, XA_BOOLEAN_FALSE);
+        ASSERT_TRUE(IsOk(res));
+        res = (*engineObj)->GetInterface(engineObj, XA_IID_ENGINE, &engineItf);
+        ASSERT_TRUE(IsOk(res));
+        ASSERT_TRUE(NULL != engineItf);
+    }
+
+    virtual void TearDown() {
+        ALOGV("Test TearDown()");
+        if (mediaPlayerObj) {
+            (*mediaPlayerObj)->Destroy(mediaPlayerObj);
+            mediaPlayerObj = NULL;
+        }
+        if (outputMixObj) {
+            (*outputMixObj)->Destroy(outputMixObj);
+            outputMixObj = NULL;
+        }
+        if (engineObj){
+            (*engineObj)->Destroy(engineObj);
+            engineObj = NULL;
+        }
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Tests
+
+    /* Test case for creating an MediaPlayer object */
+    void OutputMixCreation() {
+        res = (*engineItf)->CreateOutputMix(engineItf, &outputMixObj,
+                0, NULL/*iidArray*/, NULL/*required*/);
+        ASSERT_TRUE(IsOk(res));
+        ASSERT_TRUE(NULL != outputMixObj);
+        res = (*outputMixObj)->Realize(outputMixObj, XA_BOOLEAN_FALSE);
+        ASSERT_TRUE(IsOk(res));
+    }
+
+};
+
+//-------------------------------------------------------------------------------------------------
+TEST_F(XAObjectCreationTest, testEngineCreation) {
+    ALOGV("Test Fixture: EngineCreation");
+    // nothing to do here that isn't done in SetUp()
+}
+
+TEST_F(XAObjectCreationTest, testOutputMixCreation) {
+    ALOGV("Test Fixture: OutputMixCreation");
+    OutputMixCreation();
+}
+
+int main(int argc, char **argv) {
+    testing::InitGoogleTest(&argc, argv);
+
+    return RUN_ALL_TESTS();
+}
+