diff options
Diffstat (limited to 'tests')
50 files changed, 3954 insertions, 27 deletions
diff --git a/tests/FrameworkPerf/Android.mk b/tests/FrameworkPerf/Android.mk new file mode 100644 index 0000000..2eb52f0 --- /dev/null +++ b/tests/FrameworkPerf/Android.mk @@ -0,0 +1,14 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := FrameworkPerf + +LOCAL_JAVA_LIBRARIES := android.test.runner + +LOCAL_AAPT_FLAGS = -c 120dpi,240dpi,160dpi,161dpi,320dpi,nodpi + +include $(BUILD_PACKAGE) diff --git a/tests/FrameworkPerf/AndroidManifest.xml b/tests/FrameworkPerf/AndroidManifest.xml new file mode 100644 index 0000000..2591aaf --- /dev/null +++ b/tests/FrameworkPerf/AndroidManifest.xml @@ -0,0 +1,29 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.frameworkperf"> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + <uses-sdk android:minSdkVersion="5" /> + + <application android:hardwareAccelerated="false"> + <uses-library android:name="android.test.runner" /> + <activity android:name="FrameworkPerfActivity" android:label="Framework Perf"> + <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> + <service android:name="SchedulerService"> + </service> + <service android:name="TestService" android:process=":test"> + </service> + <service android:name="LocalTestService"> + </service> + <receiver android:name="Receiver" android:exported="true"> + </receiver> + </application> + + <instrumentation android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.android.frameworkperf" + android:label="Framework Perf Runner" + /> +</manifest> diff --git a/tests/FrameworkPerf/res/drawable-161dpi/stat_sample_scale.png b/tests/FrameworkPerf/res/drawable-161dpi/stat_sample_scale.png Binary files differnew file mode 100755 index 0000000..6c9ba0a --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-161dpi/stat_sample_scale.png diff --git a/tests/FrameworkPerf/res/drawable-161dpi/wallpaper_goldengate_scale.jpg b/tests/FrameworkPerf/res/drawable-161dpi/wallpaper_goldengate_scale.jpg Binary files differnew file mode 100644 index 0000000..2271091 --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-161dpi/wallpaper_goldengate_scale.jpg diff --git a/tests/FrameworkPerf/res/drawable-hdpi/stat_happy.png b/tests/FrameworkPerf/res/drawable-hdpi/stat_happy.png Binary files differnew file mode 100755 index 0000000..27f5bb7 --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-hdpi/stat_happy.png diff --git a/tests/FrameworkPerf/res/drawable-mdpi/stat_happy.png b/tests/FrameworkPerf/res/drawable-mdpi/stat_happy.png Binary files differnew file mode 100644 index 0000000..3a8791b --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-mdpi/stat_happy.png diff --git a/tests/FrameworkPerf/res/drawable-nodpi/stat_sample.png b/tests/FrameworkPerf/res/drawable-nodpi/stat_sample.png Binary files differnew file mode 100755 index 0000000..6c9ba0a --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-nodpi/stat_sample.png diff --git a/tests/FrameworkPerf/res/drawable-nodpi/wallpaper_goldengate.jpg b/tests/FrameworkPerf/res/drawable-nodpi/wallpaper_goldengate.jpg Binary files differnew file mode 100644 index 0000000..2271091 --- /dev/null +++ b/tests/FrameworkPerf/res/drawable-nodpi/wallpaper_goldengate.jpg diff --git a/tests/FrameworkPerf/res/layout/button_layout.xml b/tests/FrameworkPerf/res/layout/button_layout.xml new file mode 100644 index 0000000..7786a25 --- /dev/null +++ b/tests/FrameworkPerf/res/layout/button_layout.xml @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="FooBarYou" /> +</LinearLayout> diff --git a/tests/FrameworkPerf/res/layout/image_button_layout.xml b/tests/FrameworkPerf/res/layout/image_button_layout.xml new file mode 100644 index 0000000..65b12b3 --- /dev/null +++ b/tests/FrameworkPerf/res/layout/image_button_layout.xml @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" + android:src="@drawable/stat_happy"/> +</LinearLayout> diff --git a/tests/FrameworkPerf/res/layout/large_layout.xml b/tests/FrameworkPerf/res/layout/large_layout.xml new file mode 100644 index 0000000..39bbe34 --- /dev/null +++ b/tests/FrameworkPerf/res/layout/large_layout.xml @@ -0,0 +1,460 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- All ids in this layout must be in wifi_dialog.xml --> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <!-- UI components that should be shown appropriately --> + <FrameLayout + android:id="@+id/eap_not_supported" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="360dip" + android:orientation="vertical" + android:visibility="gone"> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:lineSpacingExtra="12dip" + android:text="Foo" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </FrameLayout> + <!-- In "add network" flow, we have security type field (@id/security below) below + this View, so need a bit different layout than the other flow, in which we'll use + @id/eap_not_supported. --> + <FrameLayout + android:id="@+id/eap_not_supported_for_add_network" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:lineSpacingExtra="12dip" + android:text="Bar" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </FrameLayout> + <LinearLayout + android:id="@+id/wps_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + <TextView + android:layout_width="match_parent" + android:minWidth="128dip" + android:layout_height="wrap_content" + android:text="Blah" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" + android:gravity="bottom" /> + + <EditText + android:id="@+id/wps_pin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textPassword" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </LinearLayout> + <TableLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="16dip"> + <!-- To accomodate @id/type into TableLayout, we splitted the layout into two: + @id/type_ssid and @id/type_security. --> + <TableRow + android:id="@+id/type_ssid" + android:minHeight="56dip" + android:visibility="gone"> + <TextView + android:id="@+id/ssid_text" + android:layout_width="wrap_content" + android:minWidth="128dip" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:paddingRight="16dip" + android:layout_alignParentLeft="true" + android:text="Whatever" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" + android:gravity="left|center_vertical" /> + + <FrameLayout + android:id="@+id/ssid_layout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBottom="@id/ssid_text" + android:layout_toRightOf="@id/ssid_text"> + <EditText + android:id="@+id/ssid" + android:layout_width="368dip" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </FrameLayout> + </TableRow> + + <TableRow + android:id="@+id/security_fields" + android:minHeight="56dip" + android:visibility="gone"> + <TextView + android:id="@+id/password_text" + android:layout_width="wrap_content" + android:minWidth="128dip" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:text="Whenever" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" + android:gravity="left|center_vertical" /> + + <LinearLayout + android:id="@+id/password_layout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="bottom"> + <EditText + android:id="@+id/password" + android:layout_width="368dip" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:singleLine="true" + android:password="true" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </LinearLayout> + + <!-- It looks CheckBox isn't aligned well with TableRow --> + <FrameLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <CheckBox + android:id="@+id/show_password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:text="However" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" /> + </FrameLayout> + </TableRow> + + <TableRow + android:id="@+id/type_security" + android:minHeight="56dip" + android:visibility="gone"> + <TextView + android:id="@+id/security_text" + android:layout_width="wrap_content" + android:minWidth="128dip" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:text="Whoever" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textSize="20sp" + android:gravity="bottom"/> + + <FrameLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="bottom"> + <Spinner + android:id="@+id/security" + android:layout_width="368dip" + android:layout_height="wrap_content" + android:minHeight="56dip" + android:paddingLeft="4dip"/> + </FrameLayout> + </TableRow> + </TableLayout> + + <!-- All the views below are "gone". + We want them as data storage, not as UI components. --> + <LinearLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone"> + + <LinearLayout android:id="@+id/info" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"/> + + <LinearLayout android:id="@+id/setup_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="On the top" /> + + <Spinner android:id="@+id/network_setup" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + </LinearLayout> + + <!-- android:id="@+id/security_fields" --> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <LinearLayout android:id="@+id/eap" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="On the bottom" /> + + <Spinner android:id="@+id/method" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="On the side" /> + + <Spinner android:id="@+id/phase2" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="SRH" /> + + <Spinner android:id="@+id/ca_cert" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Enjoyable" /> + + <Spinner android:id="@+id/user_cert" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Fantastic" /> + + <EditText android:id="@+id/identity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Superb" /> + + <EditText android:id="@+id/anonymous" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + </LinearLayout> <!-- android:id="@+id/eap" --> + + <!-- <TextView android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/wifi_password" /> + + <EditText android:id="@+id/password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:password="true" /> + + <CheckBox android:id="@+id/show_password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/wifi_show_password" /> --> + </LinearLayout> <!-- android:id="@+id/security_fields" --> + + <LinearLayout android:id="@+id/proxy_settings_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <TextView android:id="@+id/proxy_settings_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Heavenly" /> + + <Spinner android:id="@+id/proxy_settings" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + + <LinearLayout android:id="@+id/proxy_warning_limited_support" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <!-- Dummy to enable right-justification of warning --> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Orgasmic" /> + </LinearLayout> + + <LinearLayout android:id="@+id/proxy_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + <TextView android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Really" /> + + <EditText android:id="@+id/proxy_hostname" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Really really" /> + + <EditText android:id="@+id/proxy_port" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Really really with cherries on top" /> + + <EditText android:id="@+id/proxy_exclusionlist" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + </LinearLayout> + + <LinearLayout android:id="@+id/ip_fields" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Mmmmm... cherries" /> + + <Spinner android:id="@+id/ip_settings" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + + <LinearLayout android:id="@+id/staticip" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="I mean Mmmmm.. cherries" /> + + <EditText android:id="@+id/ipaddress" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Shorter" /> + + <EditText android:id="@+id/gateway" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="is" /> + + <EditText android:id="@+id/network_prefix_length" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="better" /> + + <EditText android:id="@+id/dns1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="always" /> + + <EditText android:id="@+id/dns2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:inputType="textNoSuggestions" /> + + </LinearLayout> + </LinearLayout> +</LinearLayout> diff --git a/tests/FrameworkPerf/res/layout/main.xml b/tests/FrameworkPerf/res/layout/main.xml new file mode 100644 index 0000000..e00ad92 --- /dev/null +++ b/tests/FrameworkPerf/res/layout/main.xml @@ -0,0 +1,127 @@ +<?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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + > + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Foreground: " + /> + <Spinner android:id="@+id/fgspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + <TextView android:id="@+id/fgtext" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Background: " + /> + <Spinner android:id="@+id/bgspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + <TextView android:id="@+id/bgtext" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Limit by: " + /> + <Spinner android:id="@+id/limitspinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="Test time (ms): " + android:id="@+id/limitlabel" + /> + <EditText android:id="@+id/testtime" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="number" + android:text="5000" + /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginTop="10dp" + > + <Button android:id="@+id/start" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/start" + /> + <Button android:id="@+id/stop" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/stop" + /> + <CheckBox android:id="@+id/local" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Local" + /> + </LinearLayout> + + <TextView android:id="@+id/log" + android:layout_width="match_parent" + android:layout_height="0px" + android:layout_weight="1" + android:layout_marginTop="10dp" + android:textSize="12sp" + android:textColor="#ffffffff" + /> + +</LinearLayout> diff --git a/tests/FrameworkPerf/res/layout/small_layout.xml b/tests/FrameworkPerf/res/layout/small_layout.xml new file mode 100644 index 0000000..e78a176 --- /dev/null +++ b/tests/FrameworkPerf/res/layout/small_layout.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + + <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> + + <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> + <TextView android:text="Foo" android:layout_width="wrap_content" android:layout_height="wrap_content" /> + </LinearLayout> + + <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> + <TextView android:id="@+id/config_list" android:layout_width="wrap_content" android:layout_height="wrap_content" /> + </LinearLayout> + </LinearLayout> + +</ScrollView> + diff --git a/tests/FrameworkPerf/res/layout/view_layout.xml b/tests/FrameworkPerf/res/layout/view_layout.xml new file mode 100644 index 0000000..0171eef --- /dev/null +++ b/tests/FrameworkPerf/res/layout/view_layout.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <View android:layout_width="wrap_content" android:layout_height="wrap_content" /> +</LinearLayout> diff --git a/tests/FrameworkPerf/res/values/attrs.xml b/tests/FrameworkPerf/res/values/attrs.xml new file mode 100644 index 0000000..5823537 --- /dev/null +++ b/tests/FrameworkPerf/res/values/attrs.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Base attributes that are available to all Item objects. --> + <declare-styleable name="MenuItem"> + + <!-- The ID of the item. --> + <attr name="android:id" /> + + <!-- The category applied to the item. + (This will be or'ed with the orderInCategory attribute.) --> + <attr name="android:menuCategory" /> + + <!-- The order within the category applied to the item. + (This will be or'ed with the category attribute.) --> + <attr name="android:orderInCategory" /> + + <!-- The title associated with the item. --> + <attr name="android:title" /> + + <!-- The condensed title associated with the item. This is used in situations where the + normal title may be too long to be displayed. --> + <attr name="android:titleCondensed" /> + + <!-- The icon associated with this item. This icon will not always be shown, so + the title should be sufficient in describing this item. --> + <attr name="android:icon" /> + + <!-- The alphabetic shortcut key. This is the shortcut when using a keyboard + with alphabetic keys. --> + <attr name="android:alphabeticShortcut" /> + + <!-- The numeric shortcut key. This is the shortcut when using a numeric (e.g., 12-key) + keyboard. --> + <attr name="android:numericShortcut" /> + + <!-- Whether the item is capable of displaying a check mark. --> + <attr name="android:checkable" /> + + <!-- Whether the item is checked. Note that you must first have enabled checking with + the checkable attribute or else the check mark will not appear. --> + <attr name="android:checked" /> + + <!-- Whether the item is shown/visible. --> + <attr name="android:visible" /> + + <!-- Whether the item is enabled. --> + <attr name="android:enabled" /> + </declare-styleable> +</resources> diff --git a/tests/FrameworkPerf/res/values/strings.xml b/tests/FrameworkPerf/res/values/strings.xml new file mode 100644 index 0000000..82fd713 --- /dev/null +++ b/tests/FrameworkPerf/res/values/strings.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <string name="start">Start</string> + <string name="stop">Stop</string> + <string name="data_usage_menu_roaming">Data roaming</string> + <string name="data_usage_menu_restrict_background">Restrict background data</string> + <string name="data_usage_menu_split_4g">Separate 4G usage</string> + <string name="data_usage_menu_show_wifi">Show Wi-Fi usage</string> + <string name="data_usage_menu_show_ethernet">Show Ethernet usage</string> +</resources> diff --git a/tests/FrameworkPerf/res/xml/simple.xml b/tests/FrameworkPerf/res/xml/simple.xml new file mode 100644 index 0000000..4e938aa --- /dev/null +++ b/tests/FrameworkPerf/res/xml/simple.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> +</menu> diff --git a/tests/FrameworkPerf/res/xml/simple_large.xml b/tests/FrameworkPerf/res/xml/simple_large.xml new file mode 100644 index 0000000..812cec9 --- /dev/null +++ b/tests/FrameworkPerf/res/xml/simple_large.xml @@ -0,0 +1,418 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_roaming" + android:title="@string/data_usage_menu_roaming" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_restrict_background" + android:title="@string/data_usage_menu_restrict_background" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_split_4g" + android:title="@string/data_usage_menu_split_4g" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_wifi" + android:title="@string/data_usage_menu_show_wifi" + android:checkable="true" /> + <item + android:id="@+id/data_usage_menu_show_ethernet" + android:title="@string/data_usage_menu_show_ethernet" + android:checkable="true" /> +</menu> diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java new file mode 100644 index 0000000..30a968f --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java @@ -0,0 +1,464 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Binder; +import android.os.Bundle; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.os.PowerManager; +import android.os.RemoteException; +import android.util.Log; +import android.view.View; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.Spinner; +import android.widget.TextView; + +import java.util.ArrayList; + +/** + * So you thought sync used up your battery life. + */ +public class FrameworkPerfActivity extends Activity + implements AdapterView.OnItemSelectedListener { + static final String TAG = "Perf"; + static final boolean DEBUG = false; + + Spinner mFgSpinner; + Spinner mBgSpinner; + Spinner mLimitSpinner; + TextView mLimitLabel; + TextView mTestTime; + Button mStartButton; + Button mStopButton; + CheckBox mLocalCheckBox; + TextView mLog; + PowerManager.WakeLock mPartialWakeLock; + + long mMaxRunTime = 5000; + boolean mLimitIsIterations; + boolean mStarted; + + final String[] mAvailOpLabels; + final String[] mAvailOpDescriptions; + final String[] mLimitLabels = { "Time", "Iterations" }; + + int mFgTestIndex = -1; + int mBgTestIndex = -1; + TestService.Op mFgTest; + TestService.Op mBgTest; + int mCurOpIndex = 0; + TestConnection mCurConnection; + boolean mConnectionBound; + + final ArrayList<RunResult> mResults = new ArrayList<RunResult>(); + + Object mResultNotifier = new Object(); + + class TestConnection implements ServiceConnection, IBinder.DeathRecipient { + Messenger mService; + boolean mLinked; + + @Override public void onServiceConnected(ComponentName name, IBinder service) { + try { + if (!(service instanceof Binder)) { + // If remote, we'll be killing ye. + service.linkToDeath(this, 0); + mLinked = true; + } + mService = new Messenger(service); + dispatchCurOp(this); + } catch (RemoteException e) { + // Whoops, service has disappeared... try starting again. + Log.w(TAG, "Test service died, starting again"); + startCurOp(); + } + } + + @Override public void onServiceDisconnected(ComponentName name) { + } + + @Override public void binderDied() { + cleanup(); + connectionDied(this); + } + + void cleanup() { + if (mLinked) { + mLinked = false; + mService.getBinder().unlinkToDeath(this, 0); + } + } + } + + static final int MSG_DO_NEXT_TEST = 1000; + + final Handler mHandler = new Handler() { + @Override public void handleMessage(Message msg) { + switch (msg.what) { + case TestService.RES_TEST_FINISHED: { + Bundle bundle = (Bundle)msg.obj; + bundle.setClassLoader(getClassLoader()); + RunResult res = (RunResult)bundle.getParcelable("res"); + completeCurOp(res); + } break; + case MSG_DO_NEXT_TEST: { + startCurOp(); + } break; + } + } + }; + + final Messenger mMessenger = new Messenger(mHandler); + + public FrameworkPerfActivity() { + mAvailOpLabels = new String[TestService.mAvailOps.length]; + mAvailOpDescriptions = new String[TestService.mAvailOps.length]; + for (int i=0; i<TestService.mAvailOps.length; i++) { + TestService.Op op = TestService.mAvailOps[i]; + if (op == null) { + mAvailOpLabels[i] = "All"; + mAvailOpDescriptions[i] = "All tests"; + } else { + mAvailOpLabels[i] = op.getName(); + if (mAvailOpLabels[i] == null) { + mAvailOpLabels[i] = "Nothing"; + } + mAvailOpDescriptions[i] = op.getLongName(); + } + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set the layout for this activity. You can find it + // in res/layout/hello_activity.xml + setContentView(R.layout.main); + + mFgSpinner = (Spinner) findViewById(R.id.fgspinner); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mAvailOpLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mFgSpinner.setAdapter(adapter); + mFgSpinner.setOnItemSelectedListener(this); + mBgSpinner = (Spinner) findViewById(R.id.bgspinner); + adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mAvailOpLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mBgSpinner.setAdapter(adapter); + mBgSpinner.setOnItemSelectedListener(this); + mLimitSpinner = (Spinner) findViewById(R.id.limitspinner); + adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_spinner_item, mLimitLabels); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mLimitSpinner.setAdapter(adapter); + mLimitSpinner.setOnItemSelectedListener(this); + + mTestTime = (TextView)findViewById(R.id.testtime); + mLimitLabel = (TextView)findViewById(R.id.limitlabel); + + mStartButton = (Button)findViewById(R.id.start); + mStartButton.setOnClickListener(new View.OnClickListener() { + @Override public void onClick(View v) { + startRunning(); + } + }); + mStopButton = (Button)findViewById(R.id.stop); + mStopButton.setOnClickListener(new View.OnClickListener() { + @Override public void onClick(View v) { + stopRunning(); + } + }); + mStopButton.setEnabled(false); + mLocalCheckBox = (CheckBox)findViewById(R.id.local); + + mLog = (TextView)findViewById(R.id.log); + + PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE); + mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Scheduler"); + mPartialWakeLock.setReferenceCounted(false); + } + + @Override + public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { + if (parent == mFgSpinner || parent == mBgSpinner || parent == mLimitSpinner) { + TestService.Op op = TestService.mAvailOps[position]; + if (parent == mFgSpinner) { + mFgTestIndex = position; + mFgTest = op; + ((TextView)findViewById(R.id.fgtext)).setText(mAvailOpDescriptions[position]); + } else if (parent == mBgSpinner) { + mBgTestIndex = position; + mBgTest = op; + ((TextView)findViewById(R.id.bgtext)).setText(mAvailOpDescriptions[position]); + } else if (parent == mLimitSpinner) { + mLimitIsIterations = (position != 0); + if (mLimitIsIterations) { + mLimitLabel.setText("Iterations: "); + } else { + mLimitLabel.setText("Test time (ms): "); + } + } + } + } + + @Override + public void onNothingSelected(AdapterView<?> parent) { + } + + @Override + public void onResume() { + super.onResume(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + stopRunning(); + if (mPartialWakeLock.isHeld()) { + mPartialWakeLock.release(); + } + } + + void dispatchCurOp(TestConnection conn) { + if (mCurConnection != conn) { + Log.w(TAG, "Dispatching on invalid connection: " + conn); + return; + } + TestArgs args = new TestArgs(); + if (mLimitIsIterations) { + args.maxOps = mMaxRunTime; + } else { + args.maxTime = mMaxRunTime; + } + if (mFgTestIndex == 0 && mBgTestIndex == 0) { + args.combOp = mCurOpIndex; + } else if (mFgTestIndex != 0 && mBgTestIndex != 0) { + args.fgOp = mFgTestIndex; + args.bgOp = mBgTestIndex; + } else { + // Skip null test. + if (mCurOpIndex == 0) { + mCurOpIndex = 1; + } + if (mFgTestIndex != 0) { + args.fgOp = mFgTestIndex; + args.bgOp = mCurOpIndex; + } else { + args.fgOp = mCurOpIndex; + args.bgOp = mFgTestIndex; + } + } + Bundle bundle = new Bundle(); + bundle.putParcelable("args", args); + Message msg = Message.obtain(null, TestService.CMD_START_TEST, bundle); + msg.replyTo = mMessenger; + try { + conn.mService.send(msg); + } catch (RemoteException e) { + Log.w(TAG, "Failure communicating with service", e); + } + } + + void completeCurOp(RunResult result) { + log(String.format("%s: fg=%d*%gms/op (%dms) / bg=%d*%gms/op (%dms)", + result.name, result.fgOps, result.getFgMsPerOp(), result.fgTime, + result.bgOps, result.getBgMsPerOp(), result.bgTime)); + synchronized (mResults) { + mResults.add(result); + } + if (!mStarted) { + log("Stop"); + stopRunning(); + return; + } + if (mFgTest != null && mBgTest != null) { + log("Finished"); + stopRunning(); + return; + } + if (mFgTest == null && mBgTest == null) { + mCurOpIndex+=2; + if (mCurOpIndex >= TestService.mOpPairs.length) { + log("Finished"); + stopRunning(); + return; + } + } else { + mCurOpIndex++; + if (mCurOpIndex >= TestService.mAvailOps.length) { + log("Finished"); + stopRunning(); + return; + } + } + startCurOp(); + } + + void disconnect() { + final TestConnection conn = mCurConnection; + if (conn != null) { + if (DEBUG) { + RuntimeException here = new RuntimeException("here"); + here.fillInStackTrace(); + Log.i(TAG, "Unbinding " + conn, here); + } + if (mConnectionBound) { + unbindService(conn); + mConnectionBound = false; + } + if (conn.mLinked) { + Message msg = Message.obtain(null, TestService.CMD_TERMINATE); + try { + conn.mService.send(msg); + return; + } catch (RemoteException e) { + Log.w(TAG, "Test service aleady died when terminating"); + } + } + conn.cleanup(); + } + connectionDied(conn); + } + + void connectionDied(TestConnection conn) { + if (mCurConnection == conn) { + // Now that we know the test process has died, we can commence + // the next test. Just give a little delay to allow the activity + // manager to know it has died as well (not a disaster if it hasn't + // yet, though). + if (mConnectionBound) { + unbindService(conn); + } + mCurConnection = null; + mHandler.sendMessageDelayed(Message.obtain(null, MSG_DO_NEXT_TEST), 100); + } + } + + void startCurOp() { + if (DEBUG) Log.i(TAG, "startCurOp: mCurConnection=" + mCurConnection); + if (mCurConnection != null) { + disconnect(); + return; + } + if (mStarted) { + mHandler.removeMessages(TestService.RES_TEST_FINISHED); + mHandler.removeMessages(TestService.RES_TERMINATED); + mHandler.removeMessages(MSG_DO_NEXT_TEST); + mCurConnection = new TestConnection(); + Intent intent; + if (mLocalCheckBox.isChecked()) { + intent = new Intent(this, LocalTestService.class); + } else { + intent = new Intent(this, TestService.class); + } + if (DEBUG) { + RuntimeException here = new RuntimeException("here"); + here.fillInStackTrace(); + Log.i(TAG, "Binding " + mCurConnection, here); + } + bindService(intent, mCurConnection, BIND_AUTO_CREATE|BIND_IMPORTANT); + mConnectionBound = true; + } + } + + void startRunning() { + if (!mStarted) { + log("Start"); + mStarted = true; + mStartButton.setEnabled(false); + mStopButton.setEnabled(true); + mLocalCheckBox.setEnabled(false); + mTestTime.setEnabled(false); + mFgSpinner.setEnabled(false); + mBgSpinner.setEnabled(false); + mLimitSpinner.setEnabled(false); + updateWakeLock(); + startService(new Intent(this, SchedulerService.class)); + mCurOpIndex = 0; + mMaxRunTime = Integer.parseInt(mTestTime.getText().toString()); + synchronized (mResults) { + mResults.clear(); + } + startCurOp(); + } + } + + void stopRunning() { + if (mStarted) { + disconnect(); + mStarted = false; + mStartButton.setEnabled(true); + mStopButton.setEnabled(false); + mLocalCheckBox.setEnabled(true); + mTestTime.setEnabled(true); + mFgSpinner.setEnabled(true); + mBgSpinner.setEnabled(true); + mLimitSpinner.setEnabled(true); + updateWakeLock(); + stopService(new Intent(this, SchedulerService.class)); + synchronized (mResults) { + for (int i=0; i<mResults.size(); i++) { + RunResult result = mResults.get(i); + float fgMsPerOp = result.getFgMsPerOp(); + float bgMsPerOp = result.getBgMsPerOp(); + String fgMsPerOpStr = fgMsPerOp != 0 ? Float.toString(fgMsPerOp) : ""; + String bgMsPerOpStr = bgMsPerOp != 0 ? Float.toString(bgMsPerOp) : ""; + Log.i("PerfRes", "\t" + result.name + "\t" + result.fgOps + + "\t" + result.getFgMsPerOp() + "\t" + result.fgTime + + "\t" + result.fgLongName + "\t" + result.bgOps + + "\t" + result.getBgMsPerOp() + "\t" + result.bgTime + + "\t" + result.bgLongName); + } + } + synchronized (mResultNotifier) { + mResultNotifier.notifyAll(); + } + } + } + + void updateWakeLock() { + if (mStarted) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + if (!mPartialWakeLock.isHeld()) { + mPartialWakeLock.acquire(); + } + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + if (mPartialWakeLock.isHeld()) { + mPartialWakeLock.release(); + } + } + } + + void log(String s) { + mLog.setText(mLog.getText() + "\n" + s); + Log.i(TAG, s); + } +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java new file mode 100644 index 0000000..2a53b06 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfTest.java @@ -0,0 +1,41 @@ +package com.android.frameworkperf; + +import android.app.Activity; +import android.os.Bundle; +import android.test.ActivityInstrumentationTestCase2; + +public class FrameworkPerfTest extends ActivityInstrumentationTestCase2<FrameworkPerfActivity> { + + private static final int TEST_TIMEOUT = 15 * 60 * 1000; //15 minutes + + public FrameworkPerfTest() { + super("com.android.frameworkperf", FrameworkPerfActivity.class); + } + + public void testFrameworkPerf() { + final FrameworkPerfActivity activity = getActivity(); + synchronized (activity.mResultNotifier) { + getInstrumentation().runOnMainSync(new Runnable() { + @Override + public void run() { + activity.startRunning(); + } + }); + try { + activity.mResultNotifier.wait(TEST_TIMEOUT); + } catch (InterruptedException e) { + fail("test interrupted."); + } + } + Bundle testResult = new Bundle(); + synchronized (activity.mResults) { + assertTrue("test results were empty.", activity.mResults.size() > 0); + for (RunResult result : activity.mResults) { + testResult.putString(result.name, String.format("%f,%d,%d,%f,%d,%d", + result.getFgMsPerOp(), result.fgOps, result.fgTime, + result.getBgMsPerOp(), result.bgOps, result.bgTime)); + } + } + getInstrumentation().sendStatus(Activity.RESULT_OK, testResult); + } +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/LocalTestService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/LocalTestService.java new file mode 100644 index 0000000..09c6be8 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/LocalTestService.java @@ -0,0 +1,6 @@ +package com.android.frameworkperf; + +public class LocalTestService extends TestService { + void terminate() { + } +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java b/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java new file mode 100644 index 0000000..e17d0a7 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/Receiver.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +/** + * Allow launching as an empty process. + */ +public class Receiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + } +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/RunResult.java b/tests/FrameworkPerf/src/com/android/frameworkperf/RunResult.java new file mode 100644 index 0000000..d14e434 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/RunResult.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.os.Parcel; +import android.os.Parcelable; + +public class RunResult implements Parcelable { + final String name; + final String fgLongName; + final String bgLongName; + final long fgTime; + final long fgOps; + final long bgTime; + final long bgOps; + + RunResult(TestService.TestRunner op) { + name = op.getName(); + fgLongName = op.getForegroundLongName(); + bgLongName = op.getBackgroundLongName(); + fgTime = op.getForegroundTime(); + fgOps = op.getForegroundOps(); + bgTime = op.getBackgroundTime(); + bgOps = op.getBackgroundOps(); + } + + RunResult(Parcel source) { + name = source.readString(); + fgLongName = source.readString(); + bgLongName = source.readString(); + fgTime = source.readLong(); + fgOps = source.readLong(); + bgTime = source.readLong(); + bgOps = source.readLong(); + } + + float getFgMsPerOp() { + return fgOps != 0 ? (fgTime / (float)fgOps) : 0; + } + + float getBgMsPerOp() { + return bgOps != 0 ? (bgTime / (float)bgOps) : 0; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(name); + dest.writeString(fgLongName); + dest.writeString(bgLongName); + dest.writeLong(fgTime); + dest.writeLong(fgOps); + dest.writeLong(bgTime); + dest.writeLong(bgOps); + } + + public static final Parcelable.Creator<RunResult> CREATOR + = new Parcelable.Creator<RunResult>() { + public RunResult createFromParcel(Parcel in) { + return new RunResult(in); + } + + public RunResult[] newArray(int size) { + return new RunResult[size]; + } + }; +}
\ No newline at end of file diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/SchedulerService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/SchedulerService.java new file mode 100644 index 0000000..7691e64 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/SchedulerService.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.app.Notification; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +public class SchedulerService extends Service { + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Notification status = new Notification(R.drawable.stat_happy, null, + System.currentTimeMillis()); + status.flags |= Notification.FLAG_ONGOING_EVENT; + status.setLatestEventInfo(this, "Scheduler Test running", + "Scheduler Test running", PendingIntent.getActivity(this, 0, + new Intent(this, FrameworkPerfActivity.class) + .setAction(Intent.ACTION_MAIN) + .addCategory(Intent.CATEGORY_LAUNCHER) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0)); + startForeground(1, status); + return START_STICKY; + } + + @Override + public IBinder onBind(Intent intent) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/SimpleInflater.java b/tests/FrameworkPerf/src/com/android/frameworkperf/SimpleInflater.java new file mode 100644 index 0000000..5cbb12a --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/SimpleInflater.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import java.io.IOException; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import android.content.Context; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.util.AttributeSet; +import android.util.Xml; +import android.view.InflateException; + +public class SimpleInflater { + /** Menu tag name in XML. */ + private static final String XML_MENU = "menu"; + + /** Group tag name in XML. */ + private static final String XML_GROUP = "group"; + + /** Item tag name in XML. */ + private static final String XML_ITEM = "item"; + + private Context mContext; + + public SimpleInflater(Context context) { + mContext = context; + } + + public void inflate(int menuRes) { + XmlResourceParser parser = null; + try { + parser = mContext.getResources().getLayout(menuRes); + AttributeSet attrs = Xml.asAttributeSet(parser); + + parseMenu(parser, attrs); + } catch (XmlPullParserException e) { + throw new InflateException("Error inflating menu XML", e); + } catch (IOException e) { + throw new InflateException("Error inflating menu XML", e); + } finally { + if (parser != null) parser.close(); + } + } + + private void parseMenu(XmlPullParser parser, AttributeSet attrs) + throws XmlPullParserException, IOException { + int eventType = parser.getEventType(); + String tagName; + boolean lookingForEndOfUnknownTag = false; + String unknownTagName = null; + + // This loop will skip to the menu start tag + do { + if (eventType == XmlPullParser.START_TAG) { + tagName = parser.getName(); + if (tagName.equals(XML_MENU)) { + // Go to next tag + eventType = parser.next(); + break; + } + + throw new RuntimeException("Expecting menu, got " + tagName); + } + eventType = parser.next(); + } while (eventType != XmlPullParser.END_DOCUMENT); + + boolean reachedEndOfMenu = false; + while (!reachedEndOfMenu) { + switch (eventType) { + case XmlPullParser.START_TAG: + if (lookingForEndOfUnknownTag) { + break; + } + + tagName = parser.getName(); + if (tagName.equals(XML_ITEM)) { + readItem(attrs); + } else if (tagName.equals(XML_MENU)) { + parseMenu(parser, attrs); + } else { + lookingForEndOfUnknownTag = true; + unknownTagName = tagName; + } + break; + + case XmlPullParser.END_TAG: + tagName = parser.getName(); + if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) { + lookingForEndOfUnknownTag = false; + unknownTagName = null; + } else if (tagName.equals(XML_ITEM)) { + } else if (tagName.equals(XML_MENU)) { + reachedEndOfMenu = true; + } + break; + + case XmlPullParser.END_DOCUMENT: + throw new RuntimeException("Unexpected end of document"); + } + + eventType = parser.next(); + } + } + + public void readItem(AttributeSet attrs) { + TypedArray a = mContext.obtainStyledAttributes(attrs, + com.android.internal.R.styleable.MenuItem); + + // Inherit attributes from the group as default value + int itemId = a.getResourceId(R.styleable.MenuItem_android_id, 0); + final int category = a.getInt(R.styleable.MenuItem_android_menuCategory, 0); + final int order = a.getInt(R.styleable.MenuItem_android_orderInCategory, 0); + CharSequence itemTitle = a.getText(R.styleable.MenuItem_android_title); + CharSequence itemTitleCondensed = a.getText(R.styleable.MenuItem_android_titleCondensed); + int itemIconResId = a.getResourceId(R.styleable.MenuItem_android_icon, 0); + String itemAlphabeticShortcut = a.getString(R.styleable.MenuItem_android_alphabeticShortcut); + String itemNumericShortcut = a.getString(R.styleable.MenuItem_android_numericShortcut); + int itemCheckable = 0; + if (a.hasValue(R.styleable.MenuItem_android_checkable)) { + // Item has attribute checkable, use it + itemCheckable = a.getBoolean(R.styleable.MenuItem_android_checkable, false) ? 1 : 0; + } + boolean itemChecked = a.getBoolean(R.styleable.MenuItem_android_checked, false); + boolean itemVisible = a.getBoolean(R.styleable.MenuItem_android_visible, false); + boolean itemEnabled = a.getBoolean(R.styleable.MenuItem_android_enabled, false); + + a.recycle(); + } +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java new file mode 100644 index 0000000..2fe38aa --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import android.os.Parcel; +import android.os.Parcelable; + +public class TestArgs implements Parcelable { + long maxTime; + long maxOps = -1; + int combOp = -1; + int fgOp = -1; + int bgOp = -1; + + public TestArgs() { + } + + public TestArgs(Parcel source) { + maxTime = source.readLong(); + maxOps = source.readLong(); + combOp = source.readInt(); + fgOp = source.readInt(); + bgOp = source.readInt(); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeLong(maxTime); + dest.writeLong(maxOps); + dest.writeInt(combOp); + dest.writeInt(fgOp); + dest.writeInt(bgOp); + } + + public static final Parcelable.Creator<TestArgs> CREATOR + = new Parcelable.Creator<TestArgs>() { + public TestArgs createFromParcel(Parcel in) { + return new TestArgs(in); + } + + public TestArgs[] newArray(int size) { + return new TestArgs[size]; + } + }; +} diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java new file mode 100644 index 0000000..a8c43e9 --- /dev/null +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java @@ -0,0 +1,1114 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworkperf; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.res.TypedArray; +import android.content.res.XmlResourceParser; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Paint; +import android.os.Bundle; +import android.os.FileUtils; +import android.os.Handler; +import android.os.IBinder; +import android.os.Looper; +import android.os.Message; +import android.os.Messenger; +import android.os.Process; +import android.os.RemoteException; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.Log; +import android.util.Xml; +import android.view.LayoutInflater; + +public class TestService extends Service { + static final String TAG = "Perf"; + + final static Op[] mOpPairs = new Op[] { + new MethodCallOp(), new NoOp(), + new MethodCallOp(), new CpuOp(), + new MethodCallOp(), new SchedulerOp(), + new MethodCallOp(), new GcOp(), + new MethodCallOp(), new CreateFileOp(), + new MethodCallOp(), new CreateWriteFileOp(), + new MethodCallOp(), new CreateWriteSyncFileOp(), + new MethodCallOp(), new WriteFileOp(), + new MethodCallOp(), new ReadFileOp(), + new SchedulerOp(), new SchedulerOp(), + new GcOp(), new NoOp(), + new ObjectGcOp(), new NoOp(), + new FinalizingGcOp(), new NoOp(), + new PaintGcOp(), new NoOp(), + new IpcOp(), new NoOp(), + new IpcOp(), new CpuOp(), + new IpcOp(), new SchedulerOp(), + new IpcOp(), new GcOp(), + new IpcOp(), new CreateFileOp(), + new IpcOp(), new CreateWriteFileOp(), + new IpcOp(), new CreateWriteSyncFileOp(), + new IpcOp(), new WriteFileOp(), + new IpcOp(), new ReadFileOp(), + new CreateFileOp(), new NoOp(), + new CreateWriteFileOp(), new NoOp(), + new CreateWriteSyncFileOp(), new NoOp(), + new WriteFileOp(), new NoOp(), + new ReadFileOp(), new NoOp(), + new WriteFileOp(), new CreateWriteFileOp(), + new ReadFileOp(), new CreateWriteFileOp(), + new WriteFileOp(), new CreateWriteSyncFileOp(), + new ReadFileOp(), new CreateWriteSyncFileOp(), + new WriteFileOp(), new WriteFileOp(), + new WriteFileOp(), new ReadFileOp(), + new ReadFileOp(), new WriteFileOp(), + new ReadFileOp(), new ReadFileOp(), + new OpenXmlResOp(), new NoOp(), + new ReadXmlAttrsOp(), new NoOp(), + new ParseXmlResOp(), new NoOp(), + new ParseLargeXmlResOp(), new NoOp(), + new LayoutInflaterOp(), new NoOp(), + new LayoutInflaterLargeOp(), new NoOp(), + new LayoutInflaterViewOp(), new NoOp(), + new LayoutInflaterButtonOp(), new NoOp(), + new LayoutInflaterImageButtonOp(), new NoOp(), + new CreateBitmapOp(), new NoOp(), + new CreateRecycleBitmapOp(), new NoOp(), + new LoadSmallBitmapOp(), new NoOp(), + new LoadRecycleSmallBitmapOp(), new NoOp(), + new LoadLargeBitmapOp(), new NoOp(), + new LoadRecycleLargeBitmapOp(), new NoOp(), + new LoadSmallScaledBitmapOp(), new NoOp(), + new LoadLargeScaledBitmapOp(), new NoOp(), + }; + + final static Op[] mAvailOps = new Op[] { + null, + new NoOp(), + new CpuOp(), + new SchedulerOp(), + new MethodCallOp(), + new GcOp(), + new ObjectGcOp(), + new FinalizingGcOp(), + new PaintGcOp(), + new IpcOp(), + new CreateFileOp(), + new CreateWriteFileOp(), + new CreateWriteSyncFileOp(), + new WriteFileOp(), + new ReadFileOp(), + new OpenXmlResOp(), + new ReadXmlAttrsOp(), + new ParseXmlResOp(), + new ParseLargeXmlResOp(), + new LayoutInflaterOp(), + new LayoutInflaterLargeOp(), + new LayoutInflaterViewOp(), + new LayoutInflaterButtonOp(), + new LayoutInflaterImageButtonOp(), + new CreateBitmapOp(), + new CreateRecycleBitmapOp(), + new LoadSmallBitmapOp(), + new LoadRecycleSmallBitmapOp(), + new LoadLargeBitmapOp(), + new LoadRecycleLargeBitmapOp(), + new LoadSmallScaledBitmapOp(), + new LoadLargeScaledBitmapOp(), + }; + + static final int CMD_START_TEST = 1; + static final int CMD_TERMINATE = 2; + + static final int MSG_REALLY_START = 1000; + static final int MSG_REALLY_TERMINATE = 1001; + + static final int RES_TEST_FINISHED = 1; + static final int RES_TERMINATED = 2; + + final Handler mHandler = new Handler() { + @Override public void handleMessage(Message msg) { + switch (msg.what) { + case CMD_START_TEST: { + // Give a little time for things to settle down. + Message newMsg = Message.obtain(null, MSG_REALLY_START); + newMsg.obj = msg.obj; + newMsg.replyTo = msg.replyTo; + sendMessageDelayed(newMsg, 500); + } break; + case MSG_REALLY_START: { + Bundle bundle = (Bundle)msg.obj; + bundle.setClassLoader(getClassLoader()); + final TestArgs args = (TestArgs)bundle.getParcelable("args"); + final Messenger replyTo = msg.replyTo; + mRunner.run(this, args, new Runnable() { + @Override public void run() { + if (replyTo != null) { + Message msg = Message.obtain(null, RES_TEST_FINISHED); + Bundle bundle = new Bundle(); + bundle.putParcelable("res", new RunResult(mRunner)); + msg.obj = bundle; + try { + replyTo.send(msg); + } catch (RemoteException e) { + } + } + } + }); + } break; + case CMD_TERMINATE: { + // Give a little time for things to settle down. + Message newMsg = Message.obtain(null, MSG_REALLY_TERMINATE); + newMsg.obj = msg.obj; + newMsg.replyTo = msg.replyTo; + sendMessageDelayed(newMsg, 50); + } break; + case MSG_REALLY_TERMINATE: { + if (msg.replyTo != null) { + Message reply = Message.obtain(null, RES_TERMINATED); + try { + msg.replyTo.send(reply); + } catch (RemoteException e) { + } + } + terminate(); + } break; + } + } + }; + + final TestRunner mRunner = new TestRunner(); + + @Override + public IBinder onBind(Intent intent) { + return (new Messenger(mHandler)).getBinder(); + } + + void terminate() { + Runtime.getRuntime().exit(0); + } + + enum BackgroundMode { + NOTHING, + CPU, + SCHEDULER + }; + + public class TestRunner { + Handler mHandler; + long mMaxRunTime; + long mMaxOps; + Op mForegroundOp; + Op mBackgroundOp; + Runnable mDoneCallback; + + RunnerThread mBackgroundThread; + RunnerThread mForegroundThread; + long mStartTime; + + boolean mBackgroundRunning; + boolean mForegroundRunning; + + long mBackgroundEndTime; + long mBackgroundOps; + long mForegroundEndTime; + long mForegroundOps; + + public TestRunner() { + } + + public String getForegroundName() { + return mForegroundOp.getName(); + } + + public String getBackgroundName() { + return mBackgroundOp.getName(); + } + + public String getName() { + String fgName = mForegroundOp.getName(); + String bgName = mBackgroundOp.getName(); + StringBuilder res = new StringBuilder(); + if (fgName != null) { + res.append(fgName); + res.append("Fg"); + } + if (bgName != null) { + res.append(bgName); + res.append("Bg"); + } + return res.toString(); + } + + public String getForegroundLongName() { + return mForegroundOp.getLongName(); + } + + public String getBackgroundLongName() { + return mBackgroundOp.getLongName(); + } + + public void run(Handler handler, TestArgs args, Runnable doneCallback) { + mHandler = handler; + mMaxRunTime = args.maxTime; + mMaxOps = args.maxOps; + if (args.combOp >= 0) { + mForegroundOp = mOpPairs[args.combOp]; + mBackgroundOp = mOpPairs[args.combOp+1]; + } else { + mForegroundOp = mAvailOps[args.fgOp]; + mBackgroundOp = mAvailOps[args.bgOp]; + } + mDoneCallback = doneCallback; + mBackgroundThread = new RunnerThread("background", new Runnable() { + @Override public void run() { + boolean running; + int ops = 0; + do { + running = mBackgroundOp.onRun(); + ops++; + } while (evalRepeat(running, true) && running); + mBackgroundEndTime = SystemClock.uptimeMillis(); + mBackgroundOps = ops * mBackgroundOp.getOpsPerRun(); + threadFinished(false); + } + }, Process.THREAD_PRIORITY_BACKGROUND); + mForegroundThread = new RunnerThread("background", new Runnable() { + @Override public void run() { + boolean running; + int ops = 0; + do { + running = mForegroundOp.onRun(); + ops++; + } while (evalRepeat(true, running) && running); + mForegroundEndTime = SystemClock.uptimeMillis(); + mForegroundOps = ops * mForegroundOp.getOpsPerRun(); + threadFinished(true); + } + }, Process.THREAD_PRIORITY_FOREGROUND); + + mForegroundOp.onInit(TestService.this, true); + mBackgroundOp.onInit(TestService.this, false); + + synchronized (this) { + mStartTime = SystemClock.uptimeMillis(); + mBackgroundRunning = true; + mForegroundRunning = true; + } + + mBackgroundThread.start(); + mForegroundThread.start(); + } + + public long getForegroundTime() { + return mForegroundEndTime-mStartTime; + } + + public long getForegroundOps() { + return mForegroundOps; + } + + public long getBackgroundTime() { + return mBackgroundEndTime-mStartTime; + } + + public long getBackgroundOps() { + return mBackgroundOps; + } + + private boolean evalRepeat(boolean bgRunning, boolean fgRunning) { + synchronized (this) { + if (!bgRunning) { + mBackgroundRunning = false; + } + if (!fgRunning) { + mForegroundRunning = false; + } + if (!mBackgroundRunning && !mForegroundRunning) { + return false; + } + if (mMaxOps > 0) { + // iteration-limited case + if (mForegroundOps >= mMaxOps) { + return false; + } + mForegroundOps++; + } else { + // time-limited case + long now = SystemClock.uptimeMillis(); + if (now > (mStartTime+mMaxRunTime)) { + return false; + } + } + return true; + } + } + + private void threadFinished(boolean foreground) { + synchronized (this) { + if (foreground) { + mForegroundRunning = false; + } else { + mBackgroundRunning = false; + } + if (!mBackgroundRunning && !mForegroundRunning) { + mHandler.post(new Runnable() { + @Override public void run() { + mForegroundOp.onTerm(TestService.this); + mBackgroundOp.onTerm(TestService.this); + if (mDoneCallback != null) { + mDoneCallback.run(); + } + } + }); + } + } + } + } + + class RunnerThread extends Thread { + private final Runnable mOp; + private final int mPriority; + + RunnerThread(String name, Runnable op, int priority) { + super(name); + mOp = op; + mPriority = priority; + } + + public void run() { + Process.setThreadPriority(mPriority); + mOp.run(); + } + } + + static public abstract class Op { + final String mName; + final String mLongName; + + public Op(String name, String longName) { + mName = name; + mLongName = longName; + } + + public String getName() { + return mName; + } + + public String getLongName() { + return mLongName; + } + + void onInit(Context context, boolean foreground) { + } + + abstract boolean onRun(); + + void onTerm(Context context) { + } + + int getOpsPerRun() { + return 1; + } + } + + static class NoOp extends Op { + NoOp() { + super(null, "Nothing"); + } + + boolean onRun() { + return false; + } + + int getOpsPerRun() { + return 0; + } + } + + static class CpuOp extends Op { + CpuOp() { + super("CPU", "Consume CPU"); + } + + boolean onRun() { + return true; + } + } + + static class SchedulerOp extends Op { + SchedulerOp() { + super("Sched", "Change scheduler group"); + } + + boolean onRun() { + Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND); + Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); + return true; + } + } + + static class GcOp extends Op { + GcOp() { + super("Gc", "Run garbage collector"); + } + + boolean onRun() { + byte[] stuff = new byte[1024*1024]; + return true; + } + } + + static class ObjectGcOp extends Op { + ObjectGcOp() { + super("ObjectGc", "Run garbage collector with simple objects"); + } + + boolean onRun() { + Object obj = new Object(); + return true; + } + } + + static class FinalizingGcOp extends Op { + class Finalizable { + Finalizable() {} + @Override + protected void finalize() throws Throwable { + super.finalize(); + } + } + + FinalizingGcOp() { + super("FinalizingGc", "Run garbage collector with finalizable objects"); + } + + boolean onRun() { + Finalizable obj = new Finalizable(); + return true; + } + } + + static class PaintGcOp extends Op { + PaintGcOp() { + super("PaintGc", "Run garbage collector with Paint objects"); + } + + boolean onRun() { + Paint p = new Paint(); + return true; + } + } + + static class MethodCallOp extends Op { + MethodCallOp() { + super("MethodCall", "Method call"); + } + + boolean onRun() { + final int N = getOpsPerRun(); + for (int i=0; i<N; i++) { + someFunc(i); + } + return true; + } + + int someFunc(int foo) { + return 0; + } + + int getOpsPerRun() { + return 500; + } + } + + static class IpcOp extends Op { + PackageManager mPm; + String mProcessName; + + IpcOp() { + super("Ipc", "IPC to system process"); + } + + void onInit(Context context, boolean foreground) { + mPm = context.getPackageManager(); + mProcessName = context.getApplicationInfo().processName; + } + + boolean onRun() { + final int N = getOpsPerRun(); + for (int i=0; i<N; i++) { + mPm.queryContentProviders(mProcessName, Process.myUid(), 0); + } + return true; + } + + int getOpsPerRun() { + return 100; + } + } + + static class OpenXmlResOp extends Op { + Context mContext; + + OpenXmlResOp() { + super("OpenXmlRes", "Open (and close) an XML resource"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + XmlResourceParser parser = mContext.getResources().getLayout(R.xml.simple); + parser.close(); + return true; + } + } + + static class ReadXmlAttrsOp extends Op { + Context mContext; + XmlResourceParser mParser; + AttributeSet mAttrs; + + ReadXmlAttrsOp() { + super("ReadXmlAttrs", "Read attributes from an XML tag"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + mParser = mContext.getResources().getLayout(R.xml.simple); + mAttrs = Xml.asAttributeSet(mParser); + + int eventType; + try { + // Find the first <item> tag. + eventType = mParser.getEventType(); + String tagName; + do { + if (eventType == XmlPullParser.START_TAG) { + tagName = mParser.getName(); + if (tagName.equals("item")) { + break; + } + } + eventType = mParser.next(); + } while (eventType != XmlPullParser.END_DOCUMENT); + } catch (XmlPullParserException e) { + throw new RuntimeException("I died", e); + } catch (IOException e) { + throw new RuntimeException("I died", e); + } + } + + void onTerm(Context context) { + mParser.close(); + } + + boolean onRun() { + TypedArray a = mContext.obtainStyledAttributes(mAttrs, + com.android.internal.R.styleable.MenuItem); + a.recycle(); + return true; + } + } + + static class ParseXmlResOp extends Op { + Context mContext; + + ParseXmlResOp() { + super("ParseXmlRes", "Parse compiled XML resource"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + SimpleInflater inf = new SimpleInflater(mContext); + inf.inflate(R.xml.simple); + return true; + } + } + + static class ParseLargeXmlResOp extends Op { + Context mContext; + + ParseLargeXmlResOp() { + super("ParseLargeXmlRes", "Parse large XML resource"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + SimpleInflater inf = new SimpleInflater(mContext); + inf.inflate(R.xml.simple_large); + return true; + } + } + + static class LayoutInflaterOp extends Op { + Context mContext; + + LayoutInflaterOp() { + super("LayoutInflater", "Inflate layout resource"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + if (Looper.myLooper() == null) { + Looper.prepare(); + } + LayoutInflater inf = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inf.inflate(R.layout.small_layout, null); + return true; + } + } + + static class LayoutInflaterLargeOp extends Op { + Context mContext; + + LayoutInflaterLargeOp() { + super("LayoutInflaterLarge", "Inflate large layout resource"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + if (Looper.myLooper() == null) { + Looper.prepare(); + } + LayoutInflater inf = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inf.inflate(R.layout.large_layout, null); + return true; + } + } + + static class LayoutInflaterViewOp extends Op { + Context mContext; + + LayoutInflaterViewOp() { + super("LayoutInflaterView", "Inflate layout with 50 View objects"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + if (Looper.myLooper() == null) { + Looper.prepare(); + } + LayoutInflater inf = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inf.inflate(R.layout.view_layout, null); + return true; + } + } + + static class LayoutInflaterButtonOp extends Op { + Context mContext; + + LayoutInflaterButtonOp() { + super("LayoutInflaterButton", "Inflate layout with 50 Button objects"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + if (Looper.myLooper() == null) { + Looper.prepare(); + } + LayoutInflater inf = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inf.inflate(R.layout.button_layout, null); + return true; + } + } + + static class LayoutInflaterImageButtonOp extends Op { + Context mContext; + + LayoutInflaterImageButtonOp() { + super("LayoutInflaterImageButton", "Inflate layout with 50 ImageButton objects"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + if (Looper.myLooper() == null) { + Looper.prepare(); + } + LayoutInflater inf = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inf.inflate(R.layout.image_button_layout, null); + return true; + } + } + + static class CreateBitmapOp extends Op { + Context mContext; + + CreateBitmapOp() { + super("CreateBitmap", "Create a Bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888); + return true; + } + } + + static class CreateRecycleBitmapOp extends Op { + Context mContext; + + CreateRecycleBitmapOp() { + super("CreateRecycleBitmap", "Create and recycle a Bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888); + bm.recycle(); + return true; + } + } + + static class LoadSmallBitmapOp extends Op { + Context mContext; + + LoadSmallBitmapOp() { + super("LoadSmallBitmap", "Load small raw bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.stat_sample, opts); + return true; + } + } + + static class LoadRecycleSmallBitmapOp extends Op { + Context mContext; + + LoadRecycleSmallBitmapOp() { + super("LoadRecycleSmallBitmap", "Load and recycle small raw bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.stat_sample, opts); + bm.recycle(); + return true; + } + } + + static class LoadLargeBitmapOp extends Op { + Context mContext; + + LoadLargeBitmapOp() { + super("LoadLargeBitmap", "Load large raw bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.wallpaper_goldengate, opts); + return true; + } + } + + static class LoadRecycleLargeBitmapOp extends Op { + Context mContext; + + LoadRecycleLargeBitmapOp() { + super("LoadRecycleLargeBitmap", "Load and recycle large raw bitmap"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.wallpaper_goldengate, opts); + bm.recycle(); + return true; + } + } + + static class LoadSmallScaledBitmapOp extends Op { + Context mContext; + + LoadSmallScaledBitmapOp() { + super("LoadSmallScaledBitmap", "Load small raw bitmap that is scaled for density"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.stat_sample_scale, opts); + return true; + } + } + + static class LoadLargeScaledBitmapOp extends Op { + Context mContext; + + LoadLargeScaledBitmapOp() { + super("LoadLargeScaledBitmap", "Load large raw bitmap that is scaled for density"); + } + + void onInit(Context context, boolean foreground) { + mContext = context; + } + + boolean onRun() { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; + Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.wallpaper_goldengate_scale, opts); + return true; + } + } + + static class CreateFileOp extends Op { + File mFile; + + CreateFileOp() { + super("CreateFile", "Create and delete a file"); + } + + void onInit(Context context, boolean foreground) { + mFile = context.getFileStreamPath(foreground ? "test-fg.file" : "test-bg.file"); + mFile.delete(); + } + + boolean onRun() { + try { + mFile.createNewFile(); + } catch (IOException e) { + Log.w(TAG, "Failure creating " + mFile, e); + } + mFile.delete(); + return true; + } + } + + static class CreateWriteFileOp extends Op { + File mFile; + + CreateWriteFileOp() { + super("CreateWriteFile", "Create, write, and delete a file"); + } + + void onInit(Context context, boolean foreground) { + mFile = context.getFileStreamPath(foreground ? "test-fg.file" : "test-bg.file"); + mFile.delete(); + } + + boolean onRun() { + try { + FileOutputStream fos = new FileOutputStream(mFile); + fos.write(1); + fos.close(); + } catch (IOException e) { + Log.w(TAG, "Failure creating " + mFile, e); + } + mFile.delete(); + return true; + } + } + + static class CreateWriteSyncFileOp extends Op { + File mFile; + + CreateWriteSyncFileOp() { + super("CreateWriteSyncFile", "Create, write, sync, and delete a file"); + } + + void onInit(Context context, boolean foreground) { + mFile = context.getFileStreamPath(foreground ? "test-fg.file" : "test-bg.file"); + mFile.delete(); + } + + boolean onRun() { + try { + FileOutputStream fos = new FileOutputStream(mFile); + fos.write(1); + fos.flush(); + FileUtils.sync(fos); + fos.close(); + } catch (IOException e) { + Log.w(TAG, "Failure creating " + mFile, e); + } + mFile.delete(); + return true; + } + } + + static class WriteFileOp extends Op { + File mFile; + RandomAccessFile mRAF; + byte[] mBuffer; + + WriteFileOp() { + super("WriteFile", "Truncate and write a 64k file"); + } + + void onInit(Context context, boolean foreground) { + mBuffer = new byte[1024*64]; + for (int i=0; i<mBuffer.length; i++) { + mBuffer[i] = (byte)i; + } + mFile = context.getFileStreamPath(foreground ? "test-fg.file" : "test-bg.file"); + mFile.delete(); + try { + mRAF = new RandomAccessFile(mFile, "rw"); + } catch (FileNotFoundException e) { + Log.w(TAG, "Failure creating " + mFile, e); + } + } + + boolean onRun() { + try { + mRAF.seek(0); + mRAF.setLength(0); + mRAF.write(mBuffer); + } catch (IOException e) { + Log.w(TAG, "Failure writing " + mFile, e); + } + return true; + } + + void onTerm(Context context) { + try { + mRAF.close(); + } catch (IOException e) { + Log.w(TAG, "Failure closing " + mFile, e); + } + mFile.delete(); + } + } + + static class ReadFileOp extends Op { + File mFile; + RandomAccessFile mRAF; + byte[] mBuffer; + + ReadFileOp() { + super("ReadFile", "Seek and read a 64k file"); + } + + void onInit(Context context, boolean foreground) { + mBuffer = new byte[1024*64]; + for (int i=0; i<mBuffer.length; i++) { + mBuffer[i] = (byte)i; + } + mFile = context.getFileStreamPath(foreground ? "test-fg.file" : "test-bg.file"); + mFile.delete(); + try { + mRAF = new RandomAccessFile(mFile, "rw"); + mRAF.seek(0); + mRAF.setLength(0); + mRAF.write(mBuffer); + } catch (IOException e) { + Log.w(TAG, "Failure creating " + mFile, e); + } + } + + boolean onRun() { + try { + mRAF.seek(0); + mRAF.read(mBuffer); + } catch (IOException e) { + Log.w(TAG, "Failure reading " + mFile, e); + } + return true; + } + + void onTerm(Context context) { + try { + mRAF.close(); + } catch (IOException e) { + Log.w(TAG, "Failure closing " + mFile, e); + } + mFile.delete(); + } + } +} diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg.9.png Binary files differindex 8049191..8049191 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_focus.9.png Binary files differindex c81f675..c81f675 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_focus.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_press.9.png Binary files differindex d060b77..d060b77 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_press.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/green_gradient.9.png Binary files differindex a535678..a535678 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/green_gradient.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/patch.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/patch.9.png Binary files differindex e3b3639..e3b3639 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/patch.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/patch.9.png diff --git a/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png Binary files differnew file mode 100644 index 0000000..f65a355 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/widget_title_bg.9.png Binary files differindex 79615c2..79615c2 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/widget_title_bg.9.png diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java index 3232eed..414ae0d 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java @@ -22,9 +22,11 @@ import android.app.Activity; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.opengl.GLUtils; import android.os.Bundle; +import android.os.Environment; import android.util.Log; import android.view.Gravity; import android.view.TextureView; @@ -39,6 +41,7 @@ import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.opengles.GL; import java.io.BufferedOutputStream; +import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -65,7 +68,8 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa Bitmap b = mTextureView.getBitmap(800, 800); BufferedOutputStream out = null; try { - out = new BufferedOutputStream(new FileOutputStream("/sdcard/out.png")); + File dump = new File(Environment.getExternalStorageDirectory(), "out.png"); + out = new BufferedOutputStream(new FileOutputStream(dump)); b.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -168,10 +172,10 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3; private final float[] mTriangleVerticesData = { // X, Y, Z, U, V - -1.0f, -1.0f, 0, 0.f, 0.f, - 1.0f, -1.0f, 0, 1.f, 0.f, - -1.0f, 1.0f, 0, 0.f, 1.f, - 1.0f, 1.0f, 0, 1.f, 1.f, + -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, + -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, }; @Override @@ -212,8 +216,6 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa while (!mFinished) { checkCurrent(); - Log.d(LOG_TAG, "Rendering frame"); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); checkGlError(); @@ -237,7 +239,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa checkEglError(); try { - Thread.sleep(20); + Thread.sleep(2000); } catch (InterruptedException e) { // Ignore } diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java index fcb57d9..0f4c668 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java @@ -17,16 +17,23 @@ package com.android.test.hwui; import android.app.Activity; +import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.os.Bundle; +import android.os.Environment; import android.view.Gravity; +import android.view.Surface; import android.view.TextureView; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; @SuppressWarnings({"UnusedDeclaration"}) @@ -44,6 +51,26 @@ public class TextureViewActivity extends Activity implements TextureView.Surface mTextureView = new TextureView(this); mTextureView.setSurfaceTextureListener(this); + mTextureView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Bitmap b = mTextureView.getBitmap(800, 800); + BufferedOutputStream out = null; + try { + File dump = new File(Environment.getExternalStorageDirectory(), "out.png"); + out = new BufferedOutputStream(new FileOutputStream(dump)); + b.compress(Bitmap.CompressFormat.PNG, 100, out); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally { + if (out != null) try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + }); Button button = new Button(this); button.setText("Remove/Add"); @@ -73,6 +100,8 @@ public class TextureViewActivity extends Activity implements TextureView.Surface @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { mCamera = Camera.open(); + mCamera.setDisplayOrientation(getCameraOrientation()); + Camera.Size previewSize = mCamera.getParameters().getPreviewSize(); mTextureView.setLayoutParams(new FrameLayout.LayoutParams( previewSize.width, previewSize.height, Gravity.CENTER)); @@ -86,6 +115,34 @@ public class TextureViewActivity extends Activity implements TextureView.Surface mCamera.startPreview(); } + private int getCameraOrientation() { + Camera.CameraInfo info = new Camera.CameraInfo(); + for (int i = 0; i < Camera.getNumberOfCameras(); i++) { + Camera.getCameraInfo(i, info); + if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) break; + } + + int rotation = getWindowManager().getDefaultDisplay().getRotation(); + int degrees = 0; + + switch (rotation) { + case Surface.ROTATION_0: + degrees = 0; + break; + case Surface.ROTATION_90: + degrees = 90; + break; + case Surface.ROTATION_180: + degrees = 180; + break; + case Surface.ROTATION_270: + degrees = 270; + break; + } + + return (info.orientation - degrees + 360) % 360; + } + @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { // Ignored, the Camera does all the work for us diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java index cfad6da..656f2b1 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java @@ -44,7 +44,7 @@ public class ThinPatchesActivity extends Activity { } private class PatchView extends View { - private Drawable mPatch1, mPatch2; + private Drawable mPatch1, mPatch2, mPatch3; private Bitmap mTexture; public PatchView(Activity activity) { @@ -53,6 +53,7 @@ public class ThinPatchesActivity extends Activity { final Resources resources = activity.getResources(); mPatch1 = resources.getDrawable(R.drawable.patch); mPatch2 = resources.getDrawable(R.drawable.btn_toggle_on); + mPatch3 = resources.getDrawable(R.drawable.patch2); mTexture = Bitmap.createBitmap(4, 3, Bitmap.Config.ARGB_8888); mTexture.setPixel(0, 0, 0xffff0000); @@ -77,6 +78,14 @@ public class ThinPatchesActivity extends Activity { final int left = (getWidth() - width) / 2; final int top = (getHeight() - height) / 2; + canvas.save(); + canvas.translate(0.0f, -height * 2 - 20.0f); + + mPatch3.setBounds(left, top, left + height, top + width); + mPatch3.draw(canvas); + + canvas.restore(); + mPatch1.setBounds(left, top, left + width, top + height); mPatch1.draw(canvas); diff --git a/tests/RenderScriptTests/ComputePerf/Android.mk b/tests/RenderScriptTests/ComputePerf/Android.mk new file mode 100644 index 0000000..1d67d29 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/Android.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2011 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) \ + $(call all-renderscript-files-under, src) + +LOCAL_PACKAGE_NAME := RsComputePerf + +include $(BUILD_PACKAGE) diff --git a/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml b/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml new file mode 100644 index 0000000..a9193b5 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/AndroidManifest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.android.rs.computeperf"> + + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-sdk android:minSdkVersion="14" /> + <application android:label="Compute Perf"> + <activity android:name="ComputePerf"> + <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/RenderScriptTests/ComputePerf/res/layout/main.xml b/tests/RenderScriptTests/ComputePerf/res/layout/main.xml new file mode 100644 index 0000000..61cd24d --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/res/layout/main.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ImageView + android:id="@+id/displayin" + android:layout_width="320dip" + android:layout_height="266dip" /> + + <ImageView + android:id="@+id/displayout" + android:layout_width="320dip" + android:layout_height="266dip" /> + +</LinearLayout> diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java new file mode 100644 index 0000000..f7abe8b --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.rs.computeperf; + +import android.app.Activity; +import android.os.Bundle; +import android.graphics.BitmapFactory; +import android.graphics.Bitmap; +import android.renderscript.RenderScript; +import android.renderscript.Allocation; +import android.widget.ImageView; + +public class ComputePerf extends Activity { + + private LaunchTest mLT; + private Mandelbrot mMandel; + private RenderScript mRS; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + mRS = RenderScript.create(this); + mLT = new LaunchTest(mRS, getResources()); + mLT.run(); + mLT.run(); + + mMandel = new Mandelbrot(mRS, getResources()); + mMandel.run(); + + } + +} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java new file mode 100644 index 0000000..0c29ce1 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.rs.computeperf; + +import android.content.res.Resources; +import android.renderscript.*; + +public class LaunchTest implements Runnable { + private RenderScript mRS; + private Allocation mAllocationX; + private Allocation mAllocationXY; + private ScriptC_launchtestxlw mScript_xlw; + private ScriptC_launchtestxyw mScript_xyw; + + LaunchTest(RenderScript rs, Resources res) { + mRS = rs; + mScript_xlw = new ScriptC_launchtestxlw(mRS, res, R.raw.launchtestxlw); + mScript_xyw = new ScriptC_launchtestxyw(mRS, res, R.raw.launchtestxyw); + final int dim = mScript_xlw.get_dim(); + + mAllocationX = Allocation.createSized(rs, Element.U8(rs), dim); + Type.Builder tb = new Type.Builder(rs, Element.U8(rs)); + tb.setX(dim); + tb.setY(dim); + mAllocationXY = Allocation.createTyped(rs, tb.create()); + mScript_xlw.bind_buf(mAllocationXY); + } + + public void run() { + long t = java.lang.System.currentTimeMillis(); + mScript_xlw.forEach_root(mAllocationX); + mRS.finish(); + t = java.lang.System.currentTimeMillis() - t; + android.util.Log.v("ComputePerf", "xlw launch test ms " + t); + + t = java.lang.System.currentTimeMillis(); + mScript_xyw.forEach_root(mAllocationXY); + mRS.finish(); + t = java.lang.System.currentTimeMillis() - t; + android.util.Log.v("ComputePerf", "xyw launch test ms " + t); + } + +} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java new file mode 100644 index 0000000..ea1cd62 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.rs.computeperf; + +import android.content.res.Resources; +import android.renderscript.*; + +public class Mandelbrot implements Runnable { + private RenderScript mRS; + private Allocation mAllocationXY; + private ScriptC_mandelbrot mScript; + + Mandelbrot(RenderScript rs, Resources res) { + mRS = rs; + mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot); + + Type.Builder tb = new Type.Builder(rs, Element.U8_4(rs)); + tb.setX(mScript.get_gDimX()); + tb.setY(mScript.get_gDimY()); + mAllocationXY = Allocation.createTyped(rs, tb.create()); + } + + public void run() { + long t = java.lang.System.currentTimeMillis(); + mScript.forEach_root(mAllocationXY); + mRS.finish(); + t = java.lang.System.currentTimeMillis() - t; + android.util.Log.v("ComputePerf", "mandelbrot ms " + t); + } + +} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs new file mode 100644 index 0000000..7b81dfe --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma version(1) +#pragma rs java_package_name(com.example.android.rs.computeperf) + +const int dim = 2048; +uint8_t *buf; + +void root(uchar *v_out, uint32_t x) { + uint8_t *p = buf; + p += x * dim; + for (int i=0; i<dim; i++) { + p[i] = 1; + } +} + diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs new file mode 100644 index 0000000..7f7aa95 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma version(1) +#pragma rs java_package_name(com.example.android.rs.computeperf) + +void root(uchar *v_out, uint32_t x, uint32_t y) { + *v_out = 0; +} + diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs new file mode 100644 index 0000000..a7987b3 --- /dev/null +++ b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs @@ -0,0 +1,42 @@ +// Copyright (C) 2011 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma version(1) +#pragma rs java_package_name(com.example.android.rs.computeperf) + +const int gMaxIteration = 500; +const int gDimX = 1024; +const int gDimY = 1024; + +void root(uchar4 *v_out, uint32_t x, uint32_t y) { + float2 p; + p.x = -2.5f + ((float)x / gDimX) * 3.5f; + p.y = -1.f + ((float)y / gDimY) * 2.f; + + float2 t = 0; + int iteration = 0; + while((t.x*t.x + t.y*t.y < 4.f) && (iteration < gMaxIteration)) { + float2 t2 = t * t; + float xtemp = t2.x - t2.y + p.x; + t.y = 2 * t.x * t.y + p.y; + t.x = xtemp; + iteration++; + } + + if(iteration >= gMaxIteration) { + *v_out = 0; + } else { + *v_out = (uchar4){iteration & 0xff, (iteration >> 6) & 0xff, 0x8f, 0xff}; + } +} diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs index b77ccb4..42b1cf1 100644 --- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs +++ b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs @@ -105,8 +105,8 @@ void updateMeshInfo() { rsgMeshComputeBoundingBox(info->mMesh, &minX, &minY, &minZ, &maxX, &maxY, &maxZ); - info->bBoxMin = (minX, minY, minZ); - info->bBoxMax = (maxX, maxY, maxZ); + info->bBoxMin = (float3){minX, minY, minZ}; + info->bBoxMax = (float3){maxX, maxY, maxZ}; gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f; } gLookAt = gLookAt / (float)size; diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs index d44fd2b..05ef3ac 100644 --- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs +++ b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs @@ -104,8 +104,8 @@ void updateMeshInfo() { rsgMeshComputeBoundingBox(info->mMesh, &minX, &minY, &minZ, &maxX, &maxY, &maxZ); - info->bBoxMin = (minX, minY, minZ); - info->bBoxMax = (maxX, maxY, maxZ); + info->bBoxMin = (float3){minX, minY, minZ}; + info->bBoxMax = (float3){maxX, maxY, maxZ}; gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f; } gLookAt = gLookAt / (float)size; diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java index 6151431..a97ffa7 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UnitTest.java @@ -16,6 +16,7 @@ package com.android.rs.test; import android.content.Context; +import android.util.Log; import android.renderscript.RenderScript.RSMessageHandler; public class UnitTest extends Thread { @@ -55,6 +56,28 @@ public class UnitTest extends Thread { this (null, ctx); } + protected void _RS_ASSERT(String message, boolean b) { + if(b == false) { + result = -1; + Log.e(name, message + " FAILED"); + } + } + + protected void updateUI() { + if (mItem != null) { + mItem.result = result; + msgHandled = true; + try { + mRSTC.refreshTestResults(); + } + catch (IllegalStateException e) { + /* Ignore the case where our message receiver has been + disconnected. This happens when we leave the application + before it finishes running all of the unit tests. */ + } + } + } + protected RSMessageHandler mRsMessage = new RSMessageHandler() { public void run() { if (result == 0) { @@ -71,18 +94,7 @@ public class UnitTest extends Thread { } } - if (mItem != null) { - mItem.result = result; - msgHandled = true; - try { - mRSTC.refreshTestResults(); - } - catch (IllegalStateException e) { - /* Ignore the case where our message receiver has been - disconnected. This happens when we leave the application - before it finishes running all of the unit tests. */ - } - } + updateUI(); } }; diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java index b1cef15..10802b4 100644 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java +++ b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java @@ -110,9 +110,9 @@ public class ProfiledWebView extends WebView { * been redrawn. */ @Override - protected void pageSwapCallback() { + protected void pageSwapCallback(boolean startAnim) { mContentInvalMillis = System.currentTimeMillis() - mContentInvalMillis; - super.pageSwapCallback(); + super.pageSwapCallback(startAnim); Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis + "millis"); mIsTesting = true; |