summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Bringert <bringert@android.com>2009-08-28 10:38:54 +0100
committerBjorn Bringert <bringert@android.com>2009-08-28 12:17:33 +0100
commitc754a9c29283657754f214693038d957f4b25d09 (patch)
tree6fe1494ef4d781f1991fa506888c01edd9d0c9b5
parent3ab07db0e97b569972ca8f993f8fa6cf19a596f9 (diff)
downloadGlobalSearch-c754a9c29283657754f214693038d957f4b25d09.tar.gz
Added slow and spammy test 3rd party suggestion sources
In order to test the behavior of GlobalSearch with evil third party suggestion sources, this change adds one source which delays for 20 seconds before returning some suggestions, and one that returns 100 spam suggestions for all queries. This is needed for verifying that http://b/issue?id=2085102 http://b/issue?id=2065157 http://b/issue?id=2085216 are fixed. Change-Id:I0ad925e49d37bee6c5aaa16926a56e61fe530201
-rw-r--r--tests/slow/Android.mk28
-rw-r--r--tests/slow/AndroidManifest.xml43
-rw-r--r--tests/slow/res/values/strings.xml21
-rw-r--r--tests/slow/res/xml/searchable.xml24
-rw-r--r--tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionLauncher.java35
-rw-r--r--tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionProvider.java90
-rw-r--r--tests/spammy/Android.mk28
-rw-r--r--tests/spammy/AndroidManifest.xml43
-rw-r--r--tests/spammy/res/values/strings.xml21
-rw-r--r--tests/spammy/res/xml/searchable.xml24
-rw-r--r--tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionLauncher.java35
-rw-r--r--tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionProvider.java84
12 files changed, 476 insertions, 0 deletions
diff --git a/tests/slow/Android.mk b/tests/slow/Android.mk
new file mode 100644
index 0000000..a93af43
--- /dev/null
+++ b/tests/slow/Android.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2009 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS :=
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := SlowSuggestions
+#LOCAL_CERTIFICATE := shared
+
+include $(BUILD_PACKAGE)
diff --git a/tests/slow/AndroidManifest.xml b/tests/slow/AndroidManifest.xml
new file mode 100644
index 0000000..ef90814
--- /dev/null
+++ b/tests/slow/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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.
+*/
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.globalsearch.tests.slow">
+
+ <application android:label="@string/app_label">
+ <activity android:name=".SlowSuggestionLauncher"
+ android:label="@string/app_label"
+ android:stateNotNeeded="true"
+ android:theme="@android:style/Theme.NoDisplay"
+ android:excludeFromRecents="true">
+
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/searchable" />
+ </activity>
+
+ <provider android:name=".SlowSuggestionProvider"
+ android:authorities="com.android.globalsearch.tests.slow" />
+ </application>
+
+</manifest>
diff --git a/tests/slow/res/values/strings.xml b/tests/slow/res/values/strings.xml
new file mode 100644
index 0000000..5750e99
--- /dev/null
+++ b/tests/slow/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_label">Slow Suggestions</string>
+ <string name="settings_description">Suggestions that take a long time to appear</string>
+
+</resources>
diff --git a/tests/slow/res/xml/searchable.xml b/tests/slow/res/xml/searchable.xml
new file mode 100644
index 0000000..76d9d91
--- /dev/null
+++ b/tests/slow/res/xml/searchable.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+ android:icon="@android:drawable/sym_def_app_icon"
+ android:label="@string/app_label"
+ android:includeInGlobalSearch="true"
+ android:searchSuggestAuthority="com.android.globalsearch.tests.slow"
+ android:searchSettingsDescription="@string/settings_description"
+>
+</searchable>
diff --git a/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionLauncher.java b/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionLauncher.java
new file mode 100644
index 0000000..e07d4eb
--- /dev/null
+++ b/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionLauncher.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2009 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.globalsearch.tests.slow;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+public class SlowSuggestionLauncher extends Activity {
+ private static final String TAG = SlowSuggestionLauncher.class.getSimpleName();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Intent intent = getIntent();
+ Log.i(TAG, "Launched a slow suggestion: " + intent);
+ finish();
+ }
+
+}
diff --git a/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionProvider.java b/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionProvider.java
new file mode 100644
index 0000000..a17f8d4
--- /dev/null
+++ b/tests/slow/src/com/android/globalsearch/tests/slow/SlowSuggestionProvider.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2009 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.globalsearch.tests.slow;
+
+import android.app.SearchManager;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.util.Log;
+
+public class SlowSuggestionProvider extends ContentProvider {
+
+ private static final String TAG = SlowSuggestionProvider.class.getSimpleName();
+
+ private static final String[] COLUMNS = {
+ "_id",
+ SearchManager.SUGGEST_COLUMN_TEXT_1,
+ SearchManager.SUGGEST_COLUMN_TEXT_2,
+ SearchManager.SUGGEST_COLUMN_INTENT_ACTION,
+ SearchManager.SUGGEST_COLUMN_INTENT_DATA,
+ };
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projectionIn, String selection,
+ String[] selectionArgs, String sortOrder) {
+ Log.d(TAG, "query(" + uri + ")");
+
+ try {
+ Thread.sleep(20000);
+ } catch (InterruptedException ex) {
+ Log.d(TAG, "Interrupted");
+ }
+
+ MatrixCursor cursor = new MatrixCursor(COLUMNS);
+ for (int i = 0; i < 3; i++) {
+ cursor.addRow(new Object[]{
+ i,
+ "Slow suggestion " + i,
+ "This suggestion takes a long time to appear",
+ Intent.ACTION_VIEW,
+ "content://com.android.globalsearch.slow/slow/" + i
+ });
+ }
+ return cursor;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return SearchManager.SUGGEST_MIME_TYPE;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/tests/spammy/Android.mk b/tests/spammy/Android.mk
new file mode 100644
index 0000000..2bdb697
--- /dev/null
+++ b/tests/spammy/Android.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2009 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS :=
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := SpammySuggestions
+#LOCAL_CERTIFICATE := shared
+
+include $(BUILD_PACKAGE)
diff --git a/tests/spammy/AndroidManifest.xml b/tests/spammy/AndroidManifest.xml
new file mode 100644
index 0000000..d428a28
--- /dev/null
+++ b/tests/spammy/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, 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.
+*/
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.globalsearch.tests.spammy">
+
+ <application android:label="@string/app_label">
+ <activity android:name=".SpammySuggestionLauncher"
+ android:label="@string/app_label"
+ android:stateNotNeeded="true"
+ android:theme="@android:style/Theme.NoDisplay"
+ android:excludeFromRecents="true">
+
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/searchable" />
+ </activity>
+
+ <provider android:name=".SpammySuggestionProvider"
+ android:authorities="com.android.globalsearch.tests.spammy" />
+ </application>
+
+</manifest>
diff --git a/tests/spammy/res/values/strings.xml b/tests/spammy/res/values/strings.xml
new file mode 100644
index 0000000..f6b2267
--- /dev/null
+++ b/tests/spammy/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_label">Spammy Suggestions</string>
+ <string name="settings_description">Lots of irrelevant suggestions</string>
+
+</resources>
diff --git a/tests/spammy/res/xml/searchable.xml b/tests/spammy/res/xml/searchable.xml
new file mode 100644
index 0000000..bffed34
--- /dev/null
+++ b/tests/spammy/res/xml/searchable.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+ android:icon="@android:drawable/sym_def_app_icon"
+ android:label="@string/app_label"
+ android:includeInGlobalSearch="true"
+ android:searchSuggestAuthority="com.android.globalsearch.tests.spammy"
+ android:searchSettingsDescription="@string/settings_description"
+>
+</searchable>
diff --git a/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionLauncher.java b/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionLauncher.java
new file mode 100644
index 0000000..1ba8eaa
--- /dev/null
+++ b/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionLauncher.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2009 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.globalsearch.tests.spammy;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+public class SpammySuggestionLauncher extends Activity {
+ private static final String TAG = SpammySuggestionLauncher.class.getSimpleName();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Intent intent = getIntent();
+ Log.i(TAG, "Launched a spammy suggestion: " + intent);
+ finish();
+ }
+
+}
diff --git a/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionProvider.java b/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionProvider.java
new file mode 100644
index 0000000..ab87969
--- /dev/null
+++ b/tests/spammy/src/com/android/globalsearch/tests/spammy/SpammySuggestionProvider.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 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.globalsearch.tests.spammy;
+
+import android.app.SearchManager;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.util.Log;
+
+public class SpammySuggestionProvider extends ContentProvider {
+
+ private static final String TAG = SpammySuggestionProvider.class.getSimpleName();
+
+ private static final String[] COLUMNS = {
+ "_id",
+ SearchManager.SUGGEST_COLUMN_TEXT_1,
+ SearchManager.SUGGEST_COLUMN_TEXT_2,
+ SearchManager.SUGGEST_COLUMN_INTENT_ACTION,
+ SearchManager.SUGGEST_COLUMN_INTENT_DATA,
+ };
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projectionIn, String selection,
+ String[] selectionArgs, String sortOrder) {
+ Log.d(TAG, "query(" + uri + ")");
+
+ MatrixCursor cursor = new MatrixCursor(COLUMNS);
+ for (int i = 0; i < 100; i++) {
+ cursor.addRow(new Object[]{
+ i,
+ "Spam suggestion " + i,
+ "This is spam",
+ Intent.ACTION_VIEW,
+ "content://com.android.globalsearch.spammy/spam/" + i
+ });
+ }
+ return cursor;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return SearchManager.SUGGEST_MIME_TYPE;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+}