Merge "merge adb unit / stress tests" into jb-mr2-dev
diff --git a/tests/res/layout/view_layout.xml b/tests/res/layout/view_layout.xml
index 6d990ad..4443ba8 100644
--- a/tests/res/layout/view_layout.xml
+++ b/tests/res/layout/view_layout.xml
@@ -25,8 +25,8 @@
<android.view.cts.MockView
android:id="@+id/mock_view"
- android:layout_width="100dp"
- android:layout_height="200dp"/>
+ android:layout_width="100px"
+ android:layout_height="200px"/>
<android.view.cts.MockView
android:id="@+id/scroll_view"
diff --git a/tests/tests/nativeopengl/AndroidManifest.xml b/tests/tests/nativeopengl/AndroidManifest.xml
index 52157b4..72d87ac 100644
--- a/tests/tests/nativeopengl/AndroidManifest.xml
+++ b/tests/tests/nativeopengl/AndroidManifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/tests/tests/nativeopengl/libnativeopengltests/Android.mk b/tests/tests/nativeopengl/libnativeopengltests/Android.mk
index b6ca1cb..c9e10c4 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/Android.mk
+++ b/tests/tests/nativeopengl/libnativeopengltests/Android.mk
@@ -16,7 +16,7 @@
# This is the shared library included by the JNI test app.
#
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH:= $(call my-dir)/../standalone/jni/
include $(CLEAR_VARS)
@@ -34,14 +34,13 @@
LOCAL_SRC_FILES := \
register.cpp \
GLTestHelper.cpp \
- android_test_wrappedgtest_WrappedGTestActivity.cpp \
- com_android_opengl_cts_GLTestActivity.cpp \
tests/GLTest_test.cpp
LOCAL_SHARED_LIBRARIES := libEGL \
libGLESv2 \
libstlport \
- libandroid
+ libandroid \
+ liblog
LOCAL_STATIC_LIBRARIES := libgtest
diff --git a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp b/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp
deleted file mode 100644
index ed527a6..0000000
--- a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-
-#include "GLTestHelper.h"
-
-using namespace android;
-
-ANativeWindow* GLTestHelper::mWindow;
-
-ANativeWindow* GLTestHelper::getWindow() {
- return mWindow;
-}
-
-void GLTestHelper::setWindow(ANativeWindow* value) {
- mWindow = value;
-}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp b/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp
deleted file mode 100644
index 5e1c30e..0000000
--- a/tests/tests/nativeopengl/libnativeopengltests/android_test_wrappedgtest_WrappedGTestActivity.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-#include <android/log.h>
-#include <gtest/gtest.h>
-#include <jni.h>
-
-using namespace testing;
-
-class GTestListener : public EmptyTestEventListener {
-public:
- GTestListener(JNIEnv *env, jobject activity)
- : mActivity(activity), mEnv(env) {
-
- jclass clazz = env->FindClass(
- "android/test/wrappedgtest/WrappedGTestActivity");
- mSendStatusID = env->GetMethodID(clazz, "sendStatus",
- "(Ljava/lang/String;)V");
- mMessageBuffer = new char[2048];
- }
-
- ~GTestListener() {
- delete[] mMessageBuffer;
- }
-
-private:
- jobject mActivity;
- JNIEnv * mEnv;
- jmethodID mSendStatusID;
- char * mMessageBuffer;
-
- virtual void OnTestIterationStart(const UnitTest& unit_test,
- int iteration) {
- snprintf(mMessageBuffer, sizeof(char) * 2048,
- "[==========] Running %i tests from %i test cases.",
- unit_test.test_to_run_count(),
- unit_test.test_case_to_run_count());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestStart(const TestInfo& test_info) {
- snprintf(mMessageBuffer, sizeof(char) * 2048, "[ RUN ] %s.%s",
- test_info.test_case_name(), test_info.name());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestPartResult(const TestPartResult& result) {
- if (result.type() == TestPartResult::kSuccess) {
- return;
- }
-
- snprintf(mMessageBuffer, sizeof(char) * 2048, "%s:%i: Failure\n%s",
- result.file_name(), result.line_number(), result.message());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestEnd(const TestInfo& test_info) {
- const char * result = test_info.result()->Passed() ?
- "[ OK ] " : "[ FAILED ] ";
-
- snprintf(mMessageBuffer, sizeof(char) * 2048, "%s%s.%s (%lli ms)",
- result, test_info.test_case_name(), test_info.name(),
- test_info.result()->elapsed_time());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-
- virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
- snprintf(mMessageBuffer, sizeof(char) * 2048,
- "[==========] %i tests from %i test cases ran. (%lli ms total)",
- unit_test.test_to_run_count(),
- unit_test.test_case_to_run_count(), unit_test.elapsed_time());
-
- mEnv->CallVoidMethod(mActivity, mSendStatusID,
- mEnv->NewStringUTF(mMessageBuffer));
- }
-};
-
-static jboolean WrappedGTestActivity_runTests(JNIEnv *env, jobject obj,
- jobject activity) {
- // init gtest with no args
- int argc = 0;
- InitGoogleTest(&argc, (char**)NULL);
-
- // delete the default listener
- TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
- delete listeners.Release(listeners.default_result_printer());
-
- // add custom listener
- GTestListener * listener = new GTestListener(env, activity);
- listeners.Append(listener);
-
- // run tests
- int result = RUN_ALL_TESTS();
-
- delete listener;
- return result;
-};
-
-static JNINativeMethod methods[] = {
- // name, signature, function
- { "runTests", "(Landroid/test/wrappedgtest/WrappedGTestActivity;)I", (void*)WrappedGTestActivity_runTests },
-};
-
-int register_WrappedGTestActivity(JNIEnv *env) {
- return env->RegisterNatives(
- env->FindClass("android/test/wrappedgtest/WrappedGTestActivity"),
- methods, sizeof(methods) / sizeof(JNINativeMethod));
-};
diff --git a/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp b/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp
deleted file mode 100644
index 8544f2a..0000000
--- a/tests/tests/nativeopengl/libnativeopengltests/com_android_opengl_cts_GLTestActivity.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-
-#include <gtest/gtest.h>
-#include <jni.h>
-
-#include "GLTestHelper.h"
-#include <android/native_window_jni.h>
-
-using namespace android;
-
-static void GLTestActivity_setSurface(JNIEnv *env, jobject obj,
- jobject surface) {
- ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
- GLTestHelper::setWindow(window);
-};
-
-static JNINativeMethod methods[] = {
- // name, signature, function
- { "setSurface", "(Landroid/view/Surface;)V", (void*)GLTestActivity_setSurface },
-};
-
-int register_GLTestActivity(JNIEnv *env) {
- return env->RegisterNatives(
- env->FindClass("com/android/opengl/cts/GLTestActivity"),
- methods, sizeof(methods) / sizeof(JNINativeMethod));
-};
diff --git a/tests/tests/nativeopengl/standalone/AndroidManifest.xml b/tests/tests/nativeopengl/standalone/AndroidManifest.xml
new file mode 100644
index 0000000..a82e42a
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * 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.
+ */
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.gltest"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="15" />
+
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+
+ <application>
+ <activity android:name=".GLTestActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/tests/tests/nativeopengl/standalone/jni/Android.mk b/tests/tests/nativeopengl/standalone/jni/Android.mk
new file mode 100644
index 0000000..c23a1df
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/Android.mk
@@ -0,0 +1,48 @@
+# Copyright 2013 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.
+#
+
+MY_LOCAL_PATH := $(call my-dir)
+MY_GTEST_PATH := $(MY_LOCAL_PATH)/../../../../../../external/gtest
+
+# gtest
+
+LOCAL_PATH := $(MY_GTEST_PATH)
+
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_MODULE := libgtest
+LOCAL_C_INCLUDES := $(MY_GTEST_PATH)/include
+LOCAL_SRC_FILES := src/gtest-all.cc
+
+include $(BUILD_SHARED_LIBRARY)
+
+# nativetests
+
+LOCAL_PATH := $(MY_LOCAL_PATH)
+
+include $(CLEAR_VARS)
+
+LIB_PATH := $(LOCAL_PATH)/../libs/$(TARGET_ARCH_ABI)/
+LOCAL_C_INCLUDES := $(MY_GTEST_PATH)/include
+LOCAL_LDLIBS := -L$(LIB_PATH) -landroid -lEGL -lGLESv2 -llog -lgtest
+LOCAL_MODULE := nativeopengltests
+LOCAL_SRC_FILES := GLTestHelper.cpp \
+ register.cpp \
+ tests/GLTest_test.cpp
+
+LOCAL_SHARE_LIBRARIES := libgtest
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/nativeopengl/standalone/jni/Application.mk b/tests/tests/nativeopengl/standalone/jni/Application.mk
new file mode 100644
index 0000000..76d05a7
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/Application.mk
@@ -0,0 +1,16 @@
+# Copyright 2013 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.
+#
+
+APP_STL := stlport_shared
diff --git a/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp
new file mode 100644
index 0000000..d1f29d5
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.cpp
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2013 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.
+ */
+
+#define LOG_TAG "GLTest"
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+#include <android/log.h>
+#include <android/native_window.h>
+#include <GLTestHelper.h>
+
+// this listener is used to forward the subset of
+// gtest output needed to generate CTS results
+class CTSGTestListener : public EmptyTestEventListener {
+public:
+ CTSGTestListener(JNIEnv *env, jobject activity)
+ : mActivity(activity), mEnv(env) {
+
+ jclass clazz = env->FindClass(
+ "android/test/wrappedgtest/WrappedGTestActivity");
+ mSendStatusID = env->GetMethodID(clazz, "sendStatus",
+ "(Ljava/lang/String;)V");
+ mMessageBuffer = new char[2048];
+ }
+
+ ~CTSGTestListener() {
+ delete[] mMessageBuffer;
+ }
+
+private:
+ jobject mActivity;
+ JNIEnv * mEnv;
+ jmethodID mSendStatusID;
+ char * mMessageBuffer;
+
+ virtual void OnTestIterationStart(const UnitTest& unit_test,
+ int iteration) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048,
+ "[==========] Running %i tests from %i test cases.",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestStart(const TestInfo& test_info) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "[ RUN ] %s.%s",
+ test_info.test_case_name(), test_info.name());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestPartResult(const TestPartResult& result) {
+ if (result.type() == TestPartResult::kSuccess) {
+ return;
+ }
+
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "%s:%i: Failure\n%s",
+ result.file_name(), result.line_number(), result.message());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestEnd(const TestInfo& test_info) {
+ const char * result = test_info.result()->Passed() ?
+ "[ OK ] " : "[ FAILED ] ";
+
+ snprintf(mMessageBuffer, sizeof(char) * 2048, "%s%s.%s (%lli ms)",
+ result, test_info.test_case_name(), test_info.name(),
+ test_info.result()->elapsed_time());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+
+ virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
+ snprintf(mMessageBuffer, sizeof(char) * 2048,
+ "[==========] %i tests from %i test cases ran. (%lli ms total)",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count(), unit_test.elapsed_time());
+
+ mEnv->CallVoidMethod(mActivity, mSendStatusID,
+ mEnv->NewStringUTF(mMessageBuffer));
+ }
+};
+
+// this listener is similar to the default gtest listener
+// but it outputs the results to the log instead of stdout
+class LogGTestListener : public EmptyTestEventListener {
+
+private:
+ virtual void OnTestIterationStart(const UnitTest& unit_test,
+ int iteration) {
+ LOGI("[==========] Running %i tests from %i test cases.\n",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count());
+ }
+
+ virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) {
+ LOGI("[==========] Global test environment set-up.\n");
+ }
+
+ virtual void OnTestCaseStart(const TestCase& test_case) {
+ LOGI("[----------] %i tests from %s\n",
+ test_case.test_to_run_count(),
+ test_case.name());
+
+ }
+
+ virtual void OnTestStart(const TestInfo& test_info) {
+ LOGI("[ RUN ] %s.%s\n", test_info.test_case_name(),
+ test_info.name());
+
+ }
+
+ virtual void OnTestPartResult(const TestPartResult& result) {
+ if (result.type() == TestPartResult::kSuccess) {
+ return;
+ }
+
+ LOGI("%s:%i: Failure\n%s\n", result.file_name(), result.line_number(),
+ result.message());
+ }
+
+ virtual void OnTestEnd(const TestInfo& test_info) {
+ const char * result = test_info.result()->Passed() ?
+ "[ OK ] " : "[ FAILED ] ";
+
+ LOGI("%s%s.%s (%lli ms)\n", result, test_info.test_case_name(),
+ test_info.name(), test_info.result()->elapsed_time());
+ }
+
+
+ virtual void OnTestCaseEnd(const TestCase& test_case) {
+ LOGI("[----------] %i tests from %s (%lli ms total)\n",
+ test_case.test_to_run_count(), test_case.name(),
+ test_case.elapsed_time());
+
+ }
+
+ virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) {
+ LOGI("[==========] Global test environment tear-down.\n");
+ }
+
+ void PrintFailedTests(const UnitTest& unit_test) {
+ const int failed_test_count = unit_test.failed_test_count();
+ if (failed_test_count == 0) {
+ return;
+ }
+
+ for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
+ const TestCase& test_case = *unit_test.GetTestCase(i);
+
+ if (!test_case.should_run() || test_case.failed_test_count() == 0) {
+ continue;
+ }
+
+ for (int j = 0; j < test_case.total_test_count(); ++j) {
+ const TestInfo& test_info = *test_case.GetTestInfo(j);
+ if (!test_info.should_run() || test_info.result()->Passed()) {
+ continue;
+ }
+ LOGI("[ FAILED ] %s.%s\n", test_case.name(),
+ test_info.name());
+ }
+ }
+ }
+ virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) {
+ LOGI("[==========] %i tests from %i test cases ran. (%lli ms total)\n",
+ unit_test.test_to_run_count(),
+ unit_test.test_case_to_run_count(), unit_test.elapsed_time());
+
+ LOGI("[ PASSED ] %i tests\n", unit_test.successful_test_count());
+
+ if(unit_test.Passed()) {
+ return;
+ }
+
+ LOGI("[ FAILED ] %i tests, listed below:\n",
+ unit_test.failed_test_count());
+
+ PrintFailedTests(unit_test);
+
+ LOGI("\n%2d FAILED TESTS\n", unit_test.failed_test_count());
+ }
+};
+
+ANativeWindow* GLTestHelper::mWindow;
+
+ANativeWindow* GLTestHelper::getWindow() {
+ return mWindow;
+}
+
+void GLTestHelper::setWindow(JNIEnv *env, jobject obj, jobject surface) {
+ mWindow = ANativeWindow_fromSurface(env, surface);
+}
+
+int GLTestHelper::runGTests(TestEventListener * listener, char * filter) {
+
+ if (filter) {
+ ::testing::GTEST_FLAG(filter) = filter;
+ }
+
+ int argc = 0;
+ InitGoogleTest(&argc, (char**)NULL);
+
+ TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
+ delete listeners.Release(listeners.default_result_printer());
+
+ listeners.Append(listener);
+ int result = RUN_ALL_TESTS();
+ return result;
+}
+
+int GLTestHelper::runTests(JNIEnv *env, jobject obj, jstring filter) {
+ LogGTestListener * listener = new LogGTestListener();
+
+ char * filter_cstr = NULL;
+
+ // set filter if there is one
+ if (filter) {
+ filter_cstr = new char[512];
+ const char * ptr = env->GetStringUTFChars(filter, NULL);
+ snprintf(filter_cstr, sizeof(char) * 512, "%s", ptr);
+ env->ReleaseStringUTFChars(filter, ptr);
+ }
+
+ int result = runGTests(listener, filter_cstr);
+
+ if (filter_cstr) {
+ delete[] filter_cstr;
+ }
+
+ delete listener;
+ return result;
+}
+
+int GLTestHelper::runTestsCTS(JNIEnv *env, jobject obj, jobject activity) {
+ CTSGTestListener * listener = new CTSGTestListener(env, activity);
+ int result = runGTests(listener, NULL);
+ delete listener;
+ return result;
+}
+
+int GLTestHelper::registerNative(JNIEnv * env) {
+
+ jclass clazz = env->FindClass("com/android/opengl/cts/GLTestActivity");
+
+ jthrowable exception = env->ExceptionOccurred();
+ // CTS class not found, assume stand-alone application
+ if (exception) {
+ env->ExceptionClear();
+
+ if (!env->IsInstanceOf(env->ExceptionOccurred(),
+ env->FindClass("java/lang/NoClassDefFoundError"))) {
+ env->Throw(exception);
+ }
+
+ //
+ JNINativeMethod standaloneMethods[] = {
+ // name, signature, function
+ { "setSurface", "(Landroid/view/Surface;)V", (void*)(GLTestHelper::setWindow) },
+ { "runTests", "(Ljava/lang/String;)V", (void*)(GLTestHelper::runTests) },
+ };
+
+ return env->RegisterNatives(
+ env->FindClass("com/android/gltest/GLTestActivity"),
+ standaloneMethods,
+ sizeof(standaloneMethods) / sizeof(JNINativeMethod));
+ }
+
+ // GLTestActivity methods
+ JNINativeMethod glTestActMethods[] = {
+ // name, signature, function
+ { "setSurface", "(Landroid/view/Surface;)V", (void*)(GLTestHelper::setWindow) },
+ };
+
+ int result = env->RegisterNatives(clazz, glTestActMethods,
+ sizeof(glTestActMethods) / sizeof(JNINativeMethod));
+
+ if (result) {
+ return result;
+ }
+
+ // WrappedGTestActivity methods
+ JNINativeMethod wrappedGTestActMethods[] = {
+ // name, signature, function
+ { "runTests", "(Landroid/test/wrappedgtest/WrappedGTestActivity;)I",
+ (void*)(GLTestHelper::runTestsCTS) },
+ };
+
+ return env->RegisterNatives(
+ env->FindClass("android/test/wrappedgtest/WrappedGTestActivity"),
+ wrappedGTestActMethods,
+ sizeof(wrappedGTestActMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
similarity index 63%
rename from tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h
rename to tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
index c0775f0..d09d2f1 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/GLTestHelper.h
+++ b/tests/tests/nativeopengl/standalone/jni/GLTestHelper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright 2013 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.
@@ -17,20 +17,22 @@
#ifndef ANDROID_GL_TEST_HELPER_H
#define ANDROID_GL_TEST_HELPER_H
-#include <stdint.h>
-#include <sys/types.h>
-#include <android/native_window.h>
-#include <utils/RefBase.h>
+#include <android/native_window_jni.h>
+#include <gtest/gtest.h>
-using namespace android;
+using namespace testing;
class GLTestHelper
{
private:
static ANativeWindow* mWindow;
+ static int runGTests(TestEventListener* listener, char * filter);
+ static int runTests(JNIEnv* env, jobject obj, jstring filter);
+ static int runTestsCTS(JNIEnv* env, jobject obj, jobject activity);
public:
static ANativeWindow* getWindow();
- static void setWindow(ANativeWindow* value);
+ static void setWindow(JNIEnv* env, jobject obj, jobject surface);
+ static int registerNative(JNIEnv* env);
};
diff --git a/tests/tests/nativeopengl/libnativeopengltests/register.cpp b/tests/tests/nativeopengl/standalone/jni/register.cpp
similarity index 77%
rename from tests/tests/nativeopengl/libnativeopengltests/register.cpp
rename to tests/tests/nativeopengl/standalone/jni/register.cpp
index 97a8bd4..8dd14ed 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/register.cpp
+++ b/tests/tests/nativeopengl/standalone/jni/register.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 The Android Open Source Project
+ * Copyright 2013 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.
@@ -15,7 +15,7 @@
*/
#include <jni.h>
-#include <stdlib.h>
+#include <GLTestHelper.h>
/*
* This function is called automatically by the system when this
@@ -29,13 +29,7 @@
return JNI_ERR;
}
- extern int register_WrappedGTestActivity(JNIEnv *);
- if (register_WrappedGTestActivity(env)) {
- return JNI_ERR;
- }
-
- extern int register_GLTestActivity(JNIEnv *);
- if (register_GLTestActivity(env)) {
+ if (GLTestHelper::registerNative(env)) {
return JNI_ERR;
}
diff --git a/tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp b/tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
similarity index 98%
rename from tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp
rename to tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
index 37bfcb5..5df090d 100644
--- a/tests/tests/nativeopengl/libnativeopengltests/tests/GLTest_test.cpp
+++ b/tests/tests/nativeopengl/standalone/jni/tests/GLTest_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 The Android Open Source Project
+ * Copyright 2013 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.
@@ -17,15 +17,15 @@
#include <android/native_window.h>
-#include <gtest/gtest.h>
-
#include <EGL/egl.h>
#include <EGL/eglext.h>
+
+#include <gtest/gtest.h>
+
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-
-#include "GLTestHelper.h"
+#include <GLTestHelper.h>
namespace android {
diff --git a/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java b/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java
new file mode 100644
index 0000000..3c1e2af
--- /dev/null
+++ b/tests/tests/nativeopengl/standalone/src/com/android/gltest/GLTestActivity.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2013 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.
+ */
+package com.android.gltest;
+
+import android.app.Activity;
+import android.app.KeyguardManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.Surface;
+
+public class GLTestActivity extends Activity {
+
+ private class TestThread extends Thread {
+
+ public void run() {
+ // it is possible to set the GTest filter flag from here
+ // for example "GLTest.ClearColorTest" to run that specific test only
+ runTests(null);
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+
+ finish();
+ System.exit(0);
+ }
+ }
+
+ private SurfaceView mSurfaceView;
+
+ private SurfaceHolder.Callback mHolderCallback = new SurfaceHolder.Callback() {
+
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ setSurface(holder.getSurface());
+ }
+
+ public void surfaceCreated(SurfaceHolder holder) {
+ setSurface(holder.getSurface());
+ Thread t = new TestThread();
+ t.start();
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
+ };
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ if (checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+ == PackageManager.PERMISSION_GRANTED) {
+ KeyguardManager keyguardManager =
+ (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
+ keyguardManager.newKeyguardLock("gltest").disableKeyguard();
+ }
+
+ super.onCreate(savedInstanceState);
+
+ mSurfaceView = new SurfaceView(this);
+ mSurfaceView.getHolder().addCallback(mHolderCallback);
+ setContentView(mSurfaceView);
+ System.loadLibrary("stlport_shared");
+ System.loadLibrary("gtest");
+ System.loadLibrary("nativeopengltests");
+ }
+
+ private static native void setSurface(Surface surface);
+ private static native void runTests(String filter);
+}
diff --git a/tests/tests/text/src/android/text/util/cts/LinkifyTest.java b/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
index 404f9d7..45111f2 100644
--- a/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
+++ b/tests/tests/text/src/android/text/util/cts/LinkifyTest.java
@@ -26,6 +26,7 @@
import android.text.util.Linkify.TransformFilter;
import android.widget.TextView;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -73,7 +74,6 @@
public void testAddLinks1() {
SpannableString spannable = new SpannableString("name@gmail.com, "
- + "123456789, tel:(0812)1234567 "
+ "www.google.com, http://www.google.com/language_tools?hl=en, ");
assertTrue(Linkify.addLinks(spannable, Linkify.WEB_URLS));
@@ -87,12 +87,6 @@
assertEquals(1, spans.length);
assertEquals("mailto:name@gmail.com", spans[0].getURL());
- assertTrue(Linkify.addLinks(spannable, Linkify.PHONE_NUMBERS));
- spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
- assertEquals(2, spans.length);
- assertEquals("tel:123456789", spans[0].getURL());
- assertEquals("tel:08121234567", spans[1].getURL());
-
try {
Linkify.addLinks((Spannable) null, Linkify.WEB_URLS);
fail("Should throw NullPointerException!");
@@ -304,4 +298,43 @@
assertEquals("test:FilterUpperCase.pattern", spans[0].getURL());
assertEquals("test:12", spans[1].getURL());
}
+
+ public void testAddLinks7() {
+ String numbersInvalid = "123456789 not a phone number";
+ String numbersUKLocal = "tel:(0812)1234560 (0812)1234561";
+ String numbersUSLocal = "tel:(812)1234562 (812)123.4563 "
+ + " tel:(800)5551210 (800) 555-1211 555-1212";
+ String numbersIntl = "tel:+4408121234564 +44-0812-123-4565"
+ + " tel:+18005551213 +1-800-555-1214";
+ SpannableString spannable = new SpannableString(
+ numbersInvalid
+ + " " + numbersUKLocal
+ + " " + numbersUSLocal
+ + " " + numbersIntl);
+
+ // phonenumber linkify is locale-dependent
+ if (Locale.US.equals(Locale.getDefault())) {
+ assertTrue(Linkify.addLinks(spannable, Linkify.PHONE_NUMBERS));
+ URLSpan[] spans = spannable.getSpans(0, spannable.length(), URLSpan.class);
+ assertEquals(9, spans.length);
+ assertEquals("tel:8121234562", spans[0].getURL());
+ assertEquals("tel:8121234563", spans[1].getURL());
+ assertEquals("tel:8005551210", spans[2].getURL());
+ assertEquals("tel:8005551211", spans[3].getURL());
+ assertEquals("tel:5551212", spans[4].getURL());
+ assertEquals("tel:+4408121234564", spans[5].getURL());
+ assertEquals("tel:+4408121234565", spans[6].getURL());
+ assertEquals("tel:+18005551213", spans[7].getURL());
+ assertEquals("tel:+18005551214", spans[8].getURL());
+ }
+
+ try {
+ Linkify.addLinks((Spannable) null, Linkify.WEB_URLS);
+ fail("Should throw NullPointerException!");
+ } catch (NullPointerException e) {
+ // expect
+ }
+
+ assertFalse(Linkify.addLinks((Spannable) null, 0));
+ }
}