summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/DpiTest/Android.mk2
-rw-r--r--tests/DpiTest/res/values-xlarge-long/strings.xml19
-rw-r--r--tests/DpiTest/res/values-xlarge-notlong/strings.xml19
-rw-r--r--tests/DpiTest/res/values-xlarge/strings.xml19
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java3
-rw-r--r--tests/FixVibrateSetting/Android.mk11
-rw-r--r--tests/FixVibrateSetting/AndroidManifest.xml14
-rw-r--r--tests/FixVibrateSetting/res/drawable-hdpi/stat_sys_warning.pngbin0 -> 1057 bytes
-rw-r--r--tests/FixVibrateSetting/res/drawable-mdpi/stat_sys_warning.pngbin0 -> 651 bytes
-rw-r--r--tests/FixVibrateSetting/res/layout/fix_vibrate.xml46
-rw-r--r--tests/FixVibrateSetting/res/values/strings.xml25
-rw-r--r--tests/FixVibrateSetting/src/com/android/fixvibratesetting/FixVibrateSetting.java123
-rw-r--r--tests/LargeAssetTest/Android.mk11
-rw-r--r--tests/LargeAssetTest/AndroidManifest.xml28
-rw-r--r--tests/LargeAssetTest/assets/million-intsbin0 -> 4000000 bytes
-rw-r--r--tests/LargeAssetTest/res/layout/lat.xml52
-rw-r--r--tests/LargeAssetTest/res/values/strings.xml23
-rw-r--r--tests/LargeAssetTest/src/com/android/largeassettest/LargeAssetTest.java104
-rw-r--r--tests/StatusBar/Android.mk2
-rw-r--r--tests/StatusBar/AndroidManifest.xml2
-rw-r--r--tests/StatusBar/res/drawable-hdpi/stat_sys_phone.pngbin0 -> 1184 bytes
-rw-r--r--tests/StatusBar/res/drawable-mdpi/stat_sys_phone.pngbin0 -> 746 bytes
-rw-r--r--tests/StatusBar/res/layout/test_alert.xml57
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java67
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java81
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java37
-rw-r--r--tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget2.xml26
-rw-r--r--tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java1
-rw-r--r--tests/framework-tests/Android.mk1
-rw-r--r--tests/framework-tests/README5
-rw-r--r--tests/framework-tests/src/Android.mk10
-rw-r--r--tests/framework-tests/src/android/test/FrameworkTests.java40
-rw-r--r--tests/framework-tests/src/android/text/PackedIntVectorTest.java159
-rw-r--r--tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java118
-rw-r--r--tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java184
-rw-r--r--tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java350
36 files changed, 745 insertions, 894 deletions
diff --git a/tests/DpiTest/Android.mk b/tests/DpiTest/Android.mk
index 3596c39..5463a17 100644
--- a/tests/DpiTest/Android.mk
+++ b/tests/DpiTest/Android.mk
@@ -7,4 +7,6 @@ LOCAL_PACKAGE_NAME := DensityTest
LOCAL_MODULE_TAGS := tests
+LOCAL_AAPT_FLAGS = -c 120dpi -c 240dpi -c 160dpi
+
include $(BUILD_PACKAGE)
diff --git a/tests/DpiTest/res/values-xlarge-long/strings.xml b/tests/DpiTest/res/values-xlarge-long/strings.xml
new file mode 100644
index 0000000..86ab660
--- /dev/null
+++ b/tests/DpiTest/res/values-xlarge-long/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <string name="act_title">DpiTest: XLarge Long</string>
+</resources>
diff --git a/tests/DpiTest/res/values-xlarge-notlong/strings.xml b/tests/DpiTest/res/values-xlarge-notlong/strings.xml
new file mode 100644
index 0000000..1eebbf4
--- /dev/null
+++ b/tests/DpiTest/res/values-xlarge-notlong/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <string name="act_title">DpiTest: XLarge NotLong</string>
+</resources>
diff --git a/tests/DpiTest/res/values-xlarge/strings.xml b/tests/DpiTest/res/values-xlarge/strings.xml
new file mode 100644
index 0000000..7e5d4b0
--- /dev/null
+++ b/tests/DpiTest/res/values-xlarge/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <string name="act_title">DpiTest: XLarge</string>
+</resources>
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
index cde2c71..6192a3c 100644
--- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
@@ -56,7 +56,8 @@ public class DpiTestActivity extends Activity {
ApplicationInfo ai = app.getPackageManager().getApplicationInfo(
"com.google.android.test.dpi", 0);
if (noCompat) {
- ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS
+ ai.flags |= ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS
+ | ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS
| ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS
| ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS
| ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS
diff --git a/tests/FixVibrateSetting/Android.mk b/tests/FixVibrateSetting/Android.mk
new file mode 100644
index 0000000..2a88e5a
--- /dev/null
+++ b/tests/FixVibrateSetting/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := FixVibrateSetting
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
diff --git a/tests/FixVibrateSetting/AndroidManifest.xml b/tests/FixVibrateSetting/AndroidManifest.xml
new file mode 100644
index 0000000..007d682
--- /dev/null
+++ b/tests/FixVibrateSetting/AndroidManifest.xml
@@ -0,0 +1,14 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.fixvibratesetting">
+ <uses-permission android:name="android.permission.VIBRATE" />
+
+ <application>
+ <activity android:name="FixVibrateSetting" android:label="@string/app_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/FixVibrateSetting/res/drawable-hdpi/stat_sys_warning.png b/tests/FixVibrateSetting/res/drawable-hdpi/stat_sys_warning.png
new file mode 100644
index 0000000..37c8853
--- /dev/null
+++ b/tests/FixVibrateSetting/res/drawable-hdpi/stat_sys_warning.png
Binary files differ
diff --git a/tests/FixVibrateSetting/res/drawable-mdpi/stat_sys_warning.png b/tests/FixVibrateSetting/res/drawable-mdpi/stat_sys_warning.png
new file mode 100644
index 0000000..be00f47
--- /dev/null
+++ b/tests/FixVibrateSetting/res/drawable-mdpi/stat_sys_warning.png
Binary files differ
diff --git a/tests/FixVibrateSetting/res/layout/fix_vibrate.xml b/tests/FixVibrateSetting/res/layout/fix_vibrate.xml
new file mode 100644
index 0000000..c505e65
--- /dev/null
+++ b/tests/FixVibrateSetting/res/layout/fix_vibrate.xml
@@ -0,0 +1,46 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ >
+
+ <TextView android:id="@+id/current_setting"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:layout_marginTop="30dp"
+ android:layout_marginBottom="50dp"
+ android:paddingLeft="8dp"
+ android:paddingTop="4dp"
+ android:textSize="20sp"
+ android:textColor="#ffffffff"
+ />
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="horizontal"
+ >
+ <Button android:id="@+id/fix"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/fix"
+ />
+
+ <Button android:id="@+id/unfix"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/unfix"
+ />
+ </LinearLayout>
+
+ <Button android:id="@+id/test"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/test"
+ />
+
+</LinearLayout>
+
diff --git a/tests/FixVibrateSetting/res/values/strings.xml b/tests/FixVibrateSetting/res/values/strings.xml
new file mode 100644
index 0000000..269cef3
--- /dev/null
+++ b/tests/FixVibrateSetting/res/values/strings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <string name="app_label">Fix Vibrate</string>
+ <string name="title">Fix vibrate setting</string>
+ <string name="current_setting">"Ringer: %1$s\nNotification: %2$s"</string>
+ <string name="fix">Fix the setting</string>
+ <string name="unfix">Break the setting</string>
+ <string name="test">Test the setting</string>
+</resources>
+
diff --git a/tests/FixVibrateSetting/src/com/android/fixvibratesetting/FixVibrateSetting.java b/tests/FixVibrateSetting/src/com/android/fixvibratesetting/FixVibrateSetting.java
new file mode 100644
index 0000000..947ea78
--- /dev/null
+++ b/tests/FixVibrateSetting/src/com/android/fixvibratesetting/FixVibrateSetting.java
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+package com.android.fixvibratesetting;
+
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+import android.os.Bundle;
+
+public class FixVibrateSetting extends Activity implements View.OnClickListener
+{
+ AudioManager mAudioManager;
+ NotificationManager mNotificationManager;
+ TextView mCurrentSetting;
+ View mFix;
+ View mUnfix;
+ View mTest;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ setContentView(R.layout.fix_vibrate);
+
+ mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
+ mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
+
+ mCurrentSetting = (TextView)findViewById(R.id.current_setting);
+
+ mFix = findViewById(R.id.fix);
+ mFix.setOnClickListener(this);
+
+ mUnfix = findViewById(R.id.unfix);
+ mUnfix.setOnClickListener(this);
+
+ mTest = findViewById(R.id.test);
+ mTest.setOnClickListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ update();
+ }
+
+ private String getSettingValue(int vibrateType) {
+ int setting = mAudioManager.getVibrateSetting(vibrateType);
+ switch (setting) {
+ case AudioManager.VIBRATE_SETTING_OFF:
+ return "off";
+ case AudioManager.VIBRATE_SETTING_ON:
+ return "on";
+ case AudioManager.VIBRATE_SETTING_ONLY_SILENT:
+ return "silent-only";
+ default:
+ return "unknown";
+ }
+ }
+
+ public void onClick(View v) {
+ if (v == mFix) {
+ fix();
+ update();
+ } else if (v == mUnfix) {
+ unfix();
+ update();
+ } else if (v == mTest) {
+ test();
+ update();
+ }
+ }
+
+ private void update() {
+ String ringer = getSettingValue(AudioManager.VIBRATE_TYPE_RINGER);
+ String notification = getSettingValue(AudioManager.VIBRATE_TYPE_NOTIFICATION);
+ String text = getString(R.string.current_setting, ringer, notification);
+ mCurrentSetting.setText(text);
+ }
+
+ private void fix() {
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION,
+ AudioManager.VIBRATE_SETTING_ON);
+ }
+
+ private void unfix() {
+ mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION,
+ AudioManager.VIBRATE_SETTING_OFF);
+ }
+
+ private void test() {
+ Notification n = new Notification(R.drawable.stat_sys_warning, "Test notification",
+ System.currentTimeMillis());
+ Intent intent = new Intent(this, FixVibrateSetting.class);
+ PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0);
+ n.setLatestEventInfo(this, "Test notification", "Test notification", pending);
+
+ n.vibrate = new long[] { 0, 700, 500, 1000 };
+ n.flags |= Notification.FLAG_AUTO_CANCEL;
+ mNotificationManager.notify(1, n);
+ }
+}
+
diff --git a/tests/LargeAssetTest/Android.mk b/tests/LargeAssetTest/Android.mk
new file mode 100644
index 0000000..cb7f01b
--- /dev/null
+++ b/tests/LargeAssetTest/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := LargeAssetTest
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
diff --git a/tests/LargeAssetTest/AndroidManifest.xml b/tests/LargeAssetTest/AndroidManifest.xml
new file mode 100644
index 0000000..c86118e
--- /dev/null
+++ b/tests/LargeAssetTest/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<!-- Copyright (C) 2010 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.largeassettest">
+
+ <application>
+ <activity android:name="LargeAssetTest" android:label="Large Asset Test">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/tests/LargeAssetTest/assets/million-ints b/tests/LargeAssetTest/assets/million-ints
new file mode 100644
index 0000000..0607de1
--- /dev/null
+++ b/tests/LargeAssetTest/assets/million-ints
Binary files differ
diff --git a/tests/LargeAssetTest/res/layout/lat.xml b/tests/LargeAssetTest/res/layout/lat.xml
new file mode 100644
index 0000000..eda7b82
--- /dev/null
+++ b/tests/LargeAssetTest/res/layout/lat.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="25dp"
+ android:textColor="#ffffffff"
+ android:text="@string/prompt"
+ />
+
+ <TextView android:id="@+id/result"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginTop="25dp"
+ android:textSize="24sp"
+ android:textColor="#ffffffff"
+ />
+
+ <Button android:id="@+id/validate"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/button_text" />
+
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ />
+</LinearLayout>
+
+
diff --git a/tests/LargeAssetTest/res/values/strings.xml b/tests/LargeAssetTest/res/values/strings.xml
new file mode 100644
index 0000000..54478fa
--- /dev/null
+++ b/tests/LargeAssetTest/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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>
+
+ <string name="prompt">Click the button below to read and validate the large binary asset.</string>
+ <string name="button_text">Validate the asset</string>
+
+</resources>
+
diff --git a/tests/LargeAssetTest/src/com/android/largeassettest/LargeAssetTest.java b/tests/LargeAssetTest/src/com/android/largeassettest/LargeAssetTest.java
new file mode 100644
index 0000000..e3a9cf4
--- /dev/null
+++ b/tests/LargeAssetTest/src/com/android/largeassettest/LargeAssetTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2006 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.largeassettest;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * Skeleton to test large-asset handling. The asset in question is one million
+ * four-byte integers, in ascending numeric order.
+ */
+public class LargeAssetTest extends Activity {
+ Button mValidateButton;
+ TextView mResultText;
+ Validator mValidateThread;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.lat);
+
+ mResultText = (TextView) findViewById(R.id.result);
+ mValidateButton = (Button) findViewById(R.id.validate);
+
+ mValidateButton.setOnClickListener(mClickListener);
+ }
+
+ View.OnClickListener mClickListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ mValidateButton.setEnabled(false);
+ mValidateThread = new Validator();
+ mValidateThread.execute(LargeAssetTest.this.getAssets());
+ }
+ };
+
+ /**
+ * Validation happens in a separate thread
+ */
+ class Validator extends AsyncTask<AssetManager, Integer, Boolean> {
+ static final String TAG = "Validator";
+
+ @Override
+ protected Boolean doInBackground(AssetManager... params) {
+ AssetManager am = params[0];
+ try {
+ InputStream is = am.open("million-ints", AssetManager.ACCESS_STREAMING);
+ byte[] buf = new byte[4];
+
+ for (int i = 0; i < 1000000; i++) {
+ int num = is.read(buf, 0, 4);
+ if (num != 4) {
+ Log.e(TAG, "Wanted 4 bytes but read " + num);
+ return false;
+ }
+ // the byte array is stored in the asset in little-endian order
+ int value = (buf[3] << 24) + ((buf[2] & 0xFF) << 16)
+ + ((buf[1] & 0xFF) << 8) + (buf[0] & 0xFF);
+ if (value != i) {
+ Log.e(TAG, "Mismatch: index " + i + " : value " + value);
+ return false;
+ }
+ }
+
+ is.close();
+ } catch (IOException e) {
+ Log.w(TAG, "Couldn't open asset", e);
+ return false;
+ }
+ Log.i(TAG, "Finished, reporting valid");
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result) {
+ CharSequence text = (result) ? "Valid!" : "NOT VALID";
+ mResultText.setText(text);
+ mValidateButton.setEnabled(true);
+ }
+ }
+}
diff --git a/tests/StatusBar/Android.mk b/tests/StatusBar/Android.mk
index 18fcad0..502657f 100644
--- a/tests/StatusBar/Android.mk
+++ b/tests/StatusBar/Android.mk
@@ -8,4 +8,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := StatusBarTest
LOCAL_CERTIFICATE := platform
+LOCAL_PROGUARD_ENABLED := disabled
+
include $(BUILD_PACKAGE)
diff --git a/tests/StatusBar/AndroidManifest.xml b/tests/StatusBar/AndroidManifest.xml
index 21fb951..c1ca618 100644
--- a/tests/StatusBar/AndroidManifest.xml
+++ b/tests/StatusBar/AndroidManifest.xml
@@ -35,5 +35,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="TestAlertActivity" android:theme="@android:style/Theme.Dialog">
+ </activity>
</application>
</manifest>
diff --git a/tests/StatusBar/res/drawable-hdpi/stat_sys_phone.png b/tests/StatusBar/res/drawable-hdpi/stat_sys_phone.png
new file mode 100644
index 0000000..9815553
--- /dev/null
+++ b/tests/StatusBar/res/drawable-hdpi/stat_sys_phone.png
Binary files differ
diff --git a/tests/StatusBar/res/drawable-mdpi/stat_sys_phone.png b/tests/StatusBar/res/drawable-mdpi/stat_sys_phone.png
new file mode 100644
index 0000000..402abc7
--- /dev/null
+++ b/tests/StatusBar/res/drawable-mdpi/stat_sys_phone.png
Binary files differ
diff --git a/tests/StatusBar/res/layout/test_alert.xml b/tests/StatusBar/res/layout/test_alert.xml
new file mode 100644
index 0000000..325146c
--- /dev/null
+++ b/tests/StatusBar/res/layout/test_alert.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ >
+
+ <TextView android:id="@+id/alertTitle"
+ style="?android:attr/textAppearanceLarge"
+ android:padding="5dip"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/ButtonBar">
+
+ <Button
+ android:id="@+id/snooze"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="3"
+ android:onClick="dismiss"
+ android:text="Snooze" />
+
+ <!-- blank stretchable view -->
+ <View
+ android:layout_width="2dip"
+ android:layout_height="2dip"
+ android:layout_gravity="fill_horizontal"
+ android:layout_weight="1"/>
+
+ <Button
+ android:id="@+id/dismiss"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="3"
+ android:onClick="dismiss"
+ android:text="Dismiss" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
index 9ed5156..16b3001 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java
@@ -39,6 +39,7 @@ public class NotificationTestList extends TestActivity
Vibrator mVibrator = new Vibrator();
Handler mHandler = new Handler();
+ long mActivityCreateTime = System.currentTimeMillis();
long mChronometerBase = 0;
@Override
@@ -118,19 +119,49 @@ public class NotificationTestList extends TestActivity
}
},
- new Test("Bad resource #2") {
- public void run()
- {
- Notification n = new Notification(NotificationTestList.this,
- R.drawable.ic_statusbar_missedcall,
- null, System.currentTimeMillis()-(1000*60*60*24),
- "(453) 123-2328",
- "", null);
+ new Test("Bad Icon #1 (when=create)") {
+ public void run() {
+ Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
+ null, mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ mNM.notify(1, n);
+ }
+ },
+
+ new Test("Bad Icon #1 (when=now)") {
+ public void run() {
+ Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
+ null, System.currentTimeMillis());
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ mNM.notify(1, n);
+ }
+ },
+
+ new Test("Bad resource #1 (when=create)") {
+ public void run() {
+ Notification n = new Notification(R.drawable.icon2,
+ null, mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
- mNM.notify(2, n);
+ mNM.notify(1, n);
+ }
+ },
+
+ new Test("Bad resource #1 (when=now)") {
+ public void run() {
+ Notification n = new Notification(R.drawable.icon2,
+ null, System.currentTimeMillis());
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
+ mNM.notify(1, n);
}
},
+
new Test("Bad resource #3") {
public void run()
{
@@ -177,7 +208,7 @@ public class NotificationTestList extends TestActivity
R.drawable.icon4,
null, System.currentTimeMillis(), "Stress - Latest",
"Notify me!!!", null);
- n.flags |= Notification.FLAG_ONGOING_EVENT;
+ //n.flags |= Notification.FLAG_ONGOING_EVENT;
mNM.notify(1, n);
}
}
@@ -407,7 +438,7 @@ public class NotificationTestList extends TestActivity
new Test("Persistent #1") {
public void run() {
Notification n = new Notification(R.drawable.icon1, "tick tick tick",
- System.currentTimeMillis());
+ mActivityCreateTime);
n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
"This is a notification!!!", makeIntent());
mNM.notify(1, n);
@@ -467,6 +498,16 @@ public class NotificationTestList extends TestActivity
}
},
+ new Test("Persistent #1 - different icon") {
+ public void run() {
+ Notification n = new Notification(R.drawable.icon2, null,
+ mActivityCreateTime);
+ n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
+ "This is the same notification!!!", makeIntent());
+ mNM.notify(1, n);
+ }
+ },
+
new Test("Chronometer Start") {
public void run() {
Notification n = new Notification(R.drawable.icon2, "me me me me",
@@ -619,9 +660,7 @@ public class NotificationTestList extends TestActivity
private PendingIntent makeIntent() {
Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setComponent(new android.content.ComponentName(
- "com.android.contacts",
- "com.android.contacts.ContactsActivity"));
+ intent.addCategory(Intent.CATEGORY_HOME);
return PendingIntent.getActivity(this, 0, intent, 0);
}
diff --git a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index 06506fb..b665d2f 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -23,6 +23,7 @@ import android.widget.ArrayAdapter;
import android.view.View;
import android.widget.ListView;
import android.content.Intent;
+import android.app.PendingIntent;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.StatusBarManager;
@@ -35,6 +36,8 @@ import android.os.SystemClock;
import android.widget.RemoteViews;
import android.widget.Toast;
import android.os.PowerManager;
+import android.view.Window;
+import android.view.WindowManager;
public class StatusBarTest extends TestActivity
{
@@ -57,6 +60,56 @@ public class StatusBarTest extends TestActivity
}
private Test[] mTests = new Test[] {
+ new Test("Hide") {
+ public void run() {
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ win.setAttributes(winParams);
+ }
+ },
+ new Test("Show") {
+ public void run() {
+ Window win = getWindow();
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ win.setAttributes(winParams);
+ }
+ },
+ new Test("Immersive: Enter") {
+ public void run() {
+ setImmersive(true);
+ }
+ },
+ new Test("Immersive: Exit") {
+ public void run() {
+ setImmersive(false);
+ }
+ },
+ new Test("Priority notification") {
+ public void run() {
+ Notification not = new Notification(StatusBarTest.this,
+ R.drawable.stat_sys_phone,
+ "Incoming call from: Imperious Leader",
+ System.currentTimeMillis()-(1000*60*60*24),
+ "Imperious Leader",
+ "(888) 555-5038",
+ null
+ );
+ not.flags |= Notification.FLAG_HIGH_PRIORITY;
+ Intent fullScreenIntent = new Intent(StatusBarTest.this, TestAlertActivity.class);
+ int id = (int)System.currentTimeMillis(); // XXX HAX
+ fullScreenIntent.putExtra("id", id);
+ not.fullScreenIntent = PendingIntent.getActivity(
+ StatusBarTest.this,
+ 0,
+ fullScreenIntent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ // if you tap on it you should get the original alert box
+ not.contentIntent = not.fullScreenIntent;
+ mNotificationManager.notify(id, not);
+ }
+ },
new Test("Disable Alerts") {
public void run() {
mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ALERTS);
@@ -134,13 +187,9 @@ public class StatusBarTest extends TestActivity
}, 3000);
}
},
- new Test("Expand in 3 sec.") {
+ new Test("Expand") {
public void run() {
- mHandler.postDelayed(new Runnable() {
- public void run() {
- mStatusBarManager.expand();
- }
- }, 3000);
+ mStatusBarManager.expand();
}
},
new Test("Expand in 3 sec.") {
@@ -161,13 +210,21 @@ public class StatusBarTest extends TestActivity
}, 3000);
}
},
- new Test("Toggle in 3 sec.") {
+ new Test("More icons") {
public void run() {
- mHandler.postDelayed(new Runnable() {
- public void run() {
- mStatusBarManager.toggle();
- }
- }, 3000);
+ for (String slot: new String[] {
+ "sync_failing",
+ "gps",
+ "bluetooth",
+ "tty",
+ "speakerphone",
+ "mute",
+ "wifi",
+ "alarm_clock",
+ "secure",
+ }) {
+ mStatusBarManager.setIconVisibility(slot, true);
+ }
}
},
};
diff --git a/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java b/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java
new file mode 100644
index 0000000..f5876d0
--- /dev/null
+++ b/tests/StatusBar/src/com/android/statusbartest/TestAlertActivity.java
@@ -0,0 +1,37 @@
+package com.android.statusbartest;
+
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class TestAlertActivity extends Activity {
+ int mId;
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d("StatusBarTest", "TestAlertActivity.onResume");
+ Intent intent = getIntent();
+ mId = intent.getIntExtra("id", -1);
+ Log.d("StatusBarTest", "Remembering notification id=" + mId);
+ setContentView(R.layout.test_alert);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ Log.d("StatusBarTest", "onPause: Canceling notification id=" + mId);
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.cancel(mId);
+ finish();
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ public void dismiss(View v) {
+ Log.d("StatusBarTest", "TestAlertActivity.dismiss");
+ finish();
+ }
+}
diff --git a/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget2.xml b/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget2.xml
new file mode 100644
index 0000000..abc6f59
--- /dev/null
+++ b/tests/appwidgets/AppWidgetProviderTest/res/layout/test_appwidget2.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2006 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/oh_hai_text"
+ android:layout_width="150dp"
+ android:layout_height="150dp"
+ android:text="@string/appwidget_view_title"
+ android:background="#8fff"
+ android:textColor="#000"
+ android:textStyle="bold"
+/>
+
diff --git a/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java b/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java
index 418be65..d9c0110 100644
--- a/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java
+++ b/tests/appwidgets/AppWidgetProviderTest/src/com/android/tests/appwidgetprovider/TestAppWidgetProvider.java
@@ -41,6 +41,7 @@ public class TestAppWidgetProvider extends BroadcastReceiver {
Log.d(TAG, "DISABLED");
}
else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
+ if (true) return;
Log.d(TAG, "UPDATE");
Bundle extras = intent.getExtras();
int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
diff --git a/tests/framework-tests/Android.mk b/tests/framework-tests/Android.mk
deleted file mode 100644
index 5053e7d..0000000
--- a/tests/framework-tests/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/tests/framework-tests/README b/tests/framework-tests/README
deleted file mode 100644
index 7b46b25..0000000
--- a/tests/framework-tests/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This package contains tests which need to access package-private members in the framework code.
-To do this, the tests must be loaded in the same class loader as the classes which they are
-testing. This package is loaded in the boot classpath.
-
-Run these tests via AndroidTests -> FrameworkTests.
diff --git a/tests/framework-tests/src/Android.mk b/tests/framework-tests/src/Android.mk
deleted file mode 100644
index 54e33a4..0000000
--- a/tests/framework-tests/src/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_MODULE := framework-tests
-
-LOCAL_JAVA_LIBRARIES := android.policy_phone android.test.runner
-
-include $(BUILD_JAVA_LIBRARY)
diff --git a/tests/framework-tests/src/android/test/FrameworkTests.java b/tests/framework-tests/src/android/test/FrameworkTests.java
deleted file mode 100644
index cb3f493..0000000
--- a/tests/framework-tests/src/android/test/FrameworkTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.test;
-
-import com.android.internal.os.LoggingPrintStreamTest;
-import junit.framework.TestSuite;
-import com.android.internal.http.multipart.MultipartTest;
-import com.android.internal.policy.impl.LockPatternKeyguardViewTest;
-
-/**
- * Tests that are loaded in the boot classpath along with the Android framework
- * classes. This enables you to access package-private members in the framework
- * classes; doing so is not possible when the test classes are loaded in an
- * application classloader.
- */
-public class FrameworkTests {
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(FrameworkTests.class.getName());
-
- suite.addTestSuite(MultipartTest.class);
- suite.addTestSuite(LoggingPrintStreamTest.class);
- suite.addTestSuite(LockPatternKeyguardViewTest.class);
-
- return suite;
- }
-}
diff --git a/tests/framework-tests/src/android/text/PackedIntVectorTest.java b/tests/framework-tests/src/android/text/PackedIntVectorTest.java
deleted file mode 100644
index 78cdee9..0000000
--- a/tests/framework-tests/src/android/text/PackedIntVectorTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2007 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 android.text;
-
-import android.text.PackedIntVector;
-import junit.framework.TestCase;
-
-/**
- * PackedIntVectorTest tests the features of android.util.PackedIntVector.
- */
-public class PackedIntVectorTest extends TestCase {
-
- public void testBasic() throws Exception {
- for (int width = 0; width < 10; width++) {
- PackedIntVector p = new PackedIntVector(width);
- int[] ins = new int[width];
-
- for (int height = width * 2; height < width * 4; height++) {
- assertEquals(p.width(), width);
-
- // Test adding rows.
-
- for (int i = 0; i < height; i++) {
- int at;
-
- if (i % 2 == 0) {
- at = i;
- } else {
- at = p.size() - i;
- }
-
- for (int j = 0; j < width; j++) {
- ins[j] = i + j;
- }
-
- if (i == height / 2) {
- p.insertAt(at, null);
- } else {
- p.insertAt(at, ins);
- }
-
- assertEquals(p.size(), i + 1);
-
- for (int j = 0; j < width; j++) {
- if (i == height / 2) {
- assertEquals(0, p.getValue(at, j));
- } else {
- assertEquals(p.getValue(at, j), i + j);
- }
- }
- }
-
- // Test setting values.
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- p.setValue(i, j, i * j);
-
- assertEquals(p.getValue(i, j), i * j);
- }
- }
-
- // Test offsetting values.
-
- for (int j = 0; j < width; j++) {
- p.adjustValuesBelow(j * 2, j, j + 27);
- }
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int expect = i * j;
-
- if (i >= j * 2) {
- expect += j + 27;
- }
-
- assertEquals(p.getValue(i, j), expect);
- }
- }
-
- for (int j = 0; j < width; j++) {
- p.adjustValuesBelow(j, j, j * j + 14);
- }
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int expect = i * j;
-
- if (i >= j * 2) {
- expect += j + 27;
- }
- if (i >= j) {
- expect += j * j + 14;
- }
-
- assertEquals(p.getValue(i, j), expect);
- }
- }
-
- // Test undoing offsets.
-
- for (int j = 0; j < width; j++) {
- p.adjustValuesBelow(j * 2, j, -(j + 27));
- p.adjustValuesBelow(j, j, -(j * j + 14));
- }
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- assertEquals(p.getValue(i, j), i * j);
- }
- }
-
- // Test deleting rows.
-
- while (p.size() > 0) {
- int osize = p.size();
- int del = osize / 3;
-
- if (del == 0) {
- del = 1;
- }
-
- int at = (osize - del) / 2;
- p.deleteAt(at, del);
-
- assertEquals(p.size(), osize - del);
-
- for (int i = 0; i < at; i++) {
- for (int j = 0; j < width; j++) {
- assertEquals(p.getValue(i, j), i * j);
- }
- }
-
- for (int i = at; i < p.size(); i++) {
- for (int j = 0; j < width; j++) {
- assertEquals(p.getValue(i, j), (i + height - p.size()) * j);
- }
- }
- }
-
- assertEquals(0, p.size());
- }
- }
- }
-}
diff --git a/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java b/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
deleted file mode 100644
index 32e13a7..0000000
--- a/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.internal.http.multipart;
-
-import junit.framework.TestCase;
-import org.apache.http.Header;
-import org.apache.http.util.EncodingUtils;
-
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileWriter;
-
-public class MultipartTest extends TestCase {
-
- public void testParts() throws Exception {
- StringBuffer filebuffer = new StringBuffer();
- String filepartStr = "this is file part";
- filebuffer.append(filepartStr);
- File upload = File.createTempFile("Multipart", "test");
-
- FileWriter outFile = new FileWriter(upload);
- BufferedWriter out = new BufferedWriter(outFile);
- try {
- out.write(filebuffer.toString());
- out.flush();
- } finally {
- out.close();
- }
-
- Part[] parts = new Part[3];
- parts[0] = new StringPart("stringpart", "PART1!!");
- parts[1] = new FilePart(upload.getName(), upload);
- parts[2] = new StringPart("stringpart", "PART2!!");
-
- MultipartEntity me = new MultipartEntity(parts);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- me.writeTo(os);
- Header h = me.getContentType();
- String boundry = EncodingUtils.getAsciiString(me.getMultipartBoundary());
- StringBuffer contentType = new StringBuffer("multipart/form-data");
- contentType.append("; boundary=");
- contentType.append(boundry);
- assertEquals("Multipart content type error", contentType.toString(), h.getValue());
- final String CRLF = "\r\n";
- StringBuffer output = new StringBuffer();
-
- output.append("--");
- output.append(boundry);
- output.append(CRLF);
-
- output.append("Content-Disposition: form-data; name=\"stringpart\"");
- output.append(CRLF);
- output.append("Content-Type: text/plain; charset=US-ASCII");
- output.append(CRLF);
- output.append("Content-Transfer-Encoding: 8bit");
- output.append(CRLF);
- output.append(CRLF);
- output.append("PART1!!");
- output.append(CRLF);
-
- output.append("--");
- output.append(boundry);
- output.append(CRLF);
-
- output.append("Content-Disposition: form-data; name=\"");
- output.append(upload.getName());
- output.append("\"; filename=\"");
- output.append(upload.getName());
- output.append("\"");
-
- output.append(CRLF);
- output.append("Content-Type: application/octet-stream; charset=ISO-8859-1");
- output.append(CRLF);
- output.append("Content-Transfer-Encoding: binary");
- output.append(CRLF);
- output.append(CRLF);
- output.append(filepartStr);
- output.append(CRLF);
-
- output.append("--");
- output.append(boundry);
- output.append(CRLF);
-
- output.append("Content-Disposition: form-data; name=\"stringpart\"");
- output.append(CRLF);
- output.append("Content-Type: text/plain; charset=US-ASCII");
- output.append(CRLF);
- output.append("Content-Transfer-Encoding: 8bit");
- output.append(CRLF);
- output.append(CRLF);
- output.append("PART2!!");
- output.append(CRLF);
-
- output.append("--");
- output.append(boundry);
- output.append("--");
- output.append(CRLF);
- // System.out.print(output.toString());
- assertEquals("Multipart content error", output.toString(), os.toString());
-
- // System.out.print(os.toString());
- }
-}
diff --git a/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java b/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java
deleted file mode 100644
index 4d016d1..0000000
--- a/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.internal.os;
-
-import junit.framework.TestCase;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class LoggingPrintStreamTest extends TestCase {
-
- TestPrintStream out = new TestPrintStream();
-
- public void testPrintException() {
- @SuppressWarnings("ThrowableInstanceNeverThrown")
- Throwable t = new Throwable("Ignore me.");
-
- StringWriter sout = new StringWriter();
- t.printStackTrace(new PrintWriter(sout));
-
- t.printStackTrace(out);
- // t.printStackTrace();
-
- String[] lines = sout.toString().split("\\n");
- assertEquals(Arrays.asList(lines), out.lines);
- }
-
- public void testPrintObject() {
- Object o = new Object();
- out.print(4);
- out.print(o);
- out.print(2);
- out.flush();
- assertEquals(Arrays.asList("4" + o + "2"), out.lines);
- }
-
- public void testPrintlnObject() {
- Object o = new Object();
- out.print(4);
- out.println(o);
- out.print(2);
- out.flush();
- assertEquals(Arrays.asList("4" + o, "2"), out.lines);
- }
-
- public void testPrintf() {
- out.printf("Name: %s\nEmployer: %s", "Bob", "Google");
- assertEquals(Arrays.asList("Name: Bob"), out.lines);
- out.flush();
- assertEquals(Arrays.asList("Name: Bob", "Employer: Google"), out.lines);
- }
-
- public void testPrintInt() {
- out.print(4);
- out.print(2);
- assertTrue(out.lines.isEmpty());
- out.flush();
- assertEquals(Collections.singletonList("42"), out.lines);
- }
-
- public void testPrintlnInt() {
- out.println(4);
- out.println(2);
- assertEquals(Arrays.asList("4", "2"), out.lines);
- }
-
- public void testPrintCharArray() {
- out.print("Foo\nBar\nTee".toCharArray());
- assertEquals(Arrays.asList("Foo", "Bar"), out.lines);
- out.flush();
- assertEquals(Arrays.asList("Foo", "Bar", "Tee"), out.lines);
- }
-
- public void testPrintString() {
- out.print("Foo\nBar\nTee");
- assertEquals(Arrays.asList("Foo", "Bar"), out.lines);
- out.flush();
- assertEquals(Arrays.asList("Foo", "Bar", "Tee"), out.lines);
- }
-
- public void testPrintlnCharArray() {
- out.println("Foo\nBar\nTee".toCharArray());
- assertEquals(Arrays.asList("Foo", "Bar", "Tee"), out.lines);
- }
-
- public void testPrintlnString() {
- out.println("Foo\nBar\nTee");
- assertEquals(Arrays.asList("Foo", "Bar", "Tee"), out.lines);
- }
-
- public void testPrintlnStringWithBufferedData() {
- out.print(5);
- out.println("Foo\nBar\nTee");
- assertEquals(Arrays.asList("5Foo", "Bar", "Tee"), out.lines);
- }
-
- public void testAppend() {
- out.append("Foo\n")
- .append('4')
- .append('\n')
- .append("Bar", 1, 2)
- .append('\n');
- assertEquals(Arrays.asList("Foo", "4", "a"), out.lines);
- }
-
- public void testMultiByteCharactersSpanningBuffers() throws Exception {
- // assume 3*1000 bytes won't fit in LoggingPrintStream's internal buffer
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < 1000; i++) {
- builder.append("\u20AC"); // a Euro character; 3 bytes in UTF-8
- }
- String expected = builder.toString();
-
- out.write(expected.getBytes("UTF-8"));
- out.flush();
- assertEquals(Arrays.asList(expected), out.lines);
- }
-
- public void testWriteOneByteAtATimeMultibyteCharacters() throws Exception {
- String expected = " \u20AC \u20AC \u20AC \u20AC ";
- for (byte b : expected.getBytes()) {
- out.write(b);
- }
- out.flush();
- assertEquals(Arrays.asList(expected), out.lines);
- }
-
- public void testWriteByteArrayAtATimeMultibyteCharacters() throws Exception {
- String expected = " \u20AC \u20AC \u20AC \u20AC ";
- out.write(expected.getBytes());
- out.flush();
- assertEquals(Arrays.asList(expected), out.lines);
- }
-
- public void testWriteWithOffsetsMultibyteCharacters() throws Exception {
- String expected = " \u20AC \u20AC \u20AC \u20AC ";
- byte[] bytes = expected.getBytes();
- int i = 0;
- while (i < bytes.length - 5) {
- out.write(bytes, i, 5);
- i += 5;
- }
- out.write(bytes, i, bytes.length - i);
- out.flush();
- assertEquals(Arrays.asList(expected), out.lines);
- }
-
- public void testWriteFlushesOnNewlines() throws Exception {
- String a = " \u20AC \u20AC ";
- String b = " \u20AC \u20AC ";
- String c = " ";
- String toWrite = a + "\n" + b + "\n" + c;
- out.write(toWrite.getBytes());
- out.flush();
- assertEquals(Arrays.asList(a, b, c), out.lines);
- }
-
- static class TestPrintStream extends LoggingPrintStream {
-
- final List<String> lines = new ArrayList<String>();
-
- protected void log(String line) {
- lines.add(line);
- }
- }
-}
diff --git a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java b/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
deleted file mode 100644
index 1e57bd2..0000000
--- a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.internal.policy.impl;
-
-import android.content.Context;
-import com.android.internal.telephony.IccCard;
-import android.content.res.Configuration;
-import android.test.AndroidTestCase;
-import android.view.View;
-import android.view.KeyEvent;
-import com.android.internal.widget.LockPatternUtils;
-import com.google.android.collect.Lists;
-
-import java.util.List;
-
-/**
- * Tests for {@link com.android.internal.policy.impl.LockPatternKeyguardView},
- * which handles the management of screens while the keyguard is showing.
- */
-public class LockPatternKeyguardViewTest extends AndroidTestCase {
- private MockUpdateMonitor mUpdateMonitor;
- private LockPatternUtils mLockPatternUtils;
- private TestableLockPatternKeyguardView mLPKV;
- private MockKeyguardCallback mKeyguardViewCallback;
-
- private static class MockUpdateMonitor extends KeyguardUpdateMonitor {
-
- public IccCard.State simState = IccCard.State.READY;
-
- private MockUpdateMonitor(Context context) {
- super(context);
- }
-
- @Override
- public IccCard.State getSimState() {
- return simState;
- }
- }
-
- private static class MockLockPatternUtils extends LockPatternUtils {
- boolean isLockPatternEnabled = true;
- public boolean isPermanentlyLocked = false;
-
- public MockLockPatternUtils() {
- super(null);
- }
-
- @Override
- public boolean isLockPatternEnabled() {
- return isLockPatternEnabled;
- }
-
- @Override
- public void setLockPatternEnabled(boolean lockPatternEnabled) {
- isLockPatternEnabled = lockPatternEnabled;
- }
-
- @Override
- public boolean isPermanentlyLocked() {
- return isPermanentlyLocked;
- }
-
- public void setPermanentlyLocked(boolean permanentlyLocked) {
- isPermanentlyLocked = permanentlyLocked;
- }
- }
-
- private static class MockKeyguardScreen extends View implements KeyguardScreen {
-
- private int mOnPauseCount = 0;
- private int mOnResumeCount = 0;
- private int mCleanupCount = 0;
-
- private MockKeyguardScreen(Context context) {
- super(context);
- setFocusable(true);
- }
-
- /** {@inheritDoc} */
- public boolean needsInput() {
- return false;
- }
-
- /** {@inheritDoc} */
- public void onPause() {
- mOnPauseCount++;
- }
-
- /** {@inheritDoc} */
- public void onResume() {
- mOnResumeCount++;
- }
-
- /** {@inheritDoc} */
- public void cleanUp() {
- mCleanupCount++;
- }
-
- public int getOnPauseCount() {
- return mOnPauseCount;
- }
-
- public int getOnResumeCount() {
- return mOnResumeCount;
- }
-
- public int getCleanupCount() {
- return mCleanupCount;
- }
- }
-
- /**
- * Allows us to inject the lock and unlock views to simulate their behavior
- * and detect their creation.
- */
- private static class TestableLockPatternKeyguardView extends LockPatternKeyguardView {
- private List<MockKeyguardScreen> mInjectedLockScreens;
- private List<MockKeyguardScreen> mInjectedUnlockScreens;
-
-
-
- private TestableLockPatternKeyguardView(Context context, KeyguardUpdateMonitor updateMonitor,
- LockPatternUtils lockPatternUtils, KeyguardWindowController controller) {
- super(context, updateMonitor, lockPatternUtils, controller);
- }
-
- @Override
- View createLockScreen() {
- final MockKeyguardScreen newView = new MockKeyguardScreen(getContext());
- if (mInjectedLockScreens == null) mInjectedLockScreens = Lists.newArrayList();
- mInjectedLockScreens.add(newView);
- return newView;
- }
-
- @Override
- View createUnlockScreenFor(UnlockMode unlockMode) {
- final MockKeyguardScreen newView = new MockKeyguardScreen(getContext());
- if (mInjectedUnlockScreens == null) mInjectedUnlockScreens = Lists.newArrayList();
- mInjectedUnlockScreens.add(newView);
- return newView;
- }
-
- public List<MockKeyguardScreen> getInjectedLockScreens() {
- return mInjectedLockScreens;
- }
-
- public List<MockKeyguardScreen> getInjectedUnlockScreens() {
- return mInjectedUnlockScreens;
- }
- }
-
- private static class MockKeyguardCallback implements KeyguardViewCallback {
-
- private int mPokeWakelockCount = 0;
- private int mKeyguardDoneCount = 0;
-
- public void pokeWakelock() {
- mPokeWakelockCount++;
- }
-
- public void pokeWakelock(int millis) {
- mPokeWakelockCount++;
- }
-
- public void keyguardDone(boolean authenticated) {
- mKeyguardDoneCount++;
- }
-
- public void keyguardDoneDrawing() {
-
- }
-
- public int getPokeWakelockCount() {
- return mPokeWakelockCount;
- }
-
- public int getKeyguardDoneCount() {
- return mKeyguardDoneCount;
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mUpdateMonitor = new MockUpdateMonitor(getContext());
- mLockPatternUtils = new MockLockPatternUtils();
-
- mLPKV = new TestableLockPatternKeyguardView(getContext(), mUpdateMonitor,
- mLockPatternUtils, new KeyguardWindowController() {
- public void setNeedsInput(boolean needsInput) {
- }
- });
- mKeyguardViewCallback = new MockKeyguardCallback();
- mLPKV.setCallback(mKeyguardViewCallback);
- }
-
- public void testStateAfterCreatedWhileScreenOff() {
-
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
-
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
- MockKeyguardScreen unlockScreen = mLPKV.getInjectedUnlockScreens().get(0);
-
- assertEquals(0, lockScreen.getOnPauseCount());
- assertEquals(0, lockScreen.getOnResumeCount());
- assertEquals(0, lockScreen.getCleanupCount());
-
- assertEquals(0, unlockScreen.getOnPauseCount());
- assertEquals(0, unlockScreen.getOnResumeCount());
- assertEquals(0, unlockScreen.getCleanupCount());
-
- assertEquals(0, mKeyguardViewCallback.getPokeWakelockCount());
- assertEquals(0, mKeyguardViewCallback.getKeyguardDoneCount());
- }
-
- public void testWokenByNonMenuKey() {
- mLPKV.wakeWhenReadyTq(0);
-
- // should have poked the wakelock to turn on the screen
- assertEquals(1, mKeyguardViewCallback.getPokeWakelockCount());
-
- // shouldn't be any additional views created
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
- MockKeyguardScreen unlockScreen = mLPKV.getInjectedUnlockScreens().get(0);
-
- // lock screen should be only visible one
- assertEquals(View.VISIBLE, lockScreen.getVisibility());
- assertEquals(View.GONE, unlockScreen.getVisibility());
-
- // on resume not called until screen turns on
- assertEquals(0, lockScreen.getOnPauseCount());
- assertEquals(0, lockScreen.getOnResumeCount());
- assertEquals(0, lockScreen.getCleanupCount());
-
- assertEquals(0, unlockScreen.getOnPauseCount());
- assertEquals(0, unlockScreen.getOnResumeCount());
- assertEquals(0, unlockScreen.getCleanupCount());
-
- // simulate screen turning on
- mLPKV.onScreenTurnedOn();
-
- assertEquals(0, lockScreen.getOnPauseCount());
- assertEquals(1, lockScreen.getOnResumeCount());
- assertEquals(0, lockScreen.getCleanupCount());
-
- assertEquals(0, unlockScreen.getOnPauseCount());
- assertEquals(0, unlockScreen.getOnResumeCount());
- assertEquals(0, unlockScreen.getCleanupCount());
- }
-
- public void testWokenByMenuKeyWhenPatternSet() {
- assertEquals(true, mLockPatternUtils.isLockPatternEnabled());
-
- mLPKV.wakeWhenReadyTq(KeyEvent.KEYCODE_MENU);
-
- // should have poked the wakelock to turn on the screen
- assertEquals(1, mKeyguardViewCallback.getPokeWakelockCount());
-
- // shouldn't be any additional views created
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
- MockKeyguardScreen unlockScreen = mLPKV.getInjectedUnlockScreens().get(0);
-
- // unlock screen should be only visible one
- assertEquals(View.GONE, lockScreen.getVisibility());
- assertEquals(View.VISIBLE, unlockScreen.getVisibility());
- }
-
- public void testScreenRequestsRecreation() {
- mLPKV.wakeWhenReadyTq(0);
- mLPKV.onScreenTurnedOn();
-
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
-
- assertEquals(0, lockScreen.getOnPauseCount());
- assertEquals(1, lockScreen.getOnResumeCount());
-
- // simulate screen asking to be recreated
- mLPKV.mKeyguardScreenCallback.recreateMe(new Configuration());
-
- // should have been recreated
- assertEquals(2, mLPKV.getInjectedLockScreens().size());
- assertEquals(2, mLPKV.getInjectedUnlockScreens().size());
-
- // both old screens should have been cleaned up
- assertEquals(1, mLPKV.getInjectedLockScreens().get(0).getCleanupCount());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().get(0).getCleanupCount());
-
- // old lock screen should have been paused
- assertEquals(1, mLPKV.getInjectedLockScreens().get(0).getOnPauseCount());
- assertEquals(0, mLPKV.getInjectedUnlockScreens().get(0).getOnPauseCount());
-
- // new lock screen should have been resumed
- assertEquals(1, mLPKV.getInjectedLockScreens().get(1).getOnResumeCount());
- assertEquals(0, mLPKV.getInjectedUnlockScreens().get(1).getOnResumeCount());
- }
-
- public void testMenuDoesntGoToUnlockScreenOnWakeWhenPukLocked() {
- // PUK locked
- mUpdateMonitor.simState = IccCard.State.PUK_REQUIRED;
-
- // wake by menu
- mLPKV.wakeWhenReadyTq(KeyEvent.KEYCODE_MENU);
-
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
- MockKeyguardScreen unlockScreen = mLPKV.getInjectedUnlockScreens().get(0);
-
- // lock screen should be only visible one
- assertEquals(View.VISIBLE, lockScreen.getVisibility());
- assertEquals(View.GONE, unlockScreen.getVisibility());
- }
-
- public void testMenuGoesToLockScreenWhenDeviceNotSecure() {
- mLockPatternUtils.setLockPatternEnabled(false);
-
- // wake by menu
- mLPKV.wakeWhenReadyTq(KeyEvent.KEYCODE_MENU);
-
- assertEquals(1, mLPKV.getInjectedLockScreens().size());
- assertEquals(1, mLPKV.getInjectedUnlockScreens().size());
- MockKeyguardScreen lockScreen = mLPKV.getInjectedLockScreens().get(0);
- MockKeyguardScreen unlockScreen = mLPKV.getInjectedUnlockScreens().get(0);
-
- // lock screen should be only visible one
- assertEquals(View.VISIBLE, lockScreen.getVisibility());
- assertEquals(View.GONE, unlockScreen.getVisibility());
- }
-}