diff options
Diffstat (limited to 'tests')
215 files changed, 7563 insertions, 7640 deletions
diff --git a/tests/AndroidTests/Android.mk b/tests/AndroidTests/Android.mk index ced796a..a81b779 100644 --- a/tests/AndroidTests/Android.mk +++ b/tests/AndroidTests/Android.mk @@ -3,9 +3,9 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests -LOCAL_JAVA_LIBRARIES := framework-tests android.test.runner +LOCAL_JAVA_LIBRARIES := framework-tests android.test.runner services -LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client +LOCAL_STATIC_JAVA_LIBRARIES := gsf-client # Resource unit tests use a private locale LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c 160dpi -c 32dpi -c 240dpi diff --git a/tests/AndroidTests/AndroidManifest.xml b/tests/AndroidTests/AndroidManifest.xml index d94327a..eb422be 100644 --- a/tests/AndroidTests/AndroidManifest.xml +++ b/tests/AndroidTests/AndroidManifest.xml @@ -35,27 +35,27 @@ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> - <uses-permission android:name="android.permission.READ_CONTACTS" /> - <uses-permission android:name="android.permission.WRITE_CONTACTS" /> - <uses-permission android:name="android.permission.WRITE_SETTINGS" /> - <uses-permission android:name="android.permission.READ_SMS"/> - <uses-permission android:name="android.permission.WRITE_SMS"/> - <uses-permission android:name="android.permission.DELETE_CACHE_FILES" /> <uses-permission android:name="android.permission.CLEAR_APP_CACHE" /> <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" /> + <uses-permission android:name="android.permission.DELETE_CACHE_FILES" /> <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> - <uses-permission android:name="android.permission.WRITE_GSERVICES" /> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <uses-permission android:name="android.permission.READ_LOGS"/> + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.READ_SMS"/> + <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> + <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> - + <uses-permission android:name="android.permission.WRITE_SETTINGS" /> + <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> + <uses-permission android:name="android.permission.WRITE_SMS"/> <uses-permission android:name="com.android.unit_tests.permission.TEST_GRANTED" /> - - <uses-permission android:name="android.permission.USE_CREDENTIALS" /> + <uses-permission android:name="com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD" /> <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" /> <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.ALL_SERVICES" /> - <uses-permission android:name="com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD" /> + <!-- InstrumentationTestRunner for AndroidTests --> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.android.unit_tests" diff --git a/tests/AndroidTests/res/layout/layout_five.xml b/tests/AndroidTests/res/layout/layout_five.xml index fd1e0ef..9923eaf 100644 --- a/tests/AndroidTests/res/layout/layout_five.xml +++ b/tests/AndroidTests/res/layout/layout_five.xml @@ -17,6 +17,6 @@ ** limitations under the License. */ --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <TextView android:id="@+id/text" android:text="@string/layout_five_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <TextView android:id="@+id/text" android:text="@string/layout_five_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> diff --git a/tests/AndroidTests/res/layout/layout_one.xml b/tests/AndroidTests/res/layout/layout_one.xml index f5c78bd..c326b2b 100644 --- a/tests/AndroidTests/res/layout/layout_one.xml +++ b/tests/AndroidTests/res/layout/layout_one.xml @@ -17,4 +17,4 @@ ** limitations under the License. */ --> -<view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/viewOne" android:layout_width="fill_parent" android:layout_height="fill_parent"/> +<view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/viewOne" android:layout_width="match_parent" android:layout_height="match_parent"/> diff --git a/tests/AndroidTests/res/layout/layout_six.xml b/tests/AndroidTests/res/layout/layout_six.xml index 6efcdf3..b78082d 100644 --- a/tests/AndroidTests/res/layout/layout_six.xml +++ b/tests/AndroidTests/res/layout/layout_six.xml @@ -17,11 +17,11 @@ ** limitations under the License. */ --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="fill_parent" android:layout_height="wrap_content" /> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView android:id="@+id/text" android:text="@string/layout_six_text_text" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> diff --git a/tests/AndroidTests/res/layout/layout_tag.xml b/tests/AndroidTests/res/layout/layout_tag.xml index 1f17701..72874a6 100644 --- a/tests/AndroidTests/res/layout/layout_tag.xml +++ b/tests/AndroidTests/res/layout/layout_tag.xml @@ -20,4 +20,4 @@ <view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/viewOne" android:tag="MyTag" - android:layout_width="fill_parent" android:layout_height="fill_parent"/> + android:layout_width="match_parent" android:layout_height="match_parent"/> diff --git a/tests/AndroidTests/res/layout/layout_three.xml b/tests/AndroidTests/res/layout/layout_three.xml index 77b2aa9..7b1ccc5 100644 --- a/tests/AndroidTests/res/layout/layout_three.xml +++ b/tests/AndroidTests/res/layout/layout_three.xml @@ -17,11 +17,11 @@ ** limitations under the License. */ --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="fill_parent"/> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view2" android:layout_width="fill_parent" android:layout_height="fill_parent"/> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view3" android:layout_width="fill_parent" android:layout_height="fill_parent"/> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view4" android:layout_width="fill_parent" android:layout_height="fill_parent"/> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view5" android:layout_width="fill_parent" android:layout_height="fill_parent"/> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view6" android:layout_width="fill_parent" android:layout_height="fill_parent"/> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="match_parent"/> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view2" android:layout_width="match_parent" android:layout_height="match_parent"/> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view3" android:layout_width="match_parent" android:layout_height="match_parent"/> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view4" android:layout_width="match_parent" android:layout_height="match_parent"/> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view5" android:layout_width="match_parent" android:layout_height="match_parent"/> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/view6" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> diff --git a/tests/AndroidTests/res/layout/layout_two.xml b/tests/AndroidTests/res/layout/layout_two.xml index 9c99710..af14228 100644 --- a/tests/AndroidTests/res/layout/layout_two.xml +++ b/tests/AndroidTests/res/layout/layout_two.xml @@ -17,7 +17,7 @@ ** limitations under the License. */ --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/viewOne" android:layout_width="fill_parent" android:layout_height="fill_parent"/> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <view class="com.android.unit_tests.InflateTest$ViewOne" android:id="@+id/viewOne" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> diff --git a/tests/AndroidTests/res/raw/calendarjs.txt b/tests/AndroidTests/res/raw/calendarjs.txt deleted file mode 100644 index 15f7bab..0000000 --- a/tests/AndroidTests/res/raw/calendarjs.txt +++ /dev/null @@ -1 +0,0 @@ -{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$gCal":"http://schemas.google.com/gCal/2005","id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic"},"updated":{"$t":"2007-02-06T02:55:15.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"w g"},"subtitle":{"type":"text","$t":"w g"},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic?alt\u003Djson\u0026max-results\u003D25"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"generator":{"version":"1.0","uri":"http://www.google.com/calendar","$t":"Google Calendar"},"openSearch$totalResults":{"$t":"13"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"25"},"gCal$timezone":{"value":"America/Los_Angeles"},"entry":[{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/7iqc1ro0ihc69vhsiq3uabooig"},"published":{"$t":"2007-02-05T22:04:50.000Z"},"updated":{"$t":"2007-02-05T22:04:50.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"skate"},"summary":{"type":"html","$t":"When: Wed Feb 7, 2007 13:30 to Wed Feb 7, 2007 16:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Wed Feb 7, 2007 13:30 to Wed Feb 7, 2007 16:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DN2lxYzFybzBpaGM2OXZoc2lxM3VhYm9vaWcgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/7iqc1ro0ihc69vhsiq3uabooig"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/kp4gil76n2vcrkt9kaotj3s12c"},"published":{"$t":"2007-02-05T22:04:42.000Z"},"updated":{"$t":"2007-02-05T22:04:42.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"skate"},"summary":{"type":"html","$t":"When: Fri Feb 9, 2007 15:30 to Fri Feb 9, 2007 18:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Fri Feb 9, 2007 15:30 to Fri Feb 9, 2007 18:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003Da3A0Z2lsNzZuMnZjcmt0OWthb3RqM3MxMmMgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/kp4gil76n2vcrkt9kaotj3s12c"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/gkhb48fj68lcp15fd1k03tjbj0"},"published":{"$t":"2007-02-05T22:04:35.000Z"},"updated":{"$t":"2007-02-05T22:04:35.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 6"},"summary":{"type":"html","$t":"When: Sat Feb 10, 2007 14:00 to Sat Feb 10, 2007 17:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Sat Feb 10, 2007 14:00 to Sat Feb 10, 2007 17:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DZ2toYjQ4Zmo2OGxjcDE1ZmQxazAzdGpiajAgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/gkhb48fj68lcp15fd1k03tjbj0"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/32p5g68cpean3p2ol7kanj38sg"},"published":{"$t":"2007-02-05T22:04:29.000Z"},"updated":{"$t":"2007-02-05T22:04:29.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 5"},"summary":{"type":"html","$t":"When: Fri Feb 9, 2007 09:00 to 10:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Fri Feb 9, 2007 09:00 to 10:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DMzJwNWc2OGNwZWFuM3Ayb2w3a2FuajM4c2cgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/32p5g68cpean3p2ol7kanj38sg"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/tfqpth26conshdmav0apje1tf4"},"published":{"$t":"2007-02-05T22:04:19.000Z"},"updated":{"$t":"2007-02-05T22:04:19.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"skate"},"summary":{"type":"html","$t":"When: Thu Feb 8, 2007 15:00 to Thu Feb 8, 2007 17:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Thu Feb 8, 2007 15:00 to Thu Feb 8, 2007 17:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DdGZxcHRoMjZjb25zaGRtYXYwYXBqZTF0ZjQgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/tfqpth26conshdmav0apje1tf4"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/onbo9mhbr5m6mo356nog7uel4s"},"published":{"$t":"2007-02-05T22:04:07.000Z"},"updated":{"$t":"2007-02-05T22:04:07.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"Sharks at Anaheim"},"summary":{"type":"html","$t":"When: Wed Feb 7, 2007 19:00 to 22:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Wed Feb 7, 2007 19:00 to 22:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003Db25ibzltaGJyNW02bW8zNTZub2c3dWVsNHMgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/onbo9mhbr5m6mo356nog7uel4s"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"true"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/tjqrd9fve576hieh3sa67nql5k"},"published":{"$t":"2007-02-05T22:04:02.000Z"},"updated":{"$t":"2007-02-05T22:04:02.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"Sharks vs. ANAHEIM"},"summary":{"type":"html","$t":"When: Tue Feb 6, 2007 19:30 to 22:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Tue Feb 6, 2007 19:30 to 22:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DdGpxcmQ5ZnZlNTc2aGllaDNzYTY3bnFsNWsgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/tjqrd9fve576hieh3sa67nql5k"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"true"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/or6dtpn065f9mntond4jh2docc"},"published":{"$t":"2007-02-05T22:03:52.000Z"},"updated":{"$t":"2007-02-05T22:03:52.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"skate"},"summary":{"type":"html","$t":"When: Tue Feb 6, 2007 14:00 to 15:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Tue Feb 6, 2007 14:00 to 15:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003Db3I2ZHRwbjA2NWY5bW50b25kNGpoMmRvY2Mgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/or6dtpn065f9mntond4jh2docc"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/k70v8o4jt1afi17hg2spavq1c0"},"published":{"$t":"2007-02-05T22:03:36.000Z"},"updated":{"$t":"2007-02-05T22:03:36.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"lunch"},"summary":{"type":"html","$t":"Recurring Event\u003Cbr\u003E First start: 2007-02-06 12:00:00 PST \u003Cbr\u003E Duration: 3600 \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"Recurring Event\u003Cbr\u003E First start: 2007-02-06 12:00:00 PST \u003Cbr\u003E Duration: 3600 \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DazcwdjhvNGp0MWFmaTE3aGcyc3BhdnExYzBfMjAwNzAyMDZUMjAwMDAwWiB3Z0B2b2ljZW1lLm5ldA","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/k70v8o4jt1afi17hg2spavq1c0"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"true"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/6ee7b8nohdt03tv0gknm4v7124"},"published":{"$t":"2007-02-05T22:03:19.000Z"},"updated":{"$t":"2007-02-05T22:03:19.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 4"},"summary":{"type":"html","$t":"When: Tue Feb 6, 2007 09:00 to 11:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Tue Feb 6, 2007 09:00 to 11:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DNmVlN2I4bm9oZHQwM3R2MGdrbm00djcxMjQgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/6ee7b8nohdt03tv0gknm4v7124"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/of1vh1r2q5aqdplo65i8bqbn3o"},"published":{"$t":"2007-02-05T22:03:11.000Z"},"updated":{"$t":"2007-02-05T22:03:11.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 3"},"summary":{"type":"html","$t":"When: Mon Feb 5, 2007 18:00 to 19:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Mon Feb 5, 2007 18:00 to 19:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003Db2YxdmgxcjJxNWFxZHBsbzY1aThicWJuM28gd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/of1vh1r2q5aqdplo65i8bqbn3o"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/s7ahgfomlgii9qbkgpfbinr9u8"},"published":{"$t":"2007-02-05T22:02:40.000Z"},"updated":{"$t":"2007-02-05T22:03:04.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 2"},"summary":{"type":"html","$t":"When: Mon Feb 5, 2007 16:30 to 17:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Mon Feb 5, 2007 16:30 to 17:30\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003DczdhaGdmb21sZ2lpOXFia2dwZmJpbnI5dTggd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/s7ahgfomlgii9qbkgpfbinr9u8"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}},{"id":{"$t":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/rl8focglfe6jndql4u8lg73q5k"},"published":{"$t":"2007-02-05T22:02:28.000Z"},"updated":{"$t":"2007-02-05T22:02:53.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"title":{"type":"text","$t":"test event 1"},"summary":{"type":"html","$t":"When: Mon Feb 5, 2007 15:00 to Mon Feb 5, 2007 16:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"content":{"type":"text","$t":"When: Mon Feb 5, 2007 15:00 to Mon Feb 5, 2007 16:00\u0026nbsp; PST\u003Cbr\u003E \u003Cbr\u003EEvent Status: confirmed"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid\u003Dcmw4Zm9jZ2xmZTZqbmRxbDR1OGxnNzNxNWsgd2dAdm9pY2VtZS5uZXQ","title":"alternate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/wg%40voiceme.net/public/basic/rl8focglfe6jndql4u8lg73q5k"}],"author":[{"name":{"$t":"w g"},"email":{"$t":"wg@voiceme.net"}}],"gCal$sendEventNotifications":{"value":"false"}}]}}
\ No newline at end of file diff --git a/tests/AndroidTests/res/raw/calendarjsgz.jsgz b/tests/AndroidTests/res/raw/calendarjsgz.jsgz Binary files differdeleted file mode 100644 index 6f1bf54..0000000 --- a/tests/AndroidTests/res/raw/calendarjsgz.jsgz +++ /dev/null diff --git a/tests/AndroidTests/res/raw/calendarxml.xml b/tests/AndroidTests/res/raw/calendarxml.xml deleted file mode 100644 index 1adcd74..0000000 --- a/tests/AndroidTests/res/raw/calendarxml.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gCal='http://schemas.google.com/gCal/2005'><id>http://www.google.com/calendar/feeds/default/private/full</id><updated>2007-02-05T22:04:50.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>w g</title><subtitle type='text'>w g</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full'></link><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full?max-results=25'></link><author><name>w g</name><email>wg@voiceme.net</email></author><generator version='1.0' uri='http://www.google.com/calendar'>Google Calendar</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><gCal:timezone value='America/Los_Angeles'></gCal:timezone><entry><id>http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig</id><published>2007-02-05T22:04:50.000Z</published><updated>2007-02-05T22:04:50.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=N2lxYzFybzBpaGM2OXZoc2lxM3VhYm9vaWcgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig/63306396290'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-07T13:30:00.000-08:00' endTime='2007-02-07T16:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c</id><published>2007-02-05T22:04:42.000Z</published><updated>2007-02-05T22:04:42.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=a3A0Z2lsNzZuMnZjcmt0OWthb3RqM3MxMmMgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c/63306396282'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-09T15:30:00.000-08:00' endTime='2007-02-09T18:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0</id><published>2007-02-05T22:04:35.000Z</published><updated>2007-02-05T22:04:35.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 6</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=Z2toYjQ4Zmo2OGxjcDE1ZmQxazAzdGpiajAgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0/63306396275'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-10T14:00:00.000-08:00' endTime='2007-02-10T17:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg</id><published>2007-02-05T22:04:29.000Z</published><updated>2007-02-05T22:04:29.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 5</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=MzJwNWc2OGNwZWFuM3Ayb2w3a2FuajM4c2cgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg/63306396269'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-09T09:00:00.000-08:00' endTime='2007-02-09T10:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4</id><published>2007-02-05T22:04:19.000Z</published><updated>2007-02-05T22:04:19.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=dGZxcHRoMjZjb25zaGRtYXYwYXBqZTF0ZjQgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4/63306396259'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-08T15:00:00.000-08:00' endTime='2007-02-08T17:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s</id><published>2007-02-05T22:04:07.000Z</published><updated>2007-02-05T22:04:07.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>Sharks at Anaheim</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b25ibzltaGJyNW02bW8zNTZub2c3dWVsNHMgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s/63306396247'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-07T19:00:00.000-08:00' endTime='2007-02-07T22:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k</id><published>2007-02-05T22:04:02.000Z</published><updated>2007-02-05T22:04:02.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>Sharks vs. ANAHEIM</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=dGpxcmQ5ZnZlNTc2aGllaDNzYTY3bnFsNWsgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k/63306396242'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-06T19:30:00.000-08:00' endTime='2007-02-06T22:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc</id><published>2007-02-05T22:03:52.000Z</published><updated>2007-02-05T22:03:52.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b3I2ZHRwbjA2NWY5bW50b25kNGpoMmRvY2Mgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc/63306396232'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-06T14:00:00.000-08:00' endTime='2007-02-06T15:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0</id><published>2007-02-05T22:03:36.000Z</published><updated>2007-02-05T22:03:36.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>lunch</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=azcwdjhvNGp0MWFmaTE3aGcyc3BhdnExYzBfMjAwNzAyMDZUMjAwMDAwWiB3Z0B2b2ljZW1lLm5ldA' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0/63306396216'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:recurrence>DTSTART;TZID=America/Los_Angeles:20070206T120000 -DURATION:PT3600S -RRULE:FREQ=DAILY;WKST=SU -BEGIN:VTIMEZONE -TZID:America/Los_Angeles -X-LIC-LOCATION:America/Los_Angeles -BEGIN:STANDARD -TZOFFSETFROM:-0700 -TZOFFSETTO:-0800 -TZNAME:PST -DTSTART:19701025T020000 -RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU -END:STANDARD -BEGIN:DAYLIGHT -TZOFFSETFROM:-0800 -TZOFFSETTO:-0700 -TZNAME:PDT -DTSTART:19700405T020000 -RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU -END:DAYLIGHT -END:VTIMEZONE -</gd:recurrence><gd:where valueString=''></gd:where><gd:reminder minutes='10'></gd:reminder></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124</id><published>2007-02-05T22:03:19.000Z</published><updated>2007-02-05T22:03:19.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 4</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=NmVlN2I4bm9oZHQwM3R2MGdrbm00djcxMjQgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124/63306396199'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-06T09:00:00.000-08:00' endTime='2007-02-06T11:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o</id><published>2007-02-05T22:03:11.000Z</published><updated>2007-02-05T22:03:11.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 3</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b2YxdmgxcjJxNWFxZHBsbzY1aThicWJuM28gd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o/63306396191'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-05T18:00:00.000-08:00' endTime='2007-02-05T19:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8</id><published>2007-02-05T22:02:40.000Z</published><updated>2007-02-05T22:03:04.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 2</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=czdhaGdmb21sZ2lpOXFia2dwZmJpbnI5dTggd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8/63306396184'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-05T16:30:00.000-08:00' endTime='2007-02-05T17:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k</id><published>2007-02-05T22:02:28.000Z</published><updated>2007-02-05T22:02:53.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 1</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=cmw4Zm9jZ2xmZTZqbmRxbDR1OGxnNzNxNWsgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k/63306396173'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-05T15:00:00.000-08:00' endTime='2007-02-05T16:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry></feed> diff --git a/tests/AndroidTests/res/raw/calendarxmlgz.xmlgz b/tests/AndroidTests/res/raw/calendarxmlgz.xmlgz Binary files differdeleted file mode 100644 index 6c86462..0000000 --- a/tests/AndroidTests/res/raw/calendarxmlgz.xmlgz +++ /dev/null diff --git a/tests/AndroidTests/res/raw/medium.xml b/tests/AndroidTests/res/raw/medium.xml index 51c952c..5757a24 100644 --- a/tests/AndroidTests/res/raw/medium.xml +++ b/tests/AndroidTests/res/raw/medium.xml @@ -17,11 +17,11 @@ ** limitations under the License. */ --> -<LinearLayout id="@+id/content" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <TextView id="@+id/text" android:text="S" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView id="@+id/text" android:text="M" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView id="@+id/text" android:text="T" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView id="@+id/text" android:text="W" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView id="@+id/text" android:text="H" android:layout_width="fill_parent" android:layout_height="wrap_content" /> - <TextView id="@+id/text" android:text="F" android:layout_width="fill_parent" android:layout_height="wrap_content" /> +<LinearLayout id="@+id/content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <TextView id="@+id/text" android:text="S" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView id="@+id/text" android:text="M" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView id="@+id/text" android:text="T" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView id="@+id/text" android:text="W" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView id="@+id/text" android:text="H" android:layout_width="match_parent" android:layout_height="wrap_content" /> + <TextView id="@+id/text" android:text="F" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> diff --git a/tests/AndroidTests/res/raw/small.xml b/tests/AndroidTests/res/raw/small.xml index 2697fb8..ee859b9 100644 --- a/tests/AndroidTests/res/raw/small.xml +++ b/tests/AndroidTests/res/raw/small.xml @@ -17,4 +17,4 @@ ** limitations under the License. */ --> -<view class="com.android.tests.InflateTest$ViewOne" id="@+id/viewOne" android:layout_width="fill_parent" android:layout_height="fill_parent"/> +<view class="com.android.tests.InflateTest$ViewOne" id="@+id/viewOne" android:layout_width="match_parent" android:layout_height="match_parent"/> diff --git a/tests/AndroidTests/res/raw/v21_invalid_comment_line.vcf b/tests/AndroidTests/res/raw/v21_invalid_comment_line.vcf new file mode 100644 index 0000000..f910710 --- /dev/null +++ b/tests/AndroidTests/res/raw/v21_invalid_comment_line.vcf @@ -0,0 +1,10 @@ +BEGIN:vCard
+VERSION:2.1
+UID:357
+N:;Conference Call
+FN:Conference Call
+# This line must be ignored.
+NOTE;ENCODING=QUOTED-PRINTABLE:This is an (sharp ->=
+#<- sharp) example. This message must NOT be ignored.
+# This line must be ignored too.
+END:vCard
diff --git a/tests/AndroidTests/res/raw/v21_org_before_title.vcf b/tests/AndroidTests/res/raw/v21_org_before_title.vcf new file mode 100644 index 0000000..8ff1190 --- /dev/null +++ b/tests/AndroidTests/res/raw/v21_org_before_title.vcf @@ -0,0 +1,6 @@ +BEGIN:VCARD
+VERSION:2.1
+FN:Normal Guy
+ORG:Company;Organization;Devision;Room;Sheet No.
+TITLE:Excellent Janitor
+END:VCARD
diff --git a/tests/AndroidTests/res/raw/v21_pref_handling.vcf b/tests/AndroidTests/res/raw/v21_pref_handling.vcf new file mode 100644 index 0000000..5105310 --- /dev/null +++ b/tests/AndroidTests/res/raw/v21_pref_handling.vcf @@ -0,0 +1,15 @@ +BEGIN:VCARD +VERSION:2.1 +FN:Smith +TEL;HOME:1 +TEL;WORK;PREF:2 +TEL;ISDN:3 +EMAIL;PREF;HOME:test@example.com +EMAIL;CELL;PREF:test2@examination.com +ORG:Company +TITLE:Engineer +ORG:Mystery +TITLE:Blogger +ORG:Poetry +TITLE:Poet +END:VCARD diff --git a/tests/AndroidTests/res/raw/v21_title_before_org.vcf b/tests/AndroidTests/res/raw/v21_title_before_org.vcf new file mode 100644 index 0000000..9fdc738 --- /dev/null +++ b/tests/AndroidTests/res/raw/v21_title_before_org.vcf @@ -0,0 +1,6 @@ +BEGIN:VCARD
+VERSION:2.1
+FN:Nice Guy
+TITLE:Cool Title
+ORG:Marverous;Perfect;Great;Good;Bad;Poor
+END:VCARD
diff --git a/tests/AndroidTests/res/raw/v21_winmo_65.vcf b/tests/AndroidTests/res/raw/v21_winmo_65.vcf new file mode 100644 index 0000000..f380d0d --- /dev/null +++ b/tests/AndroidTests/res/raw/v21_winmo_65.vcf @@ -0,0 +1,10 @@ +BEGIN:VCARD
+VERSION:2.1
+N:Example;;;;
+FN:Example
+ANNIVERSARY;VALUE=DATE:20091010
+AGENT:Invalid line which must be handled correctly.
+X-CLASS:PUBLIC
+X-REDUCTION:
+X-NO:
+END:VCARD
diff --git a/tests/AndroidTests/res/raw/v30_comma_separated.vcf b/tests/AndroidTests/res/raw/v30_comma_separated.vcf new file mode 100644 index 0000000..98a7f20 --- /dev/null +++ b/tests/AndroidTests/res/raw/v30_comma_separated.vcf @@ -0,0 +1,5 @@ +BEGIN:VCARD
+VERSION:3.0
+N:F;G;M;;
+TEL;TYPE=PAGER,WORK,MSG:6101231234@pagersample.com
+END:VCARD
diff --git a/tests/AndroidTests/res/xml/calendar.xml b/tests/AndroidTests/res/xml/calendar.xml deleted file mode 100644 index 1adcd74..0000000 --- a/tests/AndroidTests/res/xml/calendar.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gCal='http://schemas.google.com/gCal/2005'><id>http://www.google.com/calendar/feeds/default/private/full</id><updated>2007-02-05T22:04:50.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>w g</title><subtitle type='text'>w g</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full'></link><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full?max-results=25'></link><author><name>w g</name><email>wg@voiceme.net</email></author><generator version='1.0' uri='http://www.google.com/calendar'>Google Calendar</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><gCal:timezone value='America/Los_Angeles'></gCal:timezone><entry><id>http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig</id><published>2007-02-05T22:04:50.000Z</published><updated>2007-02-05T22:04:50.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=N2lxYzFybzBpaGM2OXZoc2lxM3VhYm9vaWcgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig/63306396290'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/7iqc1ro0ihc69vhsiq3uabooig/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-07T13:30:00.000-08:00' endTime='2007-02-07T16:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c</id><published>2007-02-05T22:04:42.000Z</published><updated>2007-02-05T22:04:42.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=a3A0Z2lsNzZuMnZjcmt0OWthb3RqM3MxMmMgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c/63306396282'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/kp4gil76n2vcrkt9kaotj3s12c/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-09T15:30:00.000-08:00' endTime='2007-02-09T18:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0</id><published>2007-02-05T22:04:35.000Z</published><updated>2007-02-05T22:04:35.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 6</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=Z2toYjQ4Zmo2OGxjcDE1ZmQxazAzdGpiajAgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0/63306396275'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/gkhb48fj68lcp15fd1k03tjbj0/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-10T14:00:00.000-08:00' endTime='2007-02-10T17:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg</id><published>2007-02-05T22:04:29.000Z</published><updated>2007-02-05T22:04:29.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 5</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=MzJwNWc2OGNwZWFuM3Ayb2w3a2FuajM4c2cgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg/63306396269'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/32p5g68cpean3p2ol7kanj38sg/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-09T09:00:00.000-08:00' endTime='2007-02-09T10:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4</id><published>2007-02-05T22:04:19.000Z</published><updated>2007-02-05T22:04:19.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=dGZxcHRoMjZjb25zaGRtYXYwYXBqZTF0ZjQgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4/63306396259'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/tfqpth26conshdmav0apje1tf4/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-08T15:00:00.000-08:00' endTime='2007-02-08T17:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s</id><published>2007-02-05T22:04:07.000Z</published><updated>2007-02-05T22:04:07.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>Sharks at Anaheim</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b25ibzltaGJyNW02bW8zNTZub2c3dWVsNHMgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s/63306396247'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/onbo9mhbr5m6mo356nog7uel4s/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-07T19:00:00.000-08:00' endTime='2007-02-07T22:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k</id><published>2007-02-05T22:04:02.000Z</published><updated>2007-02-05T22:04:02.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>Sharks vs. ANAHEIM</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=dGpxcmQ5ZnZlNTc2aGllaDNzYTY3bnFsNWsgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k/63306396242'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/tjqrd9fve576hieh3sa67nql5k/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-06T19:30:00.000-08:00' endTime='2007-02-06T22:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc</id><published>2007-02-05T22:03:52.000Z</published><updated>2007-02-05T22:03:52.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>skate</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b3I2ZHRwbjA2NWY5bW50b25kNGpoMmRvY2Mgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc/63306396232'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/or6dtpn065f9mntond4jh2docc/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-06T14:00:00.000-08:00' endTime='2007-02-06T15:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0</id><published>2007-02-05T22:03:36.000Z</published><updated>2007-02-05T22:03:36.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>lunch</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=azcwdjhvNGp0MWFmaTE3aGcyc3BhdnExYzBfMjAwNzAyMDZUMjAwMDAwWiB3Z0B2b2ljZW1lLm5ldA' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/k70v8o4jt1afi17hg2spavq1c0/63306396216'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='true'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:recurrence>DTSTART;TZID=America/Los_Angeles:20070206T120000 -DURATION:PT3600S -RRULE:FREQ=DAILY;WKST=SU -BEGIN:VTIMEZONE -TZID:America/Los_Angeles -X-LIC-LOCATION:America/Los_Angeles -BEGIN:STANDARD -TZOFFSETFROM:-0700 -TZOFFSETTO:-0800 -TZNAME:PST -DTSTART:19701025T020000 -RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU -END:STANDARD -BEGIN:DAYLIGHT -TZOFFSETFROM:-0800 -TZOFFSETTO:-0700 -TZNAME:PDT -DTSTART:19700405T020000 -RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU -END:DAYLIGHT -END:VTIMEZONE -</gd:recurrence><gd:where valueString=''></gd:where><gd:reminder minutes='10'></gd:reminder></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124</id><published>2007-02-05T22:03:19.000Z</published><updated>2007-02-05T22:03:19.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 4</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=NmVlN2I4bm9oZHQwM3R2MGdrbm00djcxMjQgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124/63306396199'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/6ee7b8nohdt03tv0gknm4v7124/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-06T09:00:00.000-08:00' endTime='2007-02-06T11:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o</id><published>2007-02-05T22:03:11.000Z</published><updated>2007-02-05T22:03:11.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 3</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=b2YxdmgxcjJxNWFxZHBsbzY1aThicWJuM28gd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o/63306396191'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/of1vh1r2q5aqdplo65i8bqbn3o/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-05T18:00:00.000-08:00' endTime='2007-02-05T19:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8</id><published>2007-02-05T22:02:40.000Z</published><updated>2007-02-05T22:03:04.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 2</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=czdhaGdmb21sZ2lpOXFia2dwZmJpbnI5dTggd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8/63306396184'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/s7ahgfomlgii9qbkgpfbinr9u8/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where valueString=''></gd:where><gd:when startTime='2007-02-05T16:30:00.000-08:00' endTime='2007-02-05T17:30:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry><entry><id>http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k</id><published>2007-02-05T22:02:28.000Z</published><updated>2007-02-05T22:02:53.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category><title type='text'>test event 1</title><content type='text'></content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/hosted/voiceme.net/event?eid=cmw4Zm9jZ2xmZTZqbmRxbDR1OGxnNzNxNWsgd2dAdm9pY2VtZS5uZXQ' title='alternate'></link><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k'></link><link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k/63306396173'></link><author><name>w g</name><email>wg@voiceme.net</email></author><gd:comments><gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/rl8focglfe6jndql4u8lg73q5k/comments'></gd:feedLink></gd:comments><gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'></gd:eventStatus><gd:visibility value='http://schemas.google.com/g/2005#event.default'></gd:visibility><gCal:sendEventNotifications value='false'></gCal:sendEventNotifications><gd:transparency value='http://schemas.google.com/g/2005#event.opaque'></gd:transparency><gd:where></gd:where><gd:when startTime='2007-02-05T15:00:00.000-08:00' endTime='2007-02-05T16:00:00.000-08:00'><gd:reminder minutes='10'></gd:reminder></gd:when></entry></feed> diff --git a/tests/AndroidTests/src/com/android/unit_tests/ApacheHttpTests.java b/tests/AndroidTests/src/com/android/unit_tests/ApacheHttpTests.java deleted file mode 100644 index cf759e0..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/ApacheHttpTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.android.unit_tests; - -import junit.framework.TestSuite; - -public class ApacheHttpTests { - public static TestSuite suite() { - TestSuite suite = new TestSuite(ApacheHttpTests.class.getName()); - - suite.addTestSuite(TestHttpService.class); - - return suite; - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java b/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java index dbfd0e7..88fa3cc 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java @@ -17,15 +17,14 @@ package com.android.unit_tests; import android.os.Build; -import android.server.data.BuildData; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; import junit.framework.Assert; import junit.framework.TestCase; /** - * Provides test cases for android.os.Build and android.server.data.BuildData, - * and, in turn, many of the system properties set by the build system. + * Provides test cases for android.os.Build and, in turn, many of the + * system properties set by the build system. */ public class BuildTest extends TestCase { @@ -74,58 +73,4 @@ public class BuildTest extends TestCase { // (e.g., must be a C identifier, must be a valid filename, must not contain any spaces) // add tests for them. } - - /** - * Asserts that android.server.data.BuildData behaves as expected. - */ - @SmallTest - public void testBuildData() throws Exception { - BuildData bd; - - /* - * Default constructor - */ - bd = new BuildData(); - assertNotEmpty(bd.getFingerprint()); - assertNotEmpty(bd.getIncrementalVersion()); - Assert.assertTrue(bd.getTime() > 0); - - /* - * Explicit constructor - */ - final String FINGERPRINT = "fingerprint"; - final String INCREMENTAL_VERSION = "74321"; // a valid long, for the serialization test - final long TIME = 12345; - bd = new BuildData(FINGERPRINT, INCREMENTAL_VERSION, TIME); - Assert.assertEquals(FINGERPRINT, bd.getFingerprint()); - Assert.assertEquals(INCREMENTAL_VERSION, bd.getIncrementalVersion()); - Assert.assertTrue(bd.getTime() == TIME); - -// The serialization methods are package-private. -// -// import java.io.ByteArrayInputStream; -// import java.io.ByteArrayOutputStream; -// import java.io.DataInputStream; -// import java.io.DataOutputStream; -// -// /* -// * Serialization -// */ -// ByteArrayOutputStream out = new ByteArrayOutputStream(); -// bd.write(new DataOutputStream(out)); -// Assert.assertTrue(out.size() > 0); -// -// /* -// * Deserialization -// * -// * The current version of BuildData converts the incremental version to -// * and from a long when serializing/deserializing. Future versions should -// * treat it as a string. -// */ -// BuildData bd2 = -// new BuildData(new DataInputStream(new ByteArrayInputStream(out.toByteArray()))); -// Assert.assertEquals(bd.getFingerprint(), bd2.getFingerprint()); -// Assert.assertEquals(bd.getIncrementalVersion(), bd2.getIncrementalVersion()); -// Assert.assertTrue(bd.getTime() == bd2.getTime()); - } } diff --git a/tests/AndroidTests/src/com/android/unit_tests/CreateViewTest.java b/tests/AndroidTests/src/com/android/unit_tests/CreateViewTest.java index 342094d..0c57ac4 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/CreateViewTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/CreateViewTest.java @@ -21,7 +21,7 @@ import android.test.AndroidTestCase; import android.test.PerformanceTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.view.View; -import static android.view.ViewGroup.LayoutParams.FILL_PARENT; +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.widget.LinearLayout; import android.widget.TextView; @@ -45,7 +45,7 @@ public class CreateViewTest extends AndroidTestCase implements PerformanceTestCa public void testLayout2() throws Exception { LinearLayout vert = new LinearLayout(mContext); vert.addView(new CreateViewTest.ViewOne(mContext), - new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); } @SmallTest @@ -53,22 +53,22 @@ public class CreateViewTest extends AndroidTestCase implements PerformanceTestCa LinearLayout vert = new LinearLayout(mContext); ViewOne one = new ViewOne(mContext); - vert.addView(one, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(one, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); ViewOne two = new ViewOne(mContext); - vert.addView(two, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(two, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); ViewOne three = new ViewOne(mContext); - vert.addView(three, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(three, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); ViewOne four = new ViewOne(mContext); - vert.addView(four, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(four, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); ViewOne five = new ViewOne(mContext); - vert.addView(five, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(five, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); ViewOne six = new ViewOne(mContext); - vert.addView(six, new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 0)); + vert.addView(six, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); } @SmallTest @@ -83,7 +83,7 @@ public class CreateViewTest extends AndroidTestCase implements PerformanceTestCa text.setText("S"); LinearLayout vert = new LinearLayout(mContext); - vert.addView(text, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(text, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); } @SmallTest @@ -92,27 +92,27 @@ public class CreateViewTest extends AndroidTestCase implements PerformanceTestCa TextView one = new TextView(mContext); one.setText("S"); - vert.addView(one, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(one, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); TextView two = new TextView(mContext); two.setText("M"); - vert.addView(two, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(two, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); TextView three = new TextView(mContext); three.setText("T"); - vert.addView(three, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(three, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); TextView four = new TextView(mContext); four.setText("W"); - vert.addView(four, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(four, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); TextView five = new TextView(mContext); five.setText("H"); - vert.addView(five, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(five, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); TextView six = new TextView(mContext); six.setText("F"); - vert.addView(six, new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0)); + vert.addView(six, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); } public static class ViewOne extends View { diff --git a/tests/AndroidTests/src/com/android/unit_tests/CursorWindowTest.java b/tests/AndroidTests/src/com/android/unit_tests/CursorWindowTest.java index d9068c8..0247355 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/CursorWindowTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/CursorWindowTest.java @@ -18,7 +18,7 @@ package com.android.unit_tests; import android.database.AbstractCursor; import android.test.suitebuilder.annotation.SmallTest; -import com.android.internal.database.ArrayListCursor; +import com.android.common.ArrayListCursor; import android.database.CursorWindow; import android.test.PerformanceTestCase; diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseCursorTest.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseCursorTest.java deleted file mode 100644 index 5df499d..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseCursorTest.java +++ /dev/null @@ -1,626 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.content.ContentValues; -import android.database.Cursor; -import android.database.CursorIndexOutOfBoundsException; -import android.database.DataSetObserver; -import android.database.DatabaseUtils; -import android.database.sqlite.SQLiteCursor; -import android.database.sqlite.SQLiteCursorDriver; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteQuery; -import android.database.sqlite.SQLiteStatement; -import android.os.Looper; -import android.test.PerformanceTestCase; -import android.test.suitebuilder.annotation.LargeTest; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; -import android.test.suitebuilder.annotation.Suppress; -import android.util.Log; - -import java.io.File; -import java.util.Arrays; -import java.util.Random; - -import junit.framework.TestCase; - -public class DatabaseCursorTest extends TestCase implements PerformanceTestCase { - - private static final String sString1 = "this is a test"; - private static final String sString2 = "and yet another test"; - private static final String sString3 = "this string is a little longer, but still a test"; - - private static final int CURRENT_DATABASE_VERSION = 42; - private SQLiteDatabase mDatabase; - private File mDatabaseFile; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mDatabaseFile = new File("/sqlite_stmt_journals", "database_test.db"); - if (mDatabaseFile.exists()) { - mDatabaseFile.delete(); - } - mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null); - assertNotNull(mDatabase); - mDatabase.setVersion(CURRENT_DATABASE_VERSION); - } - - @Override - protected void tearDown() throws Exception { - mDatabase.close(); - mDatabaseFile.delete(); - super.tearDown(); - } - - public boolean isPerformanceOnly() { - return false; - } - - // These test can only be run once. - public int startPerformance(Intermediates intermediates) { - return 1; - } - - private void populateDefaultTable() { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);"); - - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString1 + "');"); - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString2 + "');"); - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString3 + "');"); - } - - @MediumTest - public void testCursorUpdate() { - mDatabase.execSQL( - "CREATE TABLE test (_id INTEGER PRIMARY KEY, d INTEGER, s INTEGER);"); - for(int i = 0; i < 20; i++) { - mDatabase.execSQL("INSERT INTO test (d, s) VALUES (" + i + - "," + i%2 + ");"); - } - - Cursor c = mDatabase.query("test", null, "s = 0", null, null, null, null); - int dCol = c.getColumnIndexOrThrow("d"); - int sCol = c.getColumnIndexOrThrow("s"); - - int count = 0; - while (c.moveToNext()) { - assertTrue(c.updateInt(dCol, 3)); - count++; - } - assertEquals(10, count); - - assertTrue(c.commitUpdates()); - - assertTrue(c.requery()); - - count = 0; - while (c.moveToNext()) { - assertEquals(3, c.getInt(dCol)); - count++; - } - - assertEquals(10, count); - assertTrue(c.moveToFirst()); - assertTrue(c.deleteRow()); - assertEquals(9, c.getCount()); - c.close(); - } - - @MediumTest - public void testBlob() throws Exception { - // create table - mDatabase.execSQL( - "CREATE TABLE test (_id INTEGER PRIMARY KEY, s TEXT, d REAL, l INTEGER, b BLOB);"); - // insert blob - Object[] args = new Object[4]; - - byte[] blob = new byte[1000]; - byte value = 99; - Arrays.fill(blob, value); - args[3] = blob; - - String s = new String("text"); - args[0] = s; - Double d = 99.9; - args[1] = d; - Long l = (long)1000; - args[2] = l; - - String sql = "INSERT INTO test (s, d, l, b) VALUES (?,?,?,?)"; - mDatabase.execSQL(sql, args); - // use cursor to access blob - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - c.moveToNext(); - ContentValues cv = new ContentValues(); - DatabaseUtils.cursorRowToContentValues(c, cv); - - int bCol = c.getColumnIndexOrThrow("b"); - int sCol = c.getColumnIndexOrThrow("s"); - int dCol = c.getColumnIndexOrThrow("d"); - int lCol = c.getColumnIndexOrThrow("l"); - byte[] cBlob = c.getBlob(bCol); - assertTrue(Arrays.equals(blob, cBlob)); - assertEquals(s, c.getString(sCol)); - assertEquals((double)d, c.getDouble(dCol)); - assertEquals((long)l, c.getLong(lCol)); - - // new byte[] - byte[] newblob = new byte[1000]; - value = 98; - Arrays.fill(blob, value); - - c.updateBlob(bCol, newblob); - cBlob = c.getBlob(bCol); - assertTrue(Arrays.equals(newblob, cBlob)); - - // commit - assertTrue(c.commitUpdates()); - assertTrue(c.requery()); - c.moveToNext(); - cBlob = c.getBlob(bCol); - assertTrue(Arrays.equals(newblob, cBlob)); - c.close(); - } - - @MediumTest - public void testRealColumns() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data REAL);"); - ContentValues values = new ContentValues(); - values.put("data", 42.11); - long id = mDatabase.insert("test", "data", values); - assertTrue(id > 0); - Cursor c = mDatabase.rawQuery("SELECT data FROM test", null); - assertNotNull(c); - assertTrue(c.moveToFirst()); - assertEquals(42.11, c.getDouble(0)); - c.close(); - } - - @MediumTest - public void testCursor1() throws Exception { - populateDefaultTable(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - - int dataColumn = c.getColumnIndexOrThrow("data"); - - // The cursor should ignore text before the last period when looking for a column. (This - // is a temporary hack in all implementations of getColumnIndex.) - int dataColumn2 = c.getColumnIndexOrThrow("junk.data"); - assertEquals(dataColumn, dataColumn2); - - assertSame(3, c.getCount()); - - assertTrue(c.isBeforeFirst()); - - try { - c.getInt(0); - fail("CursorIndexOutOfBoundsException expected"); - } catch (CursorIndexOutOfBoundsException ex) { - // expected - } - - c.moveToNext(); - assertEquals(1, c.getInt(0)); - - String s = c.getString(dataColumn); - assertEquals(sString1, s); - - c.moveToNext(); - s = c.getString(dataColumn); - assertEquals(sString2, s); - - c.moveToNext(); - s = c.getString(dataColumn); - assertEquals(sString3, s); - - c.moveToPosition(-1); - c.moveToNext(); - s = c.getString(dataColumn); - assertEquals(sString1, s); - - c.moveToPosition(2); - s = c.getString(dataColumn); - assertEquals(sString3, s); - - int i; - - for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) { - c.getInt(0); - } - - assertEquals(3, i); - - try { - c.getInt(0); - fail("CursorIndexOutOfBoundsException expected"); - } catch (CursorIndexOutOfBoundsException ex) { - // expected - } - c.close(); - } - - @MediumTest - public void testCursor2() throws Exception { - populateDefaultTable(); - - Cursor c = mDatabase.query("test", null, "_id > 1000", null, null, null, null); - assertEquals(0, c.getCount()); - assertTrue(c.isBeforeFirst()); - - try { - c.getInt(0); - fail("CursorIndexOutOfBoundsException expected"); - } catch (CursorIndexOutOfBoundsException ex) { - // expected - } - - int i; - for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) { - c.getInt(0); - } - assertEquals(0, i); - try { - c.getInt(0); - fail("CursorIndexOutOfBoundsException expected"); - } catch (CursorIndexOutOfBoundsException ex) { - // expected - } - c.close(); - } - - @MediumTest - public void testLargeField() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);"); - - StringBuilder sql = new StringBuilder(2100); - sql.append("INSERT INTO test (data) VALUES ('"); - Random random = new Random(System.currentTimeMillis()); - StringBuilder randomString = new StringBuilder(1979); - for (int i = 0; i < 1979; i++) { - randomString.append((random.nextInt() & 0xf) % 10); - } - sql.append(randomString); - sql.append("');"); - mDatabase.execSQL(sql.toString()); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - assertNotNull(c); - assertEquals(1, c.getCount()); - - assertTrue(c.moveToFirst()); - assertEquals(0, c.getPosition()); - String largeString = c.getString(c.getColumnIndexOrThrow("data")); - assertNotNull(largeString); - assertEquals(randomString.toString(), largeString); - c.close(); - } - - class TestObserver extends DataSetObserver { - int total; - SQLiteCursor c; - boolean quit = false; - public TestObserver(int total_, SQLiteCursor cursor) { - c = cursor; - total = total_; - } - - @Override - public void onChanged() { - int count = c.getCount(); - if (total == count) { - int i = 0; - while (c.moveToNext()) { - assertEquals(i, c.getInt(1)); - i++; - } - assertEquals(count, i); - quit = true; - Looper.myLooper().quit(); - } - } - - @Override - public void onInvalidated() { - } - } - - //@Large - @Suppress - public void testLoadingThreadDelayRegisterData() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);"); - - final int count = 505; - String sql = "INSERT INTO test (data) VALUES (?);"; - SQLiteStatement s = mDatabase.compileStatement(sql); - for (int i = 0; i < count; i++) { - s.bindLong(1, i); - s.execute(); - } - - int maxRead = 500; - int initialRead = 5; - SQLiteCursor c = (SQLiteCursor)mDatabase.rawQuery("select * from test;", - null, initialRead, maxRead); - - TestObserver observer = new TestObserver(count, c); - c.getCount(); - c.registerDataSetObserver(observer); - if (!observer.quit) { - Looper.loop(); - } - c.close(); - } - - @LargeTest - public void testLoadingThread() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);"); - - final int count = 50000; - String sql = "INSERT INTO test (data) VALUES (?);"; - SQLiteStatement s = mDatabase.compileStatement(sql); - for (int i = 0; i < count; i++) { - s.bindLong(1, i); - s.execute(); - } - - int maxRead = 1000; - int initialRead = 5; - SQLiteCursor c = (SQLiteCursor)mDatabase.rawQuery("select * from test;", - null, initialRead, maxRead); - - TestObserver observer = new TestObserver(count, c); - c.registerDataSetObserver(observer); - c.getCount(); - - Looper.loop(); - c.close(); - } - - @LargeTest - public void testLoadingThreadClose() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);"); - - final int count = 1000; - String sql = "INSERT INTO test (data) VALUES (?);"; - SQLiteStatement s = mDatabase.compileStatement(sql); - for (int i = 0; i < count; i++) { - s.bindLong(1, i); - s.execute(); - } - - int maxRead = 11; - int initialRead = 5; - SQLiteCursor c = (SQLiteCursor)mDatabase.rawQuery("select * from test;", - null, initialRead, maxRead); - - TestObserver observer = new TestObserver(count, c); - c.registerDataSetObserver(observer); - c.getCount(); - c.close(); - } - - @LargeTest - public void testLoadingThreadDeactivate() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);"); - - final int count = 1000; - String sql = "INSERT INTO test (data) VALUES (?);"; - SQLiteStatement s = mDatabase.compileStatement(sql); - for (int i = 0; i < count; i++) { - s.bindLong(1, i); - s.execute(); - } - - int maxRead = 11; - int initialRead = 5; - SQLiteCursor c = (SQLiteCursor)mDatabase.rawQuery("select * from test;", - null, initialRead, maxRead); - - TestObserver observer = new TestObserver(count, c); - c.registerDataSetObserver(observer); - c.getCount(); - c.deactivate(); - c.close(); - } - - @LargeTest - public void testManyRowsLong() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);"); - - final int count = 36799; - for (int i = 0; i < count; i++) { - mDatabase.execSQL("INSERT INTO test (data) VALUES (" + i + ");"); - } - - Cursor c = mDatabase.query("test", new String[]{"data"}, null, null, null, null, null); - assertNotNull(c); - - int i = 0; - while (c.moveToNext()) { - assertEquals(i, c.getInt(0)); - i++; - } - assertEquals(count, i); - assertEquals(count, c.getCount()); - - Log.d("testManyRows", "count " + Integer.toString(i)); - c.close(); - } - - @LargeTest - public void testManyRowsTxt() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);"); - StringBuilder sql = new StringBuilder(2100); - sql.append("INSERT INTO test (data) VALUES ('"); - Random random = new Random(System.currentTimeMillis()); - StringBuilder randomString = new StringBuilder(1979); - for (int i = 0; i < 1979; i++) { - randomString.append((random.nextInt() & 0xf) % 10); - } - sql.append(randomString); - sql.append("');"); - - // if cursor window size changed, adjust this value too - final int count = 600; // more than two fillWindow needed - for (int i = 0; i < count; i++) { - mDatabase.execSQL(sql.toString()); - } - - Cursor c = mDatabase.query("test", new String[]{"data"}, null, null, null, null, null); - assertNotNull(c); - - int i = 0; - while (c.moveToNext()) { - assertEquals(randomString.toString(), c.getString(0)); - i++; - } - assertEquals(count, i); - assertEquals(count, c.getCount()); - c.close(); - } - - @LargeTest - public void testManyRowsTxtLong() throws Exception { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, txt TEXT, data INT);"); - - Random random = new Random(System.currentTimeMillis()); - StringBuilder randomString = new StringBuilder(1979); - for (int i = 0; i < 1979; i++) { - randomString.append((random.nextInt() & 0xf) % 10); - } - - // if cursor window size changed, adjust this value too - final int count = 600; - for (int i = 0; i < count; i++) { - StringBuilder sql = new StringBuilder(2100); - sql.append("INSERT INTO test (txt, data) VALUES ('"); - sql.append(randomString); - sql.append("','"); - sql.append(i); - sql.append("');"); - mDatabase.execSQL(sql.toString()); - } - - Cursor c = mDatabase.query("test", new String[]{"txt", "data"}, null, null, null, null, null); - assertNotNull(c); - - int i = 0; - while (c.moveToNext()) { - assertEquals(randomString.toString(), c.getString(0)); - assertEquals(i, c.getInt(1)); - i++; - } - assertEquals(count, i); - assertEquals(count, c.getCount()); - c.close(); - } - - @MediumTest - public void testRequery() throws Exception { - populateDefaultTable(); - - Cursor c = mDatabase.rawQuery("SELECT * FROM test", null); - assertNotNull(c); - assertEquals(3, c.getCount()); - c.deactivate(); - c.requery(); - assertEquals(3, c.getCount()); - c.close(); - } - - @MediumTest - public void testRequeryWithSelection() throws Exception { - populateDefaultTable(); - - Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = '" + sString1 + "'", - null); - assertNotNull(c); - assertEquals(1, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - c.deactivate(); - c.requery(); - assertEquals(1, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - c.close(); - } - - @MediumTest - public void testRequeryWithSelectionArgs() throws Exception { - populateDefaultTable(); - - Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = ?", - new String[]{sString1}); - assertNotNull(c); - assertEquals(1, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - c.deactivate(); - c.requery(); - assertEquals(1, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - c.close(); - } - - @MediumTest - public void testRequeryWithAlteredSelectionArgs() throws Exception { - /** - * Test the ability of a subclass of SQLiteCursor to change its query arguments. - */ - populateDefaultTable(); - - SQLiteDatabase.CursorFactory factory = new SQLiteDatabase.CursorFactory() { - public Cursor newCursor( - SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, - SQLiteQuery query) { - return new SQLiteCursor(db, masterQuery, editTable, query) { - @Override - public boolean requery() { - setSelectionArguments(new String[]{"2"}); - return super.requery(); - } - }; - } - }; - Cursor c = mDatabase.rawQueryWithFactory( - factory, "SELECT data FROM test WHERE _id <= ?", new String[]{"1"}, - null); - assertNotNull(c); - assertEquals(1, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - - // Our hacked requery() changes the query arguments in the cursor. - c.requery(); - - assertEquals(2, c.getCount()); - assertTrue(c.moveToFirst()); - assertEquals(sString1, c.getString(0)); - assertTrue(c.moveToNext()); - assertEquals(sString2, c.getString(0)); - - // Test that setting query args on a deactivated cursor also works. - c.deactivate(); - c.requery(); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java index 7a4d934..69d55c1 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java @@ -987,4 +987,18 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase ih.close(); } + @MediumTest + public void testDbCloseReleasingAllCachedSql() { + mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, text1 TEXT, text2 TEXT, " + + "num1 INTEGER, num2 INTEGER, image BLOB);"); + final String statement = "DELETE FROM test WHERE _id=?;"; + SQLiteStatement statementDoNotClose = mDatabase.compileStatement(statement); + assertTrue(statementDoNotClose.getUniqueId() > 0); + int nStatement = statementDoNotClose.getUniqueId(); + assertTrue(statementDoNotClose.getUniqueId() == nStatement); + /* do not close statementDoNotClose object. + * That should leave it in SQLiteDatabase.mPrograms. + * mDatabase.close() in tearDown() should release it. + */ + } } diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseStatementTest.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseStatementTest.java deleted file mode 100644 index 16ca59f..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseStatementTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.database.Cursor; -import android.database.sqlite.SQLiteConstraintException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDoneException; -import android.database.sqlite.SQLiteStatement; -import android.test.PerformanceTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; -import junit.framework.TestCase; - -import java.io.File; - -public class DatabaseStatementTest extends TestCase implements PerformanceTestCase { - - private static final String sString1 = "this is a test"; - private static final String sString2 = "and yet another test"; - private static final String sString3 = "this string is a little longer, but still a test"; - - private static final int CURRENT_DATABASE_VERSION = 42; - private SQLiteDatabase mDatabase; - private File mDatabaseFile; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mDatabaseFile = new File("/sqlite_stmt_journals", "database_test.db"); - if (mDatabaseFile.exists()) { - mDatabaseFile.delete(); - } - mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null); - assertNotNull(mDatabase); - mDatabase.setVersion(CURRENT_DATABASE_VERSION); - } - - @Override - protected void tearDown() throws Exception { - mDatabase.close(); - mDatabaseFile.delete(); - super.tearDown(); - } - - public boolean isPerformanceOnly() { - return false; - } - - // These test can only be run once. - public int startPerformance(Intermediates intermediates) { - return 1; - } - - private void populateDefaultTable() { - mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);"); - - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString1 + "');"); - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString2 + "');"); - mDatabase.execSQL("INSERT INTO test (data) VALUES ('" + sString3 + "');"); - } - - @MediumTest - public void testExecuteStatement() throws Exception { - populateDefaultTable(); - SQLiteStatement statement = mDatabase.compileStatement("DELETE FROM test"); - statement.execute(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - assertEquals(0, c.getCount()); - c.deactivate(); - statement.close(); - } - - @MediumTest - public void testSimpleQuery() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER NOT NULL, str TEXT NOT NULL);"); - mDatabase.execSQL("INSERT INTO test VALUES (1234, 'hello');"); - SQLiteStatement statement1 = - mDatabase.compileStatement("SELECT num FROM test WHERE str = ?"); - SQLiteStatement statement2 = - mDatabase.compileStatement("SELECT str FROM test WHERE num = ?"); - - try { - statement1.bindString(1, "hello"); - long value = statement1.simpleQueryForLong(); - assertEquals(1234, value); - - statement1.bindString(1, "world"); - statement1.simpleQueryForLong(); - fail("shouldn't get here"); - } catch (SQLiteDoneException e) { - // expected - } - - try { - statement2.bindLong(1, 1234); - String value = statement1.simpleQueryForString(); - assertEquals("hello", value); - - statement2.bindLong(1, 5678); - statement1.simpleQueryForString(); - fail("shouldn't get here"); - } catch (SQLiteDoneException e) { - // expected - } - - statement1.close(); - statement2.close(); - } - - @MediumTest - public void testStatementLongBinding() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER);"); - SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)"); - - for (int i = 0; i < 10; i++) { - statement.bindLong(1, i); - statement.execute(); - } - statement.close(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - int numCol = c.getColumnIndexOrThrow("num"); - c.moveToFirst(); - for (long i = 0; i < 10; i++) { - long num = c.getLong(numCol); - assertEquals(i, num); - c.moveToNext(); - } - c.close(); - } - - @MediumTest - public void testStatementStringBinding() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num TEXT);"); - SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)"); - - for (long i = 0; i < 10; i++) { - statement.bindString(1, Long.toHexString(i)); - statement.execute(); - } - statement.close(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - int numCol = c.getColumnIndexOrThrow("num"); - c.moveToFirst(); - for (long i = 0; i < 10; i++) { - String num = c.getString(numCol); - assertEquals(Long.toHexString(i), num); - c.moveToNext(); - } - c.close(); - } - - @MediumTest - public void testStatementClearBindings() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER);"); - SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)"); - - for (long i = 0; i < 10; i++) { - statement.bindLong(1, i); - statement.clearBindings(); - statement.execute(); - } - statement.close(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID"); - int numCol = c.getColumnIndexOrThrow("num"); - assertTrue(c.moveToFirst()); - for (long i = 0; i < 10; i++) { - assertTrue(c.isNull(numCol)); - c.moveToNext(); - } - c.close(); - } - - @MediumTest - public void testSimpleStringBinding() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num TEXT, value TEXT);"); - String statement = "INSERT INTO test (num, value) VALUES (?,?)"; - - String[] args = new String[2]; - for (int i = 0; i < 2; i++) { - args[i] = Integer.toHexString(i); - } - - mDatabase.execSQL(statement, args); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - int numCol = c.getColumnIndexOrThrow("num"); - int valCol = c.getColumnIndexOrThrow("value"); - c.moveToFirst(); - String num = c.getString(numCol); - assertEquals(Integer.toHexString(0), num); - - String val = c.getString(valCol); - assertEquals(Integer.toHexString(1), val); - c.close(); - } - - @MediumTest - public void testStatementMultipleBindings() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER, str TEXT);"); - SQLiteStatement statement = - mDatabase.compileStatement("INSERT INTO test (num, str) VALUES (?, ?)"); - - for (long i = 0; i < 10; i++) { - statement.bindLong(1, i); - statement.bindString(2, Long.toHexString(i)); - statement.execute(); - } - statement.close(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID"); - int numCol = c.getColumnIndexOrThrow("num"); - int strCol = c.getColumnIndexOrThrow("str"); - assertTrue(c.moveToFirst()); - for (long i = 0; i < 10; i++) { - long num = c.getLong(numCol); - String str = c.getString(strCol); - assertEquals(i, num); - assertEquals(Long.toHexString(i), str); - c.moveToNext(); - } - c.close(); - } - - private static class StatementTestThread extends Thread { - private SQLiteDatabase mDatabase; - private SQLiteStatement mStatement; - - public StatementTestThread(SQLiteDatabase db, SQLiteStatement statement) { - super(); - mDatabase = db; - mStatement = statement; - } - - @Override - public void run() { - mDatabase.beginTransaction(); - for (long i = 0; i < 10; i++) { - mStatement.bindLong(1, i); - mStatement.bindString(2, Long.toHexString(i)); - mStatement.execute(); - } - mDatabase.setTransactionSuccessful(); - mDatabase.endTransaction(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID"); - int numCol = c.getColumnIndexOrThrow("num"); - int strCol = c.getColumnIndexOrThrow("str"); - assertTrue(c.moveToFirst()); - for (long i = 0; i < 10; i++) { - long num = c.getLong(numCol); - String str = c.getString(strCol); - assertEquals(i, num); - assertEquals(Long.toHexString(i), str); - c.moveToNext(); - } - c.close(); - } - } - - @MediumTest - public void testStatementMultiThreaded() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER, str TEXT);"); - SQLiteStatement statement = - mDatabase.compileStatement("INSERT INTO test (num, str) VALUES (?, ?)"); - - StatementTestThread thread = new StatementTestThread(mDatabase, statement); - thread.start(); - try { - thread.join(); - } finally { - statement.close(); - } - } - - @MediumTest - public void testStatementConstraint() throws Exception { - mDatabase.execSQL("CREATE TABLE test (num INTEGER NOT NULL);"); - SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)"); - - // Try to insert NULL, which violates the constraint - try { - statement.clearBindings(); - statement.execute(); - fail("expected exception not thrown"); - } catch (SQLiteConstraintException e) { - // expected - } - - // Make sure the statement can still be used - statement.bindLong(1, 1); - statement.execute(); - statement.close(); - - Cursor c = mDatabase.query("test", null, null, null, null, null, null); - int numCol = c.getColumnIndexOrThrow("num"); - c.moveToFirst(); - long num = c.getLong(numCol); - assertEquals(1, num); - c.close(); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseTests.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseTests.java index a7a1400..a288c73 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseTests.java +++ b/tests/AndroidTests/src/com/android/unit_tests/DatabaseTests.java @@ -23,8 +23,6 @@ public class DatabaseTests { TestSuite suite = new TestSuite(DatabaseTests.class.getName()); suite.addTestSuite(DatabaseGeneralTest.class); - suite.addTestSuite(DatabaseCursorTest.class); - suite.addTestSuite(DatabaseStatementTest.class); suite.addTestSuite(DatabaseLocaleTest.class); suite.addTestSuite(CursorWindowTest.class); suite.addTestSuite(DatabaseLockTest.class); diff --git a/tests/AndroidTests/src/com/android/unit_tests/DbSSLSessionCacheTest.java b/tests/AndroidTests/src/com/android/unit_tests/DbSSLSessionCacheTest.java deleted file mode 100644 index 8d7d797..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/DbSSLSessionCacheTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.content.ContentResolver; -import android.database.Cursor; -import android.database.sqlite.SQLiteOpenHelper; -import android.provider.Settings; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.LargeTest; -import android.test.suitebuilder.annotation.Suppress; - -import com.google.android.net.GoogleHttpClient; - -import com.android.internal.net.DbSSLSessionCache; -import com.android.internal.net.DbSSLSessionCache.DatabaseHelper; - -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; - -import java.io.IOException; -import java.security.Principal; -import java.security.cert.Certificate; - -import javax.net.ssl.SSLPeerUnverifiedException; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSessionContext; -import javax.security.cert.X509Certificate; - -/** Unit test for SSL session caching with {@link GoogleHttpClient}. - * Uses network resources. - */ -@Suppress -public class DbSSLSessionCacheTest extends AndroidTestCase { - - protected void setUp() throws Exception { - } - - protected void tearDown() throws Exception { - } - - /** - * We want to test the actual database write - the actual hooking into - * low-level SSL is tested. - */ - @LargeTest - public void testSslCacheAdd() throws Exception { - // Let's verify the database has the rows. - // Use internal details of the implementation - could make the field - // visible for testing, but it's same. - - // Use default database - DbSSLSessionCache cache = DbSSLSessionCache.getInstanceForPackage(getContext()); - cache.clear(); - - - makeRequestInNewContext("https://www.google.com"); - - // Verify the key was inserted - SQLiteOpenHelper helper = new DatabaseHelper(getContext()); - Cursor query = null; - try { - query = helper.getReadableDatabase().query(DbSSLSessionCache.SSL_CACHE_TABLE, - new String[] {"hostport"}, null, - null, null, null, null); - - assertTrue(query.moveToFirst()); // one row inserted - String hostPort = query.getString(0); - assertEquals(hostPort, "www.google.com:443"); - } finally { - query.close(); - } - } - - @LargeTest - public void testExpire() throws Exception { - DatabaseHelper helper = new DatabaseHelper(getContext()); - // clean up - DbSSLSessionCache cache = new DbSSLSessionCache(helper); - cache.clear(); - - long t0 = System.currentTimeMillis(); - for (int i = 0; i < DbSSLSessionCache.MAX_CACHE_SIZE + 2; i++) { - final int port = i; - cache.putSessionData(new MockSession() { - - public String getPeerHost() { - return "test.host.com"; - } - - public int getPeerPort() { - return port; - } - }, new byte[256]); - } - long t1 = System.currentTimeMillis(); - - System.err.println("Time to insert " + - (DbSSLSessionCache.MAX_CACHE_SIZE + 2) + " " + (t1 - t0)); - - // first entry should have port 1. - Cursor query = helper.getReadableDatabase().query(DbSSLSessionCache.SSL_CACHE_TABLE, - new String[] {"hostport", "session"}, null, - null, null, null, null); - - int cnt = query.getCount(); - - assertTrue(query.moveToFirst()); // one row inserted - String hostPort = query.getString(0); - assertEquals("test.host.com:2", hostPort); - while (query.moveToNext()) { - hostPort = query.getString(0); - String session = query.getString(1); - } - long t2 = System.currentTimeMillis(); - System.err.println("Time to load " + cnt + " " + (t2 - t1)); - - query.close(); - } - - private void makeRequestInNewContext(String url) throws IOException { - GoogleHttpClient client = new GoogleHttpClient(getContext(), "Test", - false /* no gzip */); - - try { - // Note: we must test against a real server, because the connection - // gets established before the interceptor can crash the request. - HttpGet method = new HttpGet(url); - HttpResponse response = client.execute(method); - } finally { - client.close(); - } - } - - private static class MockSession implements SSLSession { - - public String getPeerHost() { - throw new UnsupportedOperationException(); - } - - - public int getPeerPort() { - throw new UnsupportedOperationException(); - } - - - - public int getApplicationBufferSize() { - throw new UnsupportedOperationException(); - } - - - public String getCipherSuite() { - throw new UnsupportedOperationException(); - } - - - public long getCreationTime() { - throw new UnsupportedOperationException(); - } - - - public byte[] getId() { - throw new UnsupportedOperationException(); - } - - - public long getLastAccessedTime() { - throw new UnsupportedOperationException(); - } - - - public Certificate[] getLocalCertificates() { - throw new UnsupportedOperationException(); - } - - - public Principal getLocalPrincipal() { - throw new UnsupportedOperationException(); - } - - - public int getPacketBufferSize() { - throw new UnsupportedOperationException(); - } - - - public X509Certificate[] getPeerCertificateChain() - throws SSLPeerUnverifiedException { - throw new UnsupportedOperationException(); - } - - - public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { - throw new UnsupportedOperationException(); - } - - - public Principal getPeerPrincipal() throws SSLPeerUnverifiedException { - throw new UnsupportedOperationException(); - } - - - public String getProtocol() { - throw new UnsupportedOperationException(); - } - - - public SSLSessionContext getSessionContext() { - throw new UnsupportedOperationException(); - } - - - public Object getValue(String name) { - throw new UnsupportedOperationException(); - } - - - public String[] getValueNames() { - throw new UnsupportedOperationException(); - } - - - public void invalidate() { - throw new UnsupportedOperationException(); - } - - - public boolean isValid() { - throw new UnsupportedOperationException(); - } - - - public void putValue(String name, Object value) { - throw new UnsupportedOperationException(); - } - - - public void removeValue(String name) { - throw new UnsupportedOperationException(); - } - } - - -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/DropBoxTest.java b/tests/AndroidTests/src/com/android/unit_tests/DropBoxTest.java new file mode 100644 index 0000000..d20abd9 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/DropBoxTest.java @@ -0,0 +1,517 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests; + +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.os.DropBoxManager; +import android.os.ServiceManager; +import android.os.StatFs; +import android.provider.Settings; +import android.test.AndroidTestCase; + +import com.android.server.DropBoxManagerService; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.InputStream; +import java.util.Random; +import java.util.zip.GZIPOutputStream; + +/** Test {@link DropBoxManager} functionality. */ +public class DropBoxTest extends AndroidTestCase { + public void tearDown() throws Exception { + ContentResolver cr = getContext().getContentResolver(); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_AGE_SECONDS, ""); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_QUOTA_KB, ""); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_TAG_PREFIX + "DropBoxTest", ""); + } + + public void testAddText() throws Exception { + DropBoxManager dropbox = (DropBoxManager) getContext().getSystemService( + Context.DROPBOX_SERVICE); + long before = System.currentTimeMillis(); + Thread.sleep(5); + dropbox.addText("DropBoxTest", "TEST0"); + Thread.sleep(5); + long between = System.currentTimeMillis(); + Thread.sleep(5); + dropbox.addText("DropBoxTest", "TEST1"); + dropbox.addText("DropBoxTest", "TEST2"); + Thread.sleep(5); + long after = System.currentTimeMillis(); + + DropBoxManager.Entry e0 = dropbox.getNextEntry("DropBoxTest", before); + DropBoxManager.Entry e1 = dropbox.getNextEntry("DropBoxTest", e0.getTimeMillis()); + DropBoxManager.Entry e2 = dropbox.getNextEntry("DropBoxTest", e1.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e2.getTimeMillis())); + + assertTrue(e0.getTimeMillis() > before); + assertTrue(e0.getTimeMillis() < between); + assertTrue(e1.getTimeMillis() > between); + assertTrue(e1.getTimeMillis() < e2.getTimeMillis()); + assertTrue(e2.getTimeMillis() < after); + + assertEquals("TEST0", e0.getText(80)); + assertEquals("TEST1", e1.getText(80)); + assertEquals("TES", e2.getText(3)); + + e0.close(); + e1.close(); + e2.close(); + } + + public void testAddData() throws Exception { + DropBoxManager dropbox = (DropBoxManager) getContext().getSystemService( + Context.DROPBOX_SERVICE); + long before = System.currentTimeMillis(); + dropbox.addData("DropBoxTest", "TEST".getBytes(), 0); + long after = System.currentTimeMillis(); + + DropBoxManager.Entry e = dropbox.getNextEntry("DropBoxTest", before); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e.getTimeMillis())); + + assertEquals("DropBoxTest", e.getTag()); + assertTrue(e.getTimeMillis() >= before); + assertEquals(0, e.getFlags()); + assertTrue(null == e.getText(80)); + + byte[] buf = new byte[80]; + assertEquals("TEST", new String(buf, 0, e.getInputStream().read(buf))); + + e.close(); + } + + public void testAddFile() throws Exception { + File dir = getEmptyDir("testAddFile"); + long before = System.currentTimeMillis(); + + File f0 = new File(dir, "f0.txt"); + File f1 = new File(dir, "f1.txt.gz"); + File f2 = new File(dir, "f2.dat"); + File f3 = new File(dir, "f2.dat.gz"); + + FileWriter w0 = new FileWriter(f0); + GZIPOutputStream gz1 = new GZIPOutputStream(new FileOutputStream(f1)); + FileOutputStream os2 = new FileOutputStream(f2); + GZIPOutputStream gz3 = new GZIPOutputStream(new FileOutputStream(f3)); + + w0.write("FILE0"); + gz1.write("FILE1".getBytes()); + os2.write("DATA2".getBytes()); + gz3.write("DATA3".getBytes()); + + w0.close(); + gz1.close(); + os2.close(); + gz3.close(); + + DropBoxManager dropbox = (DropBoxManager) getContext().getSystemService( + Context.DROPBOX_SERVICE); + + dropbox.addFile("DropBoxTest", f0, DropBoxManager.IS_TEXT); + dropbox.addFile("DropBoxTest", f1, DropBoxManager.IS_TEXT | DropBoxManager.IS_GZIPPED); + dropbox.addFile("DropBoxTest", f2, 0); + dropbox.addFile("DropBoxTest", f3, DropBoxManager.IS_GZIPPED); + + DropBoxManager.Entry e0 = dropbox.getNextEntry("DropBoxTest", before); + DropBoxManager.Entry e1 = dropbox.getNextEntry("DropBoxTest", e0.getTimeMillis()); + DropBoxManager.Entry e2 = dropbox.getNextEntry("DropBoxTest", e1.getTimeMillis()); + DropBoxManager.Entry e3 = dropbox.getNextEntry("DropBoxTest", e2.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e3.getTimeMillis())); + + assertTrue(e0.getTimeMillis() > before); + assertTrue(e1.getTimeMillis() > e0.getTimeMillis()); + assertTrue(e2.getTimeMillis() > e1.getTimeMillis()); + assertTrue(e3.getTimeMillis() > e2.getTimeMillis()); + + assertEquals(DropBoxManager.IS_TEXT, e0.getFlags()); + assertEquals(DropBoxManager.IS_TEXT, e1.getFlags()); + assertEquals(0, e2.getFlags()); + assertEquals(0, e3.getFlags()); + + assertEquals("FILE0", e0.getText(80)); + + byte[] buf1 = new byte[80]; + assertEquals("FILE1", new String(buf1, 0, e1.getInputStream().read(buf1))); + + assertTrue(null == e2.getText(80)); + byte[] buf2 = new byte[80]; + assertEquals("DATA2", new String(buf2, 0, e2.getInputStream().read(buf2))); + + assertTrue(null == e3.getText(80)); + byte[] buf3 = new byte[80]; + assertEquals("DATA3", new String(buf3, 0, e3.getInputStream().read(buf3))); + + e0.close(); + e1.close(); + e2.close(); + e3.close(); + } + + public void testAddEntriesInTheFuture() throws Exception { + File dir = getEmptyDir("testAddEntriesInTheFuture"); + long before = System.currentTimeMillis(); + + // Near future: should be allowed to persist + FileWriter w0 = new FileWriter(new File(dir, "DropBoxTest@" + (before + 5000) + ".txt")); + w0.write("FUTURE0"); + w0.close(); + + // Far future: should be collapsed + FileWriter w1 = new FileWriter(new File(dir, "DropBoxTest@" + (before + 100000) + ".txt")); + w1.write("FUTURE1"); + w1.close(); + + // Another far future item, this one gzipped + File f2 = new File(dir, "DropBoxTest@" + (before + 100001) + ".txt.gz"); + GZIPOutputStream gz2 = new GZIPOutputStream(new FileOutputStream(f2)); + gz2.write("FUTURE2".getBytes()); + gz2.close(); + + // Tombstone in the far future + new FileOutputStream(new File(dir, "DropBoxTest@" + (before + 100002) + ".lost")).close(); + + DropBoxManagerService service = new DropBoxManagerService(getContext(), dir); + DropBoxManager dropbox = new DropBoxManager(service); + + // Until a write, the timestamps are taken at face value + DropBoxManager.Entry e0 = dropbox.getNextEntry(null, before); + DropBoxManager.Entry e1 = dropbox.getNextEntry(null, e0.getTimeMillis()); + DropBoxManager.Entry e2 = dropbox.getNextEntry(null, e1.getTimeMillis()); + DropBoxManager.Entry e3 = dropbox.getNextEntry(null, e2.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry(null, e3.getTimeMillis())); + + assertEquals("FUTURE0", e0.getText(80)); + assertEquals("FUTURE1", e1.getText(80)); + assertEquals("FUTURE2", e2.getText(80)); + assertEquals(null, e3.getText(80)); + + assertEquals(before + 5000, e0.getTimeMillis()); + assertEquals(before + 100000, e1.getTimeMillis()); + assertEquals(before + 100001, e2.getTimeMillis()); + assertEquals(before + 100002, e3.getTimeMillis()); + + e0.close(); + e1.close(); + e2.close(); + e3.close(); + + // Write something to force a collapse + dropbox.addText("NotDropBoxTest", "FUTURE"); + e0 = dropbox.getNextEntry(null, before); + e1 = dropbox.getNextEntry(null, e0.getTimeMillis()); + e2 = dropbox.getNextEntry(null, e1.getTimeMillis()); + e3 = dropbox.getNextEntry(null, e2.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e3.getTimeMillis())); + + assertEquals("FUTURE0", e0.getText(80)); + assertEquals("FUTURE1", e1.getText(80)); + assertEquals("FUTURE2", e2.getText(80)); + assertEquals(null, e3.getText(80)); + + assertEquals(before + 5000, e0.getTimeMillis()); + assertEquals(before + 5001, e1.getTimeMillis()); + assertEquals(before + 5002, e2.getTimeMillis()); + assertEquals(before + 5003, e3.getTimeMillis()); + + e0.close(); + e1.close(); + e2.close(); + e3.close(); + service.stop(); + } + + public void testIsTagEnabled() throws Exception { + DropBoxManager dropbox = (DropBoxManager) getContext().getSystemService( + Context.DROPBOX_SERVICE); + long before = System.currentTimeMillis(); + dropbox.addText("DropBoxTest", "TEST-ENABLED"); + assertTrue(dropbox.isTagEnabled("DropBoxTest")); + + ContentResolver cr = getContext().getContentResolver(); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_TAG_PREFIX + "DropBoxTest", + "disabled"); + + dropbox.addText("DropBoxTest", "TEST-DISABLED"); + assertFalse(dropbox.isTagEnabled("DropBoxTest")); + + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_TAG_PREFIX + "DropBoxTest", + ""); + + dropbox.addText("DropBoxTest", "TEST-ENABLED-AGAIN"); + assertTrue(dropbox.isTagEnabled("DropBoxTest")); + + DropBoxManager.Entry e0 = dropbox.getNextEntry("DropBoxTest", before); + DropBoxManager.Entry e1 = dropbox.getNextEntry("DropBoxTest", e0.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e1.getTimeMillis())); + + assertEquals("TEST-ENABLED", e0.getText(80)); + assertEquals("TEST-ENABLED-AGAIN", e1.getText(80)); + + e0.close(); + e1.close(); + } + + public void testGetNextEntry() throws Exception { + File dir = getEmptyDir("testGetNextEntry"); + DropBoxManagerService service = new DropBoxManagerService(getContext(), dir); + DropBoxManager dropbox = new DropBoxManager(service); + + long before = System.currentTimeMillis(); + dropbox.addText("DropBoxTest.A", "A0"); + dropbox.addText("DropBoxTest.B", "B0"); + dropbox.addText("DropBoxTest.A", "A1"); + + DropBoxManager.Entry a0 = dropbox.getNextEntry("DropBoxTest.A", before); + DropBoxManager.Entry a1 = dropbox.getNextEntry("DropBoxTest.A", a0.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest.A", a1.getTimeMillis())); + + DropBoxManager.Entry b0 = dropbox.getNextEntry("DropBoxTest.B", before); + assertTrue(null == dropbox.getNextEntry("DropBoxTest.B", b0.getTimeMillis())); + + DropBoxManager.Entry x0 = dropbox.getNextEntry(null, before); + DropBoxManager.Entry x1 = dropbox.getNextEntry(null, x0.getTimeMillis()); + DropBoxManager.Entry x2 = dropbox.getNextEntry(null, x1.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry(null, x2.getTimeMillis())); + + assertEquals("DropBoxTest.A", a0.getTag()); + assertEquals("DropBoxTest.A", a1.getTag()); + assertEquals("A0", a0.getText(80)); + assertEquals("A1", a1.getText(80)); + + assertEquals("DropBoxTest.B", b0.getTag()); + assertEquals("B0", b0.getText(80)); + + assertEquals("DropBoxTest.A", x0.getTag()); + assertEquals("DropBoxTest.B", x1.getTag()); + assertEquals("DropBoxTest.A", x2.getTag()); + assertEquals("A0", x0.getText(80)); + assertEquals("B0", x1.getText(80)); + assertEquals("A1", x2.getText(80)); + + a0.close(); + a1.close(); + b0.close(); + x0.close(); + x1.close(); + x2.close(); + service.stop(); + } + + public void testSizeLimits() throws Exception { + File dir = getEmptyDir("testSizeLimits"); + int blockSize = new StatFs(dir.getPath()).getBlockSize(); + + // Limit storage to 10 blocks + int kb = blockSize * 10 / 1024; + ContentResolver cr = getContext().getContentResolver(); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_QUOTA_KB, Integer.toString(kb)); + + // Three tags using a total of 12 blocks: + // DropBoxTest0 [ ][ ] + // DropBoxTest1 [x][ ][ ][ ][xxx(20 blocks)xxx] + // DropBoxTest2 [xxxxxxxxxx][ ][ ] + // + // The blocks marked "x" will be removed due to storage restrictions. + // Use random fill (so it doesn't compress), subtract a little for gzip overhead + + final int overhead = 64; + long before = System.currentTimeMillis(); + DropBoxManagerService service = new DropBoxManagerService(getContext(), dir); + DropBoxManager dropbox = new DropBoxManager(service); + + addRandomEntry(dropbox, "DropBoxTest0", blockSize - overhead); + addRandomEntry(dropbox, "DropBoxTest0", blockSize - overhead); + + addRandomEntry(dropbox, "DropBoxTest1", blockSize - overhead); + addRandomEntry(dropbox, "DropBoxTest1", blockSize - overhead); + addRandomEntry(dropbox, "DropBoxTest1", blockSize * 2 - overhead); + addRandomEntry(dropbox, "DropBoxTest1", blockSize - overhead); + addRandomEntry(dropbox, "DropBoxTest1", blockSize * 20 - overhead); + + addRandomEntry(dropbox, "DropBoxTest2", blockSize * 4 - overhead); + addRandomEntry(dropbox, "DropBoxTest2", blockSize - overhead); + addRandomEntry(dropbox, "DropBoxTest2", blockSize - overhead); + + DropBoxManager.Entry e0 = dropbox.getNextEntry(null, before); + DropBoxManager.Entry e1 = dropbox.getNextEntry(null, e0.getTimeMillis()); + DropBoxManager.Entry e2 = dropbox.getNextEntry(null, e1.getTimeMillis()); + DropBoxManager.Entry e3 = dropbox.getNextEntry(null, e2.getTimeMillis()); + DropBoxManager.Entry e4 = dropbox.getNextEntry(null, e3.getTimeMillis()); + DropBoxManager.Entry e5 = dropbox.getNextEntry(null, e4.getTimeMillis()); + DropBoxManager.Entry e6 = dropbox.getNextEntry(null, e5.getTimeMillis()); + DropBoxManager.Entry e7 = dropbox.getNextEntry(null, e6.getTimeMillis()); + DropBoxManager.Entry e8 = dropbox.getNextEntry(null, e7.getTimeMillis()); + DropBoxManager.Entry e9 = dropbox.getNextEntry(null, e8.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry(null, e9.getTimeMillis())); + + assertEquals("DropBoxTest0", e0.getTag()); + assertEquals("DropBoxTest0", e1.getTag()); + assertEquals(blockSize - overhead, getEntrySize(e0)); + assertEquals(blockSize - overhead, getEntrySize(e1)); + + assertEquals("DropBoxTest1", e2.getTag()); + assertEquals("DropBoxTest1", e3.getTag()); + assertEquals("DropBoxTest1", e4.getTag()); + assertEquals("DropBoxTest1", e5.getTag()); + assertEquals("DropBoxTest1", e6.getTag()); + assertEquals(-1, getEntrySize(e2)); // Tombstone + assertEquals(blockSize - overhead, getEntrySize(e3)); + assertEquals(blockSize * 2 - overhead, getEntrySize(e4)); + assertEquals(blockSize - overhead, getEntrySize(e5)); + assertEquals(-1, getEntrySize(e6)); + + assertEquals("DropBoxTest2", e7.getTag()); + assertEquals("DropBoxTest2", e8.getTag()); + assertEquals("DropBoxTest2", e9.getTag()); + assertEquals(-1, getEntrySize(e7)); // Tombstone + assertEquals(blockSize - overhead, getEntrySize(e8)); + assertEquals(blockSize - overhead, getEntrySize(e9)); + + e0.close(); + e1.close(); + e2.close(); + e3.close(); + e4.close(); + e5.close(); + e6.close(); + e7.close(); + e8.close(); + e9.close(); + + // Specifying a tag name skips tombstone records. + + DropBoxManager.Entry t0 = dropbox.getNextEntry("DropBoxTest1", before); + DropBoxManager.Entry t1 = dropbox.getNextEntry("DropBoxTest1", t0.getTimeMillis()); + DropBoxManager.Entry t2 = dropbox.getNextEntry("DropBoxTest1", t1.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry("DropBoxTest1", t2.getTimeMillis())); + + assertEquals("DropBoxTest1", t0.getTag()); + assertEquals("DropBoxTest1", t1.getTag()); + assertEquals("DropBoxTest1", t2.getTag()); + + assertEquals(blockSize - overhead, getEntrySize(t0)); + assertEquals(blockSize * 2 - overhead, getEntrySize(t1)); + assertEquals(blockSize - overhead, getEntrySize(t2)); + + t0.close(); + t1.close(); + t2.close(); + service.stop(); + } + + public void testAgeLimits() throws Exception { + File dir = getEmptyDir("testAgeLimits"); + int blockSize = new StatFs(dir.getPath()).getBlockSize(); + + // Limit storage to 10 blocks with an expiration of 1 second + int kb = blockSize * 10 / 1024; + ContentResolver cr = getContext().getContentResolver(); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_AGE_SECONDS, "1"); + Settings.Secure.putString(cr, Settings.Secure.DROPBOX_QUOTA_KB, Integer.toString(kb)); + + // Write one normal entry and another so big that it is instantly tombstoned + long before = System.currentTimeMillis(); + DropBoxManagerService service = new DropBoxManagerService(getContext(), dir); + DropBoxManager dropbox = new DropBoxManager(service); + + dropbox.addText("DropBoxTest", "TEST"); + addRandomEntry(dropbox, "DropBoxTest", blockSize * 20); + + // Verify that things are as expected + DropBoxManager.Entry e0 = dropbox.getNextEntry(null, before); + DropBoxManager.Entry e1 = dropbox.getNextEntry(null, e0.getTimeMillis()); + assertTrue(null == dropbox.getNextEntry(null, e1.getTimeMillis())); + + assertEquals("TEST", e0.getText(80)); + assertEquals(null, e1.getText(80)); + assertEquals(-1, getEntrySize(e1)); + + e0.close(); + e1.close(); + + // Wait a second and write another entry -- old ones should be expunged + Thread.sleep(2000); + dropbox.addText("DropBoxTest", "TEST1"); + + e0 = dropbox.getNextEntry(null, before); + assertTrue(null == dropbox.getNextEntry(null, e0.getTimeMillis())); + assertEquals("TEST1", e0.getText(80)); + e0.close(); + } + + public void testCreateDropBoxManagerWithInvalidDirectory() throws Exception { + // If created with an invalid directory, the DropBoxManager should suffer quietly + // and fail all operations (this is how it survives a full disk). + // Once the directory becomes possible to create, it will start working. + + File dir = new File(getEmptyDir("testCreateDropBoxManagerWith"), "InvalidDirectory"); + new FileOutputStream(dir).close(); // Create an empty file + DropBoxManagerService service = new DropBoxManagerService(getContext(), dir); + DropBoxManager dropbox = new DropBoxManager(service); + + dropbox.addText("DropBoxTest", "should be ignored"); + dropbox.addData("DropBoxTest", "should be ignored".getBytes(), 0); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", 0)); + + dir.delete(); // Remove the file so a directory can be created + dropbox.addText("DropBoxTest", "TEST"); + DropBoxManager.Entry e = dropbox.getNextEntry("DropBoxTest", 0); + assertTrue(null == dropbox.getNextEntry("DropBoxTest", e.getTimeMillis())); + assertEquals("DropBoxTest", e.getTag()); + assertEquals("TEST", e.getText(80)); + e.close(); + service.stop(); + } + + private void addRandomEntry(DropBoxManager dropbox, String tag, int size) throws Exception { + byte[] bytes = new byte[size]; + new Random(System.currentTimeMillis()).nextBytes(bytes); + + File f = new File(getEmptyDir("addRandomEntry"), "random.dat"); + FileOutputStream os = new FileOutputStream(f); + os.write(bytes); + os.close(); + + dropbox.addFile(tag, f, 0); + } + + private int getEntrySize(DropBoxManager.Entry e) throws Exception { + InputStream is = e.getInputStream(); + if (is == null) return -1; + int length = 0; + while (is.read() != -1) length++; + return length; + } + + private void recursiveDelete(File file) { + if (!file.delete() && file.isDirectory()) { + for (File f : file.listFiles()) recursiveDelete(f); + file.delete(); + } + } + + private File getEmptyDir(String name) { + File dir = getContext().getDir("DropBoxTest." + name, 0); + for (File f : dir.listFiles()) recursiveDelete(f); + assertTrue(dir.listFiles().length == 0); + return dir; + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/GDataParseTest.java b/tests/AndroidTests/src/com/android/unit_tests/GDataParseTest.java deleted file mode 100644 index af85483..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/GDataParseTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.content.res.XmlResourceParser; -import android.test.AndroidTestCase; -import android.test.PerformanceTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.Xml; -import com.google.wireless.gdata.data.Entry; -import com.google.wireless.gdata.data.Feed; -import com.google.wireless.gdata.parser.ParseException; -import com.google.wireless.gdata.parser.xml.XmlGDataParser; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.GZIPInputStream; - -/** - * Tests timing on parsing various formats of GData. - */ -public class GDataParseTest extends AndroidTestCase implements PerformanceTestCase { - - private static void parseXml(InputStream is) throws ParseException, IOException { - XmlPullParser xmlParser = Xml.newPullParser(); - XmlGDataParser parser = new XmlGDataParser(is, xmlParser); - Feed feed = parser.init(); - Entry entry = null; - while (parser.hasMoreData()) { - entry = parser.readNextEntry(entry); - } - } - - private static void parseXml(XmlPullParser xmlP) throws ParseException, IOException { - XmlGDataParser parser = new XmlGDataParser(null /* in */, xmlP); - Feed feed = parser.init(); - Entry entry = null; - while (parser.hasMoreData()) { - entry = parser.readNextEntry(entry); - } - } - - private static void dumpXml(XmlPullParser parser) throws - XmlPullParserException, IOException { - int eventType = parser.nextTag(); - while (eventType != XmlPullParser.END_DOCUMENT) { - switch (eventType) { - case XmlPullParser.START_TAG: - parser.getName(); - // System.out.print("<" + parser.getName()); - int nattrs = parser.getAttributeCount(); - for (int i = 0; i < nattrs; ++i) { - parser.getAttributeName(i); - parser.getAttributeValue(i); - // System.out.print(" " + parser.getAttributeName(i) + "=\"" - // + parser.getAttributeValue(i) + "\""); - } - // System.out.print(">"); - break; - case XmlPullParser.END_TAG: - parser.getName(); - // System.out.print("</" + parser.getName() + ">"); - break; - case XmlPullParser.TEXT: - parser.getText(); - // System.out.print(parser.getText()); - break; - default: - // do nothing - } - eventType = parser.next(); - } - } - - private byte[] getBytesForResource(int resid) throws Exception { - // all resources are written into a zip file, so the InputStream we - // get for a resource is on top of zipped - // data. in order to compare performance of parsing unzipped vs. - // zipped content, we first read the data into an in-memory buffer. - InputStream zipIs = null; - try { - zipIs = mContext.getResources().openRawResource(resid); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte buf[] = new byte[1024]; - int bytesRead = zipIs.read(buf); - while (bytesRead > 0) { - baos.write(buf, 0, bytesRead); - bytesRead = zipIs.read(buf); - } - return baos.toByteArray(); - } finally { - if (zipIs != null) { - zipIs.close(); - } - } - } - - public boolean isPerformanceOnly() { - return true; - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - return 0; - } - - @MediumTest - public void testXml() throws Exception { - InputStream is = new ByteArrayInputStream(getBytesForResource(R.raw.calendarxml)); - try { - is.reset(); - parseXml(is); - } finally { - is.close(); - } - } - - @MediumTest - public void testXmlGzip() throws Exception { - InputStream gzIs = new GZIPInputStream( - new ByteArrayInputStream(getBytesForResource(R.raw.calendarxmlgz))); - try { - parseXml(gzIs); - } finally { - gzIs.close(); - } - } - - @MediumTest - public void testJson() throws Exception { - String jsonString = new String(getBytesForResource(R.raw.calendarjs), "UTF-8"); - JSONTokener tokens = new JSONTokener(jsonString); - assertNotNull(new JSONObject(tokens)); - } - - @SmallTest - public void testBinaryXml() throws Exception { - XmlResourceParser parser = mContext.getResources().getXml(R.xml.calendar); - parseXml(parser); - parser.close(); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/GoogleHttpClientTest.java b/tests/AndroidTests/src/com/android/unit_tests/GoogleHttpClientTest.java deleted file mode 100644 index d970de3..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/GoogleHttpClientTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.content.ContentResolver; -import android.net.http.AndroidHttpClient; -import android.provider.Checkin; -import android.provider.Settings; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.LargeTest; -import android.test.suitebuilder.annotation.MediumTest; - -import com.google.android.collect.Lists; -import com.google.android.net.GoogleHttpClient; - -import org.apache.http.HttpException; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HttpContext; -import org.apache.http.protocol.HttpRequestHandler; -import org.apache.http.util.EntityUtils; - -import java.io.IOException; - -/** Unit test for {@link GoogleHttpClient}. */ -public class GoogleHttpClientTest extends AndroidTestCase { - private TestHttpServer mServer; - private String mServerUrl; - - protected void setUp() throws Exception { - // Run a test server that echoes the URI back to the caller. - mServer = new TestHttpServer(); - mServer.registerHandler("*", new HttpRequestHandler() { - public void handle( - HttpRequest request, - HttpResponse response, - HttpContext context) throws HttpException, IOException { - String uri = request.getRequestLine().getUri(); - response.setEntity(new StringEntity(uri)); - } - }); - - mServer.start(); - mServerUrl = "http://localhost:" + mServer.getPort() + "/"; - } - - protected void tearDown() throws Exception { - if (mServer != null) mServer.shutdown(); - } - - @LargeTest - public void testThreadCheck() throws Exception { - ContentResolver resolver = getContext().getContentResolver(); - GoogleHttpClient client = new GoogleHttpClient(resolver, "Test", - false /* no gzip */); - - try { - // Note: we must test against a real server, because the connection - // gets established before the interceptor can crash the request. - HttpGet method = new HttpGet(mServerUrl); - - // This is actually an AndroidHttpClient feature... - // TODO: somehow test that Activity threads have the flag set? - AndroidHttpClient.setThreadBlocked(true); - - try { - client.execute(method); - fail("\"thread forbids HTTP requests\" exception expected"); - } catch (RuntimeException e) { - if (!e.toString().contains("forbids HTTP requests")) throw e; - } finally { - AndroidHttpClient.setThreadBlocked(false); - } - - HttpResponse response = client.execute(method); - assertEquals("/", EntityUtils.toString(response.getEntity())); - } finally { - client.close(); - } - } - - @MediumTest - public void testUrlRewriteRules() throws Exception { - // Don't do anything exotic; UrlRulesTest checks the actual rewriter. - // Just make sure that URLs are, in fact, rewritten. - - // TODO: Use a MockContentProvider/MockContentResolver instead. - ContentResolver resolver = getContext().getContentResolver(); - GoogleHttpClient client = new GoogleHttpClient(resolver, "Test", - false /* not gzip capable */); - Settings.Gservices.putString(resolver, - "url:test", "http://foo.bar/ rewrite " + mServerUrl + "new/"); - - // Update the digest, so the UrlRules cache is reloaded. - Settings.Gservices.putString(resolver, "digest", mServerUrl); - - try { - HttpGet method = new HttpGet("http://foo.bar/path"); - HttpResponse response = client.execute(method); - String body = EntityUtils.toString(response.getEntity()); - assertEquals("/new/path", body); - } finally { - client.close(); - } - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/GoogleLoginServiceTest.java b/tests/AndroidTests/src/com/android/unit_tests/GoogleLoginServiceTest.java index 59f14bf..1d48030 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/GoogleLoginServiceTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/GoogleLoginServiceTest.java @@ -17,9 +17,9 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.Suppress; import android.util.Log; -import com.google.android.googleapps.GoogleLoginCredentialsResult; -import com.google.android.googleapps.IGoogleLoginService; -import com.google.android.googlelogin.GoogleLoginServiceConstants; +import com.google.android.gsf.GoogleLoginCredentialsResult; +import com.google.android.gsf.IGoogleLoginService; +import com.google.android.gsf.GoogleLoginServiceConstants; import junit.framework.Assert; @@ -60,8 +60,8 @@ public class GoogleLoginServiceTest extends AndroidTestCase { protected void setUp() throws Exception { super.setUp(); getContext().bindService((new Intent()) - .setClassName("com.google.android.googleapps", - "com.google.android.googleapps.GoogleLoginService"), + .setClassName("com.google.android.gsf", + "com.google.android.gsf.loginservice.GoogleLoginService"), mConnection, Context.BIND_AUTO_CREATE); // wait for the service to cnnnect diff --git a/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java b/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java deleted file mode 100644 index 7252aa9..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.unit_tests; - -import android.os.Parcel; -import android.test.AndroidTestCase; -import android.telephony.NeighboringCellInfo; -import android.test. suitebuilder.annotation.SmallTest; - -import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; -import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; -import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; -import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; - -public class NeighboringCellInfoTest extends AndroidTestCase { - @SmallTest - public void testConstructor() { - int rssi = 31; - NeighboringCellInfo nc; - - nc = new NeighboringCellInfo(rssi, "FFFFFFF", NETWORK_TYPE_EDGE); - assertEquals(NETWORK_TYPE_EDGE, nc.getNetworkType()); - assertEquals(rssi, nc.getRssi()); - assertEquals(0xfff, nc.getLac()); - assertEquals(0xffff, nc.getCid()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); - - nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UMTS); - assertEquals(NETWORK_TYPE_UMTS, nc.getNetworkType()); - assertEquals(rssi, nc.getRssi()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); - assertEquals(0x1ff, nc.getPsc()); - - nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UNKNOWN); - assertEquals(NETWORK_TYPE_UNKNOWN, nc.getNetworkType()); - assertEquals(rssi, nc.getRssi()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); - } - - @SmallTest - public void testParcel() { - int rssi = 20; - - NeighboringCellInfo nc = new NeighboringCellInfo(rssi, "12345678", NETWORK_TYPE_GPRS); - assertEquals(NETWORK_TYPE_GPRS, nc.getNetworkType()); - assertEquals(rssi, nc.getRssi()); - assertEquals(0x1234, nc.getLac()); - assertEquals(0x5678, nc.getCid()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); - - Parcel p = Parcel.obtain(); - p.setDataPosition(0); - nc.writeToParcel(p, 0); - - p.setDataPosition(0); - NeighboringCellInfo nw = new NeighboringCellInfo(p); - assertEquals(NETWORK_TYPE_GPRS, nw.getNetworkType()); - assertEquals(rssi, nw.getRssi()); - assertEquals(0x1234, nw.getLac()); - assertEquals(0x5678, nw.getCid()); - assertEquals(NeighboringCellInfo.UNKNOWN_CID, nw.getPsc()); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/RegexTest.java b/tests/AndroidTests/src/com/android/unit_tests/RegexTest.java deleted file mode 100644 index 8f55044..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/RegexTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.test.suitebuilder.annotation.SmallTest; -import android.text.util.Regex; -import junit.framework.TestCase; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class RegexTest extends TestCase { - - @SmallTest - public void testTldPattern() throws Exception { - boolean t; - - t = Regex.TOP_LEVEL_DOMAIN_PATTERN.matcher("com").matches(); - assertTrue("Missed valid TLD", t); - - t = Regex.TOP_LEVEL_DOMAIN_PATTERN.matcher("xer").matches(); - assertFalse("Matched invalid TLD!", t); - } - - @SmallTest - public void testUrlPattern() throws Exception { - boolean t; - - t = Regex.WEB_URL_PATTERN.matcher("http://www.google.com").matches(); - assertTrue("Valid URL", t); - - t = Regex.WEB_URL_PATTERN.matcher("ftp://www.example.com").matches(); - assertFalse("Matched invalid protocol", t); - - t = Regex.WEB_URL_PATTERN.matcher("http://www.example.com:8080").matches(); - assertTrue("Didn't match valid URL with port", t); - - t = Regex.WEB_URL_PATTERN.matcher("http://www.example.com:8080/?foo=bar").matches(); - assertTrue("Didn't match valid URL with port and query args", t); - - t = Regex.WEB_URL_PATTERN.matcher("http://www.example.com:8080/~user/?foo=bar").matches(); - assertTrue("Didn't match valid URL with ~", t); - } - - @SmallTest - public void testIpPattern() throws Exception { - boolean t; - - t = Regex.IP_ADDRESS_PATTERN.matcher("172.29.86.3").matches(); - assertTrue("Valid IP", t); - - t = Regex.IP_ADDRESS_PATTERN.matcher("1234.4321.9.9").matches(); - assertFalse("Invalid IP", t); - } - - @SmallTest - public void testDomainPattern() throws Exception { - boolean t; - - t = Regex.DOMAIN_NAME_PATTERN.matcher("mail.example.com").matches(); - assertTrue("Valid domain", t); - - t = Regex.DOMAIN_NAME_PATTERN.matcher("__+&42.xer").matches(); - assertFalse("Invalid domain", t); - } - - @SmallTest - public void testPhonePattern() throws Exception { - boolean t; - - t = Regex.PHONE_PATTERN.matcher("(919) 555-1212").matches(); - assertTrue("Valid phone", t); - - t = Regex.PHONE_PATTERN.matcher("2334 9323/54321").matches(); - assertFalse("Invalid phone", t); - - String[] tests = { - "Me: 16505551212 this\n", - "Me: 6505551212 this\n", - "Me: 5551212 this\n", - - "Me: 1-650-555-1212 this\n", - "Me: (650) 555-1212 this\n", - "Me: +1 (650) 555-1212 this\n", - "Me: +1-650-555-1212 this\n", - "Me: 650-555-1212 this\n", - "Me: 555-1212 this\n", - - "Me: 1.650.555.1212 this\n", - "Me: (650) 555.1212 this\n", - "Me: +1 (650) 555.1212 this\n", - "Me: +1.650.555.1212 this\n", - "Me: 650.555.1212 this\n", - "Me: 555.1212 this\n", - - "Me: 1 650 555 1212 this\n", - "Me: (650) 555 1212 this\n", - "Me: +1 (650) 555 1212 this\n", - "Me: +1 650 555 1212 this\n", - "Me: 650 555 1212 this\n", - "Me: 555 1212 this\n", - }; - - for (String test : tests) { - Matcher m = Regex.PHONE_PATTERN.matcher(test); - - assertTrue("Valid phone " + test, m.find()); - } - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/SSLClientSessionCacheFactoryTest.java b/tests/AndroidTests/src/com/android/unit_tests/SSLClientSessionCacheFactoryTest.java deleted file mode 100644 index 5d7349f..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/SSLClientSessionCacheFactoryTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.android.unit_tests; - -import com.google.android.net.SSLClientSessionCacheFactory; -import com.android.internal.net.DbSSLSessionCache; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.content.ContentResolver; -import android.content.Context; -import android.provider.Settings; -import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache; - -/** - * Unit test for {@link SSLClientSessionCacheFactory}. - */ -@MediumTest -public final class SSLClientSessionCacheFactoryTest extends AndroidTestCase { - - protected void tearDown() throws Exception { - setSslSessionCacheValue(getContext(), ""); - super.tearDown(); - } - - private static void setSslSessionCacheValue(Context context, String value) { - ContentResolver resolver = context.getContentResolver(); - Settings.Gservices.putString(resolver, Settings.Gservices.SSL_SESSION_CACHE, value); - } - - private static SSLClientSessionCache getCache(Context context, String type) { - setSslSessionCacheValue(context, type); - return SSLClientSessionCacheFactory.getCache(context); - } - - public void testGetDbCache() throws Exception { - Context context = getContext(); - SSLClientSessionCache cache = getCache(context, "db"); - assertNotNull(cache); - assertTrue(cache instanceof DbSSLSessionCache); - } - - public void testGetFileCache() throws Exception { - Context context = getContext(); - SSLClientSessionCache cache = getCache(context, "file"); - assertNotNull(cache); - // yuck =) - assertEquals("org.apache.harmony.xnet.provider.jsse.FileClientSessionCache$Impl", - cache.getClass().getName()); - } - - public void testGetNoCache() throws Exception { - Context context = getContext(); - SSLClientSessionCache cache = getCache(context, "none"); - assertNull(cache); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/SafeSaxTest.java b/tests/AndroidTests/src/com/android/unit_tests/SafeSaxTest.java index d488a29..8ccd26e 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/SafeSaxTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/SafeSaxTest.java @@ -29,7 +29,7 @@ import android.test.suitebuilder.annotation.SmallTest; import android.text.format.Time; import android.util.Log; import android.util.Xml; -import com.android.internal.util.XmlUtils; +import com.android.common.XmlUtils; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; diff --git a/tests/AndroidTests/src/com/android/unit_tests/SearchManagerTest.java b/tests/AndroidTests/src/com/android/unit_tests/SearchManagerTest.java index e48a57b..6f6f55d 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/SearchManagerTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/SearchManagerTest.java @@ -21,10 +21,10 @@ import com.android.unit_tests.activity.LocalActivity; import android.app.Activity; import android.app.ISearchManager; import android.app.SearchManager; +import android.app.SearchableInfo; import android.content.ComponentName; import android.content.Context; import android.os.ServiceManager; -import android.server.search.SearchableInfo; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; diff --git a/tests/AndroidTests/src/com/android/unit_tests/SearchablesTest.java b/tests/AndroidTests/src/com/android/unit_tests/SearchablesTest.java index 4e5f7a9..972559d 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/SearchablesTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/SearchablesTest.java @@ -17,6 +17,8 @@ package com.android.unit_tests; import android.app.SearchManager; +import android.app.SearchableInfo; +import android.app.SearchableInfo.ActionKeyInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -28,9 +30,7 @@ import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.os.RemoteException; -import android.server.search.SearchableInfo; import android.server.search.Searchables; -import android.server.search.SearchableInfo.ActionKeyInfo; import android.test.AndroidTestCase; import android.test.MoreAsserts; import android.test.mock.MockContext; diff --git a/tests/AndroidTests/src/com/android/unit_tests/SettingsProviderTest.java b/tests/AndroidTests/src/com/android/unit_tests/SettingsProviderTest.java index 8b1db97..7d828ec 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/SettingsProviderTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/SettingsProviderTest.java @@ -31,16 +31,16 @@ public class SettingsProviderTest extends AndroidTestCase { @MediumTest public void testNameValueCache() { ContentResolver r = getContext().getContentResolver(); - Settings.Gservices.putString(r, "test_service", "Value"); - assertEquals("Value", Settings.Gservices.getString(r, "test_service")); + Settings.Secure.putString(r, "test_service", "Value"); + assertEquals("Value", Settings.Secure.getString(r, "test_service")); // Make sure the value can be overwritten. - Settings.Gservices.putString(r, "test_service", "New"); - assertEquals("New", Settings.Gservices.getString(r, "test_service")); + Settings.Secure.putString(r, "test_service", "New"); + assertEquals("New", Settings.Secure.getString(r, "test_service")); // Also that delete works. - assertEquals(1, r.delete(Settings.Gservices.getUriFor("test_service"), null, null)); - assertEquals(null, Settings.Gservices.getString(r, "test_service")); + assertEquals(1, r.delete(Settings.Secure.getUriFor("test_service"), null, null)); + assertEquals(null, Settings.Secure.getString(r, "test_service")); // Try all the same things in the System table Settings.System.putString(r, "test_setting", "Value"); @@ -60,10 +60,10 @@ public class SettingsProviderTest extends AndroidTestCase { assertEquals("content://settings/system/test_setting", Settings.System.getUriFor("test_setting").toString()); assertEquals("content://settings/gservices/test_service", - Settings.Gservices.getUriFor("test_service").toString()); + Settings.Secure.getUriFor("test_service").toString()); // These tables use the row name (not ID) as their content URI. - Uri tables[] = { Settings.System.CONTENT_URI, Settings.Gservices.CONTENT_URI }; + Uri tables[] = { Settings.System.CONTENT_URI, Settings.Secure.CONTENT_URI }; for (Uri table : tables) { ContentValues v = new ContentValues(); v.put(Settings.System.NAME, "test_key"); @@ -119,7 +119,7 @@ public class SettingsProviderTest extends AndroidTestCase { } assertEquals(null, Settings.System.getString(r, "test_key")); - assertEquals(null, Settings.Gservices.getString(r, "test_key")); + assertEquals(null, Settings.Secure.getString(r, "test_key")); } @MediumTest diff --git a/tests/AndroidTests/src/com/android/unit_tests/SimplePullParserTest.java b/tests/AndroidTests/src/com/android/unit_tests/SimplePullParserTest.java deleted file mode 100644 index 9758298..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/SimplePullParserTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import com.google.android.util.SimplePullParser; -import junit.framework.TestCase; -import android.test.suitebuilder.annotation.SmallTest; - -public class SimplePullParserTest extends TestCase { - @SmallTest - public void testTwoLevels() throws Exception { - String xml = "" - + "<top a='1' b='hello'>\n" - + " <next c='2' d='there'/>\n" - + " <next c='3' d='bye'/>\n" - + "</top>"; - SimplePullParser parser = new SimplePullParser(xml); - int depth0 = parser.getDepth(); - assertEquals(0, depth0); - assertEquals("top", parser.nextTag(depth0)); - assertEquals(1, parser.getIntAttribute(null, "a")); - assertEquals("hello", parser.getStringAttribute(null, "b")); - - int depth1 = parser.getDepth(); - assertEquals(1, depth1); - assertEquals("next", parser.nextTag(depth1)); - assertEquals(2, parser.getIntAttribute(null, "c")); - assertEquals("there", parser.getStringAttribute(null, "d")); - assertEquals("next", parser.nextTag(depth1)); - assertEquals(3, parser.getIntAttribute(null, "c")); - assertEquals("bye", parser.getStringAttribute(null, "d")); - assertNull(parser.nextTag(depth1)); - - assertNull(parser.nextTag(depth0)); - } - - @SmallTest - public void testAttributes() throws Exception { - String xml = "<top a='1' b='hello'/>"; - SimplePullParser parser = new SimplePullParser(xml); - int depth = parser.getDepth(); - parser.nextTag(depth); - - assertEquals(2, parser.numAttributes()); - assertEquals("a", parser.getAttributeName(0)); - assertEquals("b", parser.getAttributeName(1)); - - assertEquals(1, parser.getIntAttribute(null, "a")); - assertEquals(5, parser.getIntAttribute(null, "c", 5)); - assertEquals("hello", parser.getStringAttribute(null, "b")); - assertEquals("not", parser.getStringAttribute(null, "d", "not")); - } - - @SmallTest - public void testRecovery() throws Exception { - String xml = "" - + "<top a='1' b='hello'>\n" - + " <middle c='2' d='there'>\n" - + " <inner/>\n" - + " <inner2/>\n" - + " <inner3/>\n" - + " </middle>\n" - + " <middle2/>\n" - + "</top>"; - SimplePullParser parser = new SimplePullParser(xml); - assertEquals(0, parser.getDepth()); - assertEquals("top", parser.nextTag(0)); - assertEquals(1, parser.getDepth()); - assertEquals("middle", parser.nextTag(1)); - assertEquals(2, parser.getDepth()); - assertEquals("inner", parser.nextTag(2)); - // Now skip some elements. - assertEquals("middle2", parser.nextTag(1)); - } - - @SmallTest - public void testCdata() throws Exception { - StringBuilder cdataBuilder; - String xml = "" - + "<top>" - + "<![CDATA[data0]]>" - + "<next0/>" - + "<![CDATA[data1]]>" - + "<next1/>" - + "<![CDATA[data2]]>" - + "<next2/>" - + "<![CDATA[data3]]>" - + "<next3/>" - + "<![CDATA[data4]]>" - + "<next4/>" - + "<![CDATA[data5]]>" - + "</top>"; - SimplePullParser parser = new SimplePullParser(xml); - assertEquals("top", parser.nextTag(0)); - - // We can ignore cdata by not passing a cdata builder. - assertEquals("next0", parser.nextTag(1)); - - // We can get the most recent cdata by passing an empty cdata builder. - cdataBuilder = new StringBuilder(); - assertSame(SimplePullParser.TEXT_TAG, parser.nextTagOrText(1, cdataBuilder)); - assertEquals("data1", cdataBuilder.toString()); - assertEquals("next1", parser.nextTag(1)); - - // We can join multiple cdatas by reusing a builder. - cdataBuilder = new StringBuilder(); - assertSame(SimplePullParser.TEXT_TAG, parser.nextTagOrText(1, cdataBuilder)); - assertEquals("next2", parser.nextTag(1)); - assertSame(SimplePullParser.TEXT_TAG, parser.nextTagOrText(1, cdataBuilder)); - assertEquals("data2data3", cdataBuilder.toString()); - assertEquals("next3", parser.nextTag(1)); - - // We can read all of the remaining cdata while ignoring any elements. - cdataBuilder = new StringBuilder(); - parser.readRemainingText(1, cdataBuilder); - assertEquals("data4data5", cdataBuilder.toString()); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/TestHttpServer.java b/tests/AndroidTests/src/com/android/unit_tests/TestHttpServer.java deleted file mode 100644 index aae21b3..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/TestHttpServer.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * $HeadURL: http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha6/module-main/src/test/java/org/apache/http/mockup/TestHttpServer.java $ - * $Revision: 576077 $ - * $Date: 2007-09-16 04:50:22 -0700 (Sun, 16 Sep 2007) $ - * - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - */ - -package com.android.unit_tests; - - -import java.io.IOException; -import java.io.InterruptedIOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; - -import org.apache.http.ConnectionClosedException; -import org.apache.http.ConnectionReuseStrategy; -import org.apache.http.HttpException; -import org.apache.http.HttpResponseFactory; -import org.apache.http.HttpServerConnection; -import org.apache.http.impl.DefaultConnectionReuseStrategy; -import org.apache.http.impl.DefaultHttpResponseFactory; -import org.apache.http.impl.DefaultHttpServerConnection; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpParams; -import org.apache.http.params.CoreProtocolPNames; -import org.apache.http.protocol.BasicHttpProcessor; -import org.apache.http.protocol.HttpContext; -import org.apache.http.protocol.BasicHttpContext; -import org.apache.http.protocol.HttpExpectationVerifier; -import org.apache.http.protocol.HttpRequestHandler; -import org.apache.http.protocol.HttpRequestHandlerRegistry; -import org.apache.http.protocol.HttpService; -import org.apache.http.protocol.ResponseConnControl; -import org.apache.http.protocol.ResponseContent; -import org.apache.http.protocol.ResponseDate; -import org.apache.http.protocol.ResponseServer; - -public class TestHttpServer { - - private final HttpParams params; - private final BasicHttpProcessor httpproc; - private final ConnectionReuseStrategy connStrategy; - private final HttpResponseFactory responseFactory; - private final HttpRequestHandlerRegistry reqistry; - private final ServerSocket serversocket; - - private HttpExpectationVerifier expectationVerifier; - - private Thread listener; - private volatile boolean shutdown; - - public TestHttpServer() throws IOException { - super(); - this.params = new BasicHttpParams(); - this.params - .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20000) - .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) - .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false) - .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) - .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1"); - this.httpproc = new BasicHttpProcessor(); - this.httpproc.addInterceptor(new ResponseDate()); - this.httpproc.addInterceptor(new ResponseServer()); - this.httpproc.addInterceptor(new ResponseContent()); - this.httpproc.addInterceptor(new ResponseConnControl()); - this.connStrategy = new DefaultConnectionReuseStrategy(); - this.responseFactory = new DefaultHttpResponseFactory(); - this.reqistry = new HttpRequestHandlerRegistry(); - this.serversocket = new ServerSocket(0); - } - - public void registerHandler( - final String pattern, - final HttpRequestHandler handler) { - this.reqistry.register(pattern, handler); - } - - public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) { - this.expectationVerifier = expectationVerifier; - } - - private HttpServerConnection acceptConnection() throws IOException { - Socket socket = this.serversocket.accept(); - DefaultHttpServerConnection conn = new DefaultHttpServerConnection(); - conn.bind(socket, this.params); - return conn; - } - - public int getPort() { - return this.serversocket.getLocalPort(); - } - - public InetAddress getInetAddress() { - return this.serversocket.getInetAddress(); - } - - public void start() { - if (this.listener != null) { - throw new IllegalStateException("Listener already running"); - } - this.listener = new Thread(new Runnable() { - - public void run() { - while (!shutdown && !Thread.interrupted()) { - try { - // Set up HTTP connection - HttpServerConnection conn = acceptConnection(); - // Set up the HTTP service - HttpService httpService = new HttpService( - httpproc, - connStrategy, - responseFactory); - httpService.setParams(params); - httpService.setExpectationVerifier(expectationVerifier); - httpService.setHandlerResolver(reqistry); - - // Start worker thread - Thread t = new WorkerThread(httpService, conn); - t.setDaemon(true); - t.start(); - } catch (InterruptedIOException ex) { - break; - } catch (IOException e) { - break; - } - } - } - - }); - this.listener.start(); - } - - public void shutdown() { - if (this.shutdown) { - return; - } - this.shutdown = true; - try { - this.serversocket.close(); - } catch (IOException ignore) {} - this.listener.interrupt(); - try { - this.listener.join(1000); - } catch (InterruptedException ignore) {} - } - - static class WorkerThread extends Thread { - - private final HttpService httpservice; - private final HttpServerConnection conn; - - public WorkerThread( - final HttpService httpservice, - final HttpServerConnection conn) { - super(); - this.httpservice = httpservice; - this.conn = conn; - } - - public void run() { - HttpContext context = new BasicHttpContext(null); - try { - while (!Thread.interrupted() && this.conn.isOpen()) { - this.httpservice.handleRequest(this.conn, context); - } - } catch (ConnectionClosedException ex) { - } catch (IOException ex) { - System.err.println("I/O error: " + ex.getMessage()); - } catch (HttpException ex) { - System.err.println("Unrecoverable HTTP protocol violation: " + ex.getMessage()); - } finally { - try { - this.conn.shutdown(); - } catch (IOException ignore) {} - } - } - - } - -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/TestHttpService.java b/tests/AndroidTests/src/com/android/unit_tests/TestHttpService.java deleted file mode 100644 index 6b57d13..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/TestHttpService.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * $HeadURL: http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha6/module-main/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java $ - * $Revision: 576073 $ - * $Date: 2007-09-16 03:53:13 -0700 (Sun, 16 Sep 2007) $ - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - */ - -package com.android.unit_tests; - -import org.apache.http.protocol.HttpExpectationVerifier; -import org.apache.http.protocol.HttpRequestHandler; -import android.test.PerformanceTestCase; -import android.test.suitebuilder.annotation.LargeTest; -import android.test.suitebuilder.annotation.MediumTest; - -import junit.framework.TestCase; - -import org.apache.http.Header; -import org.apache.http.HttpConnectionMetrics; -import org.apache.http.HttpEntity; -import org.apache.http.HttpEntityEnclosingRequest; -import org.apache.http.HttpException; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.HttpVersion; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.DefaultHttpClientConnection; -import org.apache.http.message.BasicHttpEntityEnclosingRequest; -import org.apache.http.message.BasicHttpRequest; -import org.apache.http.params.CoreProtocolPNames; -import org.apache.http.protocol.HttpContext; -import org.apache.http.util.EncodingUtils; -import org.apache.http.util.EntityUtils; - - -import java.io.IOException; -import java.net.Socket; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class TestHttpService extends TestCase implements PerformanceTestCase { - - public boolean isPerformanceOnly() { - // TODO Auto-generated method stub - return false; - } - - public int startPerformance(Intermediates intermediates) { - // TODO Auto-generated method stub - return 0; - } - - private TestHttpServer server; - private TestHttpClient client; - - protected void setUp() throws Exception { - this.server = new TestHttpServer(); - this.client = new TestHttpClient(); - } - - protected void tearDown() throws Exception { - if (server != null) { - this.server.shutdown(); - } - } - - /** - * This test case executes a series of simple GET requests - */ - @LargeTest - public void testSimpleBasicHttpRequests() throws Exception { - - int reqNo = 20; - - Random rnd = new Random(); - - // Prepare some random data - final List testData = new ArrayList(reqNo); - for (int i = 0; i < reqNo; i++) { - int size = rnd.nextInt(5000); - byte[] data = new byte[size]; - rnd.nextBytes(data); - testData.add(data); - } - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - String s = request.getRequestLine().getUri(); - if (s.startsWith("/?")) { - s = s.substring(2); - } - int index = Integer.parseInt(s); - byte[] data = (byte []) testData.get(index); - ByteArrayEntity entity = new ByteArrayEntity(data); - response.setEntity(entity); - } - - }); - - this.server.start(); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpRequest get = new BasicHttpRequest("GET", "/?" + r); - HttpResponse response = this.client.execute(get, host, conn); - byte[] received = EntityUtils.toByteArray(response.getEntity()); - byte[] expected = (byte[]) testData.get(r); - - assertEquals(expected.length, received.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(expected[i], received[i]); - } - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - - } finally { - conn.close(); - this.server.shutdown(); - } - } - - /** - * This test case executes a series of simple POST requests with content length - * delimited content. - */ - @LargeTest - public void testSimpleHttpPostsWithContentLength() throws Exception { - - int reqNo = 20; - - Random rnd = new Random(); - - // Prepare some random data - List testData = new ArrayList(reqNo); - for (int i = 0; i < reqNo; i++) { - int size = rnd.nextInt(5000); - byte[] data = new byte[size]; - rnd.nextBytes(data); - testData.add(data); - } - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - if (request instanceof HttpEntityEnclosingRequest) { - HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity(); - byte[] data = EntityUtils.toByteArray(incoming); - - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(false); - response.setEntity(outgoing); - } else { - StringEntity outgoing = new StringEntity("No content"); - response.setEntity(outgoing); - } - } - - }); - - this.server.start(); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/"); - byte[] data = (byte[]) testData.get(r); - ByteArrayEntity outgoing = new ByteArrayEntity(data); - post.setEntity(outgoing); - - HttpResponse response = this.client.execute(post, host, conn); - byte[] received = EntityUtils.toByteArray(response.getEntity()); - byte[] expected = (byte[]) testData.get(r); - - assertEquals(expected.length, received.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(expected[i], received[i]); - } - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - - } finally { - conn.close(); - this.server.shutdown(); - } - } - - /** - * This test case executes a series of simple POST requests with chunk - * coded content content. - */ - @LargeTest - public void testSimpleHttpPostsChunked() throws Exception { - - int reqNo = 20; - - Random rnd = new Random(); - - // Prepare some random data - List testData = new ArrayList(reqNo); - for (int i = 0; i < reqNo; i++) { - int size = rnd.nextInt(20000); - byte[] data = new byte[size]; - rnd.nextBytes(data); - testData.add(data); - } - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - if (request instanceof HttpEntityEnclosingRequest) { - HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity(); - byte[] data = EntityUtils.toByteArray(incoming); - - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(true); - response.setEntity(outgoing); - } else { - StringEntity outgoing = new StringEntity("No content"); - response.setEntity(outgoing); - } - } - - }); - - this.server.start(); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/"); - byte[] data = (byte[]) testData.get(r); - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(true); - post.setEntity(outgoing); - - HttpResponse response = this.client.execute(post, host, conn); - byte[] received = EntityUtils.toByteArray(response.getEntity()); - byte[] expected = (byte[]) testData.get(r); - - assertEquals(expected.length, received.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(expected[i], received[i]); - } - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - } finally { - conn.close(); - this.server.shutdown(); - } - } - - /** - * This test case executes a series of simple HTTP/1.0 POST requests. - */ - @LargeTest - public void testSimpleHttpPostsHTTP10() throws Exception { - - int reqNo = 20; - - Random rnd = new Random(); - - // Prepare some random data - List testData = new ArrayList(reqNo); - for (int i = 0; i < reqNo; i++) { - int size = rnd.nextInt(5000); - byte[] data = new byte[size]; - rnd.nextBytes(data); - testData.add(data); - } - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - if (request instanceof HttpEntityEnclosingRequest) { - HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity(); - byte[] data = EntityUtils.toByteArray(incoming); - - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(false); - response.setEntity(outgoing); - } else { - StringEntity outgoing = new StringEntity("No content"); - response.setEntity(outgoing); - } - } - - }); - - this.server.start(); - - // Set protocol level to HTTP/1.0 - this.client.getParams().setParameter( - CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/"); - byte[] data = (byte[]) testData.get(r); - ByteArrayEntity outgoing = new ByteArrayEntity(data); - post.setEntity(outgoing); - - HttpResponse response = this.client.execute(post, host, conn); - assertEquals(HttpVersion.HTTP_1_0, response.getStatusLine().getProtocolVersion()); - byte[] received = EntityUtils.toByteArray(response.getEntity()); - byte[] expected = (byte[]) testData.get(r); - - assertEquals(expected.length, received.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(expected[i], received[i]); - } - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - } finally { - conn.close(); - this.server.shutdown(); - } - } - - /** - * This test case executes a series of simple POST requests using - * the 'expect: continue' handshake. - */ - @LargeTest - public void testHttpPostsWithExpectContinue() throws Exception { - - int reqNo = 20; - - Random rnd = new Random(); - - // Prepare some random data - List testData = new ArrayList(reqNo); - for (int i = 0; i < reqNo; i++) { - int size = rnd.nextInt(5000); - byte[] data = new byte[size]; - rnd.nextBytes(data); - testData.add(data); - } - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - if (request instanceof HttpEntityEnclosingRequest) { - HttpEntity incoming = ((HttpEntityEnclosingRequest) request).getEntity(); - byte[] data = EntityUtils.toByteArray(incoming); - - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(true); - response.setEntity(outgoing); - } else { - StringEntity outgoing = new StringEntity("No content"); - response.setEntity(outgoing); - } - } - - }); - - this.server.start(); - - // Activate 'expect: continue' handshake - this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/"); - byte[] data = (byte[]) testData.get(r); - ByteArrayEntity outgoing = new ByteArrayEntity(data); - outgoing.setChunked(true); - post.setEntity(outgoing); - - HttpResponse response = this.client.execute(post, host, conn); - byte[] received = EntityUtils.toByteArray(response.getEntity()); - byte[] expected = (byte[]) testData.get(r); - - assertEquals(expected.length, received.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(expected[i], received[i]); - } - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - } finally { - conn.close(); - this.server.shutdown(); - } - } - - - /** - * This test case executes a series of simple POST requests that do not - * meet the target server expectations. - */ - @LargeTest - public void testHttpPostsWithExpectationVerification() throws Exception { - - int reqNo = 3; - - // Initialize the server-side request handler - this.server.registerHandler("*", new HttpRequestHandler() { - - public void handle( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException, IOException { - - StringEntity outgoing = new StringEntity("No content"); - response.setEntity(outgoing); - } - - }); - - this.server.setExpectationVerifier(new HttpExpectationVerifier() { - - public void verify( - final HttpRequest request, - final HttpResponse response, - final HttpContext context) throws HttpException { - Header someheader = request.getFirstHeader("Secret"); - if (someheader != null) { - int secretNumber; - try { - secretNumber = Integer.parseInt(someheader.getValue()); - } catch (NumberFormatException ex) { - response.setStatusCode(HttpStatus.SC_BAD_REQUEST); - return; - } - if (secretNumber < 2) { - response.setStatusCode(HttpStatus.SC_EXPECTATION_FAILED); - ByteArrayEntity outgoing = new ByteArrayEntity( - EncodingUtils.getAsciiBytes("Wrong secret number")); - response.setEntity(outgoing); - } - } - } - - }); - - this.server.start(); - - // Activate 'expect: continue' handshake - this.client.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true); - - DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); - HttpHost host = new HttpHost("localhost", this.server.getPort()); - - try { - for (int r = 0; r < reqNo; r++) { - if (!conn.isOpen()) { - Socket socket = new Socket(host.getHostName(), host.getPort()); - conn.bind(socket, this.client.getParams()); - } - - BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/"); - post.addHeader("Secret", Integer.toString(r)); - ByteArrayEntity outgoing = new ByteArrayEntity( - EncodingUtils.getAsciiBytes("No content")); - post.setEntity(outgoing); - - HttpResponse response = this.client.execute(post, host, conn); - - HttpEntity entity = response.getEntity(); - assertNotNull(entity); - entity.consumeContent(); - - if (r < 2) { - assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode()); - } else { - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); - } - - if (!this.client.keepAlive(response)) { - conn.close(); - } - } - //Verify the connection metrics - HttpConnectionMetrics cm = conn.getMetrics(); - assertEquals(reqNo, cm.getRequestCount()); - assertEquals(reqNo, cm.getResponseCount()); - } finally { - conn.close(); - this.server.shutdown(); - } - } - -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java b/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java index 7720041..b194896 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java @@ -16,9 +16,6 @@ package com.android.unit_tests; -import com.google.android.collect.Lists; -import com.google.android.collect.Maps; - import android.graphics.Paint; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.SmallTest; @@ -29,9 +26,12 @@ import android.text.SpannedString; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.StyleSpan; -import android.text.util.Rfc822Validator; import android.test.MoreAsserts; +import com.android.common.Rfc822Validator; +import com.google.android.collect.Lists; +import com.google.android.collect.Maps; + import junit.framework.TestCase; import java.util.List; diff --git a/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java b/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java index 3b33a99..724ef6a 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/TimeTest.java @@ -359,56 +359,58 @@ public class TimeTest extends TestCase { Time t = new Time(Time.TIMEZONE_UTC); t.parse3339("1980-05-23"); - if (!t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23) { + if (!t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23) { fail("Did not parse all-day date correctly"); } t.parse3339("1980-05-23T09:50:50"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) { fail("Did not parse timezone-offset-less date correctly"); } t.parse3339("1980-05-23T09:50:50Z"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) { fail("Did not parse UTC date correctly"); } t.parse3339("1980-05-23T09:50:50.0Z"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) { fail("Did not parse UTC date correctly"); } t.parse3339("1980-05-23T09:50:50.12Z"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) { fail("Did not parse UTC date correctly"); } t.parse3339("1980-05-23T09:50:50.123Z"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) { fail("Did not parse UTC date correctly"); } - t.parse3339("1980-05-23T09:50:50-06:00"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || - t.hour != 9 || t.minute != 50 || t.second != 50 || - t.gmtoff != -6*3600) { + // The time should be normalized to UTC + t.parse3339("1980-05-23T09:50:50-01:05"); + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || + t.hour != 10 || t.minute != 55 || t.second != 50 || + t.gmtoff != 0) { fail("Did not parse timezone-offset date correctly"); } - t.parse3339("1980-05-23T09:50:50.123-06:00"); - if (t.allDay || t.year != 1980 || t.month != 05 || t.monthDay != 23 || - t.hour != 9 || t.minute != 50 || t.second != 50 || - t.gmtoff != -6*3600) { + // The time should be normalized to UTC + t.parse3339("1980-05-23T09:50:50.123-01:05"); + if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || + t.hour != 10 || t.minute != 55 || t.second != 50 || + t.gmtoff != 0) { fail("Did not parse timezone-offset date correctly"); } diff --git a/tests/AndroidTests/src/com/android/unit_tests/UriTest.java b/tests/AndroidTests/src/com/android/unit_tests/UriTest.java index d17e2c3..42066d9 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/UriTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/UriTest.java @@ -541,4 +541,33 @@ public class UriTest extends TestCase { assertEquals(nestedUrl, Uri.decode(uri.getQueryParameters("nested").get(0))); } + + public void testGetQueryParameterEdgeCases() { + Uri uri; + + // key at beginning of URL + uri = Uri.parse("http://test/").buildUpon() + .appendQueryParameter("key", "a b") + .appendQueryParameter("keya", "c d") + .appendQueryParameter("bkey", "e f") + .build(); + assertEquals("a b", uri.getQueryParameter("key")); + + // key in middle of URL + uri = Uri.parse("http://test/").buildUpon() + .appendQueryParameter("akeyb", "a b") + .appendQueryParameter("keya", "c d") + .appendQueryParameter("key", "e f") + .appendQueryParameter("bkey", "g h") + .build(); + assertEquals("e f", uri.getQueryParameter("key")); + + // key at end of URL + uri = Uri.parse("http://test/").buildUpon() + .appendQueryParameter("akeyb", "a b") + .appendQueryParameter("keya", "c d") + .appendQueryParameter("key", "y z") + .build(); + assertEquals("y z", uri.getQueryParameter("key")); + } } diff --git a/tests/AndroidTests/src/com/android/unit_tests/UrlRulesTest.java b/tests/AndroidTests/src/com/android/unit_tests/UrlRulesTest.java deleted file mode 100644 index a7c19a7..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/UrlRulesTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests; - -import android.content.ContentResolver; -import android.provider.Settings; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; - -import com.google.android.net.UrlRules; -import static com.google.android.net.UrlRules.Rule; - -/** Test loading and matching URL rewrite rules for UrlRules. */ -public class UrlRulesTest extends AndroidTestCase { - @SmallTest - public void testEmptyRules() { - UrlRules rules = new UrlRules(new Rule[] { }); - assertTrue(rules.matchRule("http://foo.bar/") == Rule.DEFAULT); - } - - @SmallTest - public void testInvalidRule() throws Exception { - try { - new Rule("rule", "foo bar"); - } catch (Exception e) { - // Re-throw any exception except the one we're looking for. - if (!e.toString().contains("Illegal rule: foo bar")) throw e; - } - } - - @SmallTest - public void testRewriteRule() throws UrlRules.RuleFormatException { - Rule rule = new Rule("test_rule", - "http://foo.bar/ rewrite http://bar.foo/"); - assertEquals("test_rule", rule.mName); - assertEquals("http://foo.bar/", rule.mPrefix); - assertEquals("http://bar.foo/", rule.mRewrite); - assertFalse(rule.mBlock); - assertEquals("http://bar.foo/bat", rule.apply("http://foo.bar/bat")); - } - - @SmallTest - public void testBlockRule() throws UrlRules.RuleFormatException { - Rule rule = new Rule("test_rule", - "http://foo.bar/ block"); - assertEquals("test_rule", rule.mName); - assertEquals("http://foo.bar/", rule.mPrefix); - assertTrue(rule.mRewrite == null); - assertTrue(rule.mBlock); - assertTrue(rule.apply("http://foo.bar/bat") == null); - } - - @SmallTest - public void testMatchRule() throws UrlRules.RuleFormatException { - UrlRules rules = new UrlRules(new Rule[] { - new Rule("12", "http://one.two/ rewrite http://buckle.my.shoe/"), - new Rule("34", "http://three.four/ rewrite http://close.the.door/"), - new Rule("56", "http://five.six/ rewrite http://pick.up.sticks/"), - }); - - assertTrue(rules.matchRule("https://one.two/") == Rule.DEFAULT); - assertTrue(rules.matchRule("http://one.two") == Rule.DEFAULT); - assertEquals("12", rules.matchRule("http://one.two/foo").mName); - - String u = "http://five.six/bar"; - assertEquals("http://pick.up.sticks/bar", rules.matchRule(u).apply(u)); - } - - @SmallTest - public void testAmbiguousMatch() throws UrlRules.RuleFormatException { - // Rule is the longest match wins. - UrlRules rules = new UrlRules(new Rule[] { - new Rule("1", "http://xyz/one rewrite http://rewrite/"), - new Rule("123", "http://xyz/onetwothree rewrite http://rewrite/"), - new Rule("12", "http://xyz/onetwo rewrite http://rewrite/"), - }); - - assertEquals("1", rules.matchRule("http://xyz/one").mName); - assertEquals("1", rules.matchRule("http://xyz/one...").mName); - assertEquals("12", rules.matchRule("http://xyz/onetwo...").mName); - assertEquals("123", rules.matchRule("http://xyz/onetwothree...").mName); - - } - - @MediumTest - public void testGservicesRules() { - // TODO: use a MockContentProvider/MockContentResolver instead. - ContentResolver r = getContext().getContentResolver(); - - // Update the digest, so the UrlRules cache is reloaded. - Settings.Gservices.putString(r, "digest", "testGservicesRules"); - Settings.Gservices.putString(r, "url:blank_test", ""); - Settings.Gservices.putString(r, "url:test", - "http://foo.bar/ rewrite http://bar.foo/"); - - UrlRules rules = UrlRules.getRules(r); // Don't crash, please. :) - assertTrue(rules.matchRule("http://bar.foo/") == Rule.DEFAULT); - - Rule rule = rules.matchRule("http://foo.bar/bat"); - assertEquals("test", rule.mName); - assertEquals("http://foo.bar/", rule.mPrefix); - assertEquals("http://bar.foo/", rule.mRewrite); - assertFalse(rule.mBlock); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ArrayTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/ArrayTest.java deleted file mode 100644 index 4d5b5e7..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ArrayTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.Resources; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.TypedValue; -import com.android.unit_tests.R; - -public class ArrayTest extends AndroidTestCase { - private Resources mResources; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); - } - - private void checkEntry(int resid, int index, Object res, Object expected) { - assertEquals("in resource 0x" + Integer.toHexString(resid) - + " at index " + index, expected, res); - } - - private void checkStringArray(int resid, String[] expected) { - String[] res = mResources.getStringArray(resid); - assertEquals(res.length, expected.length); - for (int i=0; i<expected.length; i++) { - checkEntry(resid, i, res[i], expected[i]); - } - } - - private void checkTextArray(int resid, String[] expected) { - CharSequence[] res = mResources.getTextArray(resid); - assertEquals(res.length, expected.length); - for (int i=0; i<expected.length; i++) { - checkEntry(resid, i, res[i], expected[i]); - } - } - - private void checkIntArray(int resid, int[] expected) { - int[] res = mResources.getIntArray(resid); - assertEquals(res.length, expected.length); - for (int i=0; i<expected.length; i++) { - assertEquals("in resource 0x" + Integer.toHexString(resid) - + " at index " + i, expected[i], res[i]); - } - } - - @SmallTest - public void testStrings() throws Exception { - checkStringArray(R.array.strings, new String[] {"zero", "1", "here"}); - checkTextArray(R.array.strings, new String[] {"zero", "1", "here"}); - checkStringArray(R.array.integers, new String[] {null, null, null}); - checkTextArray(R.array.integers, new String[] {null, null, null}); - } - - @SmallTest - public void testIntegers() throws Exception { - checkIntArray(R.array.strings, new int[] {0, 0, 0}); - checkIntArray(R.array.integers, new int[] {0, 1, 101}); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java deleted file mode 100644 index a065d70..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.Context; -import android.content.res.AssetManager; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.DisplayMetrics; -import android.view.Display; -import android.view.WindowManager; -import com.android.unit_tests.R; - -import java.util.Locale; - -public class ConfigTest extends AndroidTestCase { - enum properties { - LANGUAGE, - COUNTRY, - MCC, - MNC, - TOUCHSCREEN, - KEYBOARD, - KEYBOARDHIDDEN, - NAVIGATION, - ORIENTATION, - WIDTH, - HEIGHT, - DENSITY - } - - private static void checkValue(Resources res, int resId, String expectedValue) { - try { - String actual = res.getString(resId); - assertNotNull("Returned wrong configuration-based simple value: expected <nothing>, got '" - + actual + "' from resource 0x" - + Integer.toHexString(resId), - expectedValue); - assertEquals("Returned wrong configuration-based simple value: expected '" - + expectedValue + "', got '" + actual + "' from resource 0x" - + Integer.toHexString(resId), - expectedValue, actual); - } catch (Resources.NotFoundException e) { - assertNull("Resource not found for configuration-based simple value: expecting \"" - + expectedValue + "\"", - expectedValue); - } - } - - private static void checkValue(Resources res, int resId, - int[] styleable, String[] expectedValues) { - Resources.Theme theme = res.newTheme(); - TypedArray sa = theme.obtainStyledAttributes(resId, styleable); - for (int i = 0; i < styleable.length; i++) { - String actual = sa.getString(i); - assertEquals("Returned wrong configuration-based style value: expected '" - + expectedValues[i] + "', got '" + actual + "' from attr " - + i + " of resource 0x" + Integer.toHexString(resId), - actual, expectedValues[i]); - } - sa.recycle(); - } - - class TotalConfig { - Configuration mConfig; - DisplayMetrics mMetrics; - - TotalConfig() { - mConfig = new Configuration(); - // don't rely on build settings - they may change - mConfig.locale = new Locale("en", "US"); - mConfig.mcc = 310; - mConfig.mnc = 001; // unused - mConfig.touchscreen = Configuration.TOUCHSCREEN_FINGER; - mConfig.keyboard = Configuration.KEYBOARD_QWERTY; - mConfig.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; - mConfig.navigation = Configuration.NAVIGATION_TRACKBALL; - mConfig.orientation = Configuration.ORIENTATION_PORTRAIT; - - mMetrics = new DisplayMetrics(); - mMetrics.widthPixels = 200; - mMetrics.heightPixels = 320; - mMetrics.density = 1; - } - - void setProperty(properties p, int value) { - switch(p) { - case MCC: - mConfig.mcc = value; - break; - case MNC: - mConfig.mnc = value; - break; - case TOUCHSCREEN: - mConfig.touchscreen = value; - break; - case KEYBOARD: - mConfig.keyboard = value; - break; - case KEYBOARDHIDDEN: - mConfig.keyboardHidden = value; - break; - case NAVIGATION: - mConfig.navigation = value; - break; - case ORIENTATION: - mConfig.orientation = value; - break; - case WIDTH: - mMetrics.widthPixels = value; - break; - case HEIGHT: - mMetrics.heightPixels = value; - break; - case DENSITY: - // this is the ratio from the standard - - mMetrics.density = (((float)value)/((float)DisplayMetrics.DENSITY_DEFAULT)); - break; - default: - assert(false); - break; - } - } - - public void setProperty(properties p, String value) { - switch(p) { - case LANGUAGE: - String oldCountry = mConfig.locale.getCountry(); - mConfig.locale = new Locale(value, oldCountry); - break; - case COUNTRY: - String oldLanguage = mConfig.locale.getLanguage(); - mConfig.locale = new Locale(oldLanguage, value); - break; - default: - assert(false); - break; - } - } - - public Resources getResources() { - AssetManager assmgr = new AssetManager(); - assmgr.addAssetPath(mContext.getPackageResourcePath()); - return new Resources(assmgr, mMetrics, mConfig); - } - } - - private static void checkPair(Resources res, int[] notResIds, - int simpleRes, String simpleString, - int bagRes, String bagString) { - boolean willHave = true; - if (notResIds != null) { - for (int i : notResIds) { - if (i == simpleRes) { - willHave = false; - break; - } - } - } - checkValue(res, simpleRes, willHave ? simpleString : null); - checkValue(res, bagRes, R.styleable.TestConfig, - new String[]{willHave ? bagString : null}); - } - - @SmallTest - public void testAllConfigs() throws Exception { - /** - * Test a resource that contains a value for each possible single - * configuration value. - */ - TotalConfig config = new TotalConfig(); - Resources res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - - config = new TotalConfig(); - config.setProperty(properties.LANGUAGE, "xx"); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple xx"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx"}); - - config = new TotalConfig(); - config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.COUNTRY, "YY"); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple xx-rYY"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx-rYY"}); - - config = new TotalConfig(); - config.setProperty(properties.MCC, 111); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mcc111"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mcc111"}); - - config = new TotalConfig(); - config.setProperty(properties.MNC, 222); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mnc222"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mnc222"}); - - config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_NOTOUCH); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple notouch"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag notouch"}); - - config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple stylus"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag stylus"}); - - config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_NOKEYS); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple nokeys"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag nokeys"}); - - config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 12key"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 12key"}); - - config = new TotalConfig(); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple keysexposed"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag keysexposed"}); - - config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_NONAV); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple nonav"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag nonav"}); - - config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple dpad"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag dpad"}); - - config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_WHEEL); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple wheel"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag wheel"}); - - config = new TotalConfig(); - config.setProperty(properties.HEIGHT, 480); - config.setProperty(properties.WIDTH, 320); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 480x320"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 480x320"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 240); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 240dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 240dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple landscape"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag landscape"}); - - config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple square"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag square"}); - } - - @MediumTest - public void testDensity() throws Exception { - // have 32, 240 and the default 160 content. - // rule is that closest wins, with down scaling (larger content) - // being twice as nice as upscaling. - // transition at H/2 * (-1 +/- sqrt(1+8L/H)) - // SO, X < 49 goes to 32 - // 49 >= X < 182 goes to 160 - // X >= 182 goes to 240 - TotalConfig config = new TotalConfig(); - config.setProperty(properties.DENSITY, 2); - Resources res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 32dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 32dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 32); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 32dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 32dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 48); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 32dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 32dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 49); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 150); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 181); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 182); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 240dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 240dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 239); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 240dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 240dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 490); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 240dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 240dpi"}); - } - -// TODO - add tests for special cases - ie, other key params seem ignored if -// nokeys is set - - @MediumTest - public void testCombinations() throws Exception { - /** - * Verify that proper strings are found for multiple-selectivity case - * (ie, a string set for locale and mcc is found only when both are - * true). - */ - TotalConfig config = new TotalConfig(); - config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.COUNTRY, "YY"); - config.setProperty(properties.MCC, 111); - Resources res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mcc111 xx-rYY"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mcc111 xx-rYY"}); - - config = new TotalConfig(); - config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.COUNTRY, "YY"); - config.setProperty(properties.MCC, 333); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple xx-rYY"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx-rYY"}); - - config = new TotalConfig(); - config.setProperty(properties.MNC, 333); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - } - - @MediumTest - public void testPrecidence() throws Exception { - /** - * Verify that in cases of ties, the specific ordering is followed - */ - - /** - * Precidence order: mcc, mnc, locale, orientation, density, - * touchscreen, hidden, keyboard, navigation, width-height - */ - - /** - * verify mcc trumps mnc. Have 110-xx, 220-xx but no 110-220 - * so with is selected? Should be mcc110-xx. - */ - TotalConfig config = new TotalConfig(); - config.setProperty(properties.MCC, 110); - config.setProperty(properties.MNC, 220); - config.setProperty(properties.LANGUAGE, "xx"); - Resources res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mcc110 xx"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mcc110 xx"}); - - /* full A + B + C doesn't exist. Do we get A + C or B + C? - */ - config = new TotalConfig(); - config.setProperty(properties.MCC, 111); - config.setProperty(properties.MNC, 222); - config.setProperty(properties.LANGUAGE, "xx"); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mcc111 mnc222"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mcc111 mnc222"}); - - config = new TotalConfig(); - config.setProperty(properties.MNC, 222); - config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.ORIENTATION, - Configuration.ORIENTATION_SQUARE); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple mnc222 xx"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag mnc222 xx"}); - - config = new TotalConfig(); - config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.ORIENTATION, - Configuration.ORIENTATION_SQUARE); - config.setProperty(properties.DENSITY, 32); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple xx square"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx square"}); - - config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, - Configuration.ORIENTATION_SQUARE); - config.setProperty(properties.DENSITY, 32); - config.setProperty(properties.TOUCHSCREEN, - Configuration.TOUCHSCREEN_STYLUS); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple square 32dpi"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag square 32dpi"}); - - config = new TotalConfig(); - config.setProperty(properties.DENSITY, 32); - config.setProperty(properties.TOUCHSCREEN, - Configuration.TOUCHSCREEN_STYLUS); - config.setProperty(properties.KEYBOARDHIDDEN, - Configuration.KEYBOARDHIDDEN_NO); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 32dpi stylus"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 32dpi stylus"}); - - config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, - Configuration.TOUCHSCREEN_STYLUS); - config.setProperty(properties.KEYBOARDHIDDEN, - Configuration.KEYBOARDHIDDEN_NO); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple stylus keysexposed"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag stylus keysexposed"}); - - config = new TotalConfig(); - config.setProperty(properties.KEYBOARDHIDDEN, - Configuration.KEYBOARDHIDDEN_NO); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - config.setProperty(properties.NAVIGATION, - Configuration.NAVIGATION_DPAD); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple keysexposed 12key"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag keysexposed 12key"}); - - config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - config.setProperty(properties.NAVIGATION, - Configuration.NAVIGATION_DPAD); - config.setProperty(properties.HEIGHT, 63); - config.setProperty(properties.WIDTH, 57); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 12key dpad"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 12key dpad"}); - - config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, - Configuration.NAVIGATION_DPAD); - config.setProperty(properties.HEIGHT, 640); - config.setProperty(properties.WIDTH, 400); - res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple dpad"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag dpad"}); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ContentTests.java b/tests/AndroidTests/src/com/android/unit_tests/content/ContentTests.java index 80318dc..636660f 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ContentTests.java +++ b/tests/AndroidTests/src/com/android/unit_tests/content/ContentTests.java @@ -23,10 +23,6 @@ public class ContentTests { TestSuite suite = new TestSuite(ContentTests.class.getName()); suite.addTestSuite(AssetTest.class); - suite.addTestSuite(IntentFilterTest.class); - suite.addTest(ResourceTests.suite()); - suite.addTestSuite(PluralResourcesTest.class); - suite.addTestSuite(ConfigTest.class); return suite; } } diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/FractionTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/FractionTest.java deleted file mode 100644 index 74a6b8d..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/FractionTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.Resources; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.TypedValue; -import com.android.unit_tests.R; - -public class FractionTest extends AndroidTestCase { - - private Resources mResources; - private final TypedValue mValue = new TypedValue(); - - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); - } - - @SmallTest - public void testFractions() throws Exception { - tryFraction(R.dimen.frac100perc, 1, 1, 1); - tryFraction(R.dimen.frac1perc, 1, 1, .01f); - tryFraction(R.dimen.fracp1perc, 1, 1, .001f); - tryFraction(R.dimen.fracp01perc, 1, 1, .0001f); - tryFraction(R.dimen.frac0perc, 1, 1, 0); - tryFraction(R.dimen.frac1p1perc, 1, 1, .011f); - tryFraction(R.dimen.frac100p1perc, 1, 1, 1.001f); - tryFraction(R.dimen.frac25510perc, 1, 1, 255.1f); - tryFraction(R.dimen.frac25610perc, 1, 1, 256.1f); - tryFraction(R.dimen.frac6553510perc, 1, 1, 65535.1f); - tryFraction(R.dimen.frac6553610perc, 1, 1, 65536.1f); - - tryFraction(R.dimen.frac100perc, 100, 1, 100); - tryFraction(R.dimen.frac1perc, 100, 1, .01f * 100); - tryFraction(R.dimen.fracp1perc, 100, 1, .001f * 100); - tryFraction(R.dimen.fracp01perc, 100, 1, .0001f * 100); - tryFraction(R.dimen.frac0perc, 100, 1, 0); - tryFraction(R.dimen.frac1p1perc, 100, 1, .011f * 100); - tryFraction(R.dimen.frac100p1perc, 100, 1, 1.001f * 100); - tryFraction(R.dimen.frac25510perc, 100, 1, 255.1f * 100); - tryFraction(R.dimen.frac25610perc, 100, 1, 256.1f * 100); - tryFraction(R.dimen.frac6553510perc, 100, 1, 65535.1f * 100); - tryFraction(R.dimen.frac6553610perc, 100, 1, 65536.1f * 100); - - tryFraction(R.dimen.frac100pperc, 100, 2, 2); - tryFraction(R.dimen.frac1pperc, 100, 2, .01f * 2); - tryFraction(R.dimen.fracp1pperc, 100, 2, .001f * 2); - tryFraction(R.dimen.fracp01pperc, 100, 2, .0001f * 2); - tryFraction(R.dimen.frac0pperc, 100, 2, 0); - tryFraction(R.dimen.frac1p1pperc, 100, 2, .011f * 2); - tryFraction(R.dimen.frac100p1pperc, 100, 2, 1.001f * 2); - tryFraction(R.dimen.frac25510pperc, 100, 2, 255.1f * 2); - tryFraction(R.dimen.frac25610pperc, 100, 2, 256.1f * 2); - tryFraction(R.dimen.frac6553510pperc, 100, 2, 65535.1f * 2); - tryFraction(R.dimen.frac6553610pperc, 100, 2, 65536.1f * 2); - } - - private void tryFraction(int resid, float base, float pbase, float expected) { - mResources.getValue(resid, mValue, true); - float res = mValue.getFraction(base, pbase); - float diff = Math.abs(expected - res); - float prec = expected * 1e-4f; - if (prec < 1e-5f) { - prec = 1e-5f; - } - //System.out.println( - // "Res 0x" + Integer.toHexString(resid) + ": got=" + res - // + ", expected=" + expected + ", diff=" + diff); - assertFalse("Expecting value " + expected + " got " + res - + ": in resource 0x" + Integer.toHexString(resid) - + " " + mValue, - diff > prec); - } -} - diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/IntentFilterTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/IntentFilterTest.java deleted file mode 100644 index 0335b9d..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/IntentFilterTest.java +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.IntentFilter; -import android.test.suitebuilder.annotation.SmallTest; -import static android.os.PatternMatcher.PATTERN_LITERAL; -import static android.os.PatternMatcher.PATTERN_PREFIX; -import static android.os.PatternMatcher.PATTERN_SIMPLE_GLOB; -import android.net.Uri; -import android.util.StringBuilderPrinter; -import junit.framework.TestCase; - -import java.util.HashSet; - -public class IntentFilterTest extends TestCase { - - public static class Match extends IntentFilter { - Match(String[] actions, String[] categories, String[] mimeTypes, - String[] schemes, String[] authorities, String[] ports) { - if (actions != null) { - for (int i = 0; i < actions.length; i++) { - addAction(actions[i]); - } - } - if (categories != null) { - for (int i = 0; i < categories.length; i++) { - addCategory(categories[i]); - } - } - if (mimeTypes != null) { - for (int i = 0; i < mimeTypes.length; i++) { - try { - addDataType(mimeTypes[i]); - } catch (IntentFilter.MalformedMimeTypeException e) { - throw new RuntimeException("Bad mime type", e); - } - } - } - if (schemes != null) { - for (int i = 0; i < schemes.length; i++) { - addDataScheme(schemes[i]); - } - } - if (authorities != null) { - for (int i = 0; i < authorities.length; i++) { - addDataAuthority(authorities[i], - ports != null ? ports[i] : null); - } - } - } - - Match(String[] actions, String[] categories, String[] mimeTypes, - String[] schemes, String[] authorities, String[] ports, - String[] paths, int[] pathTypes) { - this(actions, categories, mimeTypes, schemes, authorities, ports); - if (paths != null) { - for (int i = 0; i < paths.length; i++) { - addDataPath(paths[i], pathTypes[i]); - } - } - } - } - - public static class MatchCondition { - public final int result; - public final String action; - public final String mimeType; - public final Uri data; - public final String[] categories; - - public MatchCondition(int _result, String _action, String[] _categories, - String _mimeType, String _data) { - result = _result; - action = _action; - mimeType = _mimeType; - data = _data != null ? Uri.parse(_data) : null; - categories = _categories; - } - } - - public static void checkMatches(IntentFilter filter, - MatchCondition[] results) { - for (int i = 0; i < results.length; i++) { - MatchCondition mc = results[i]; - HashSet<String> categories = null; - if (mc.categories != null) { - for (int j = 0; j < mc.categories.length; j++) { - if (categories == null) { - categories = new HashSet<String>(); - } - categories.add(mc.categories[j]); - } - } - int result = filter.match(mc.action, mc.mimeType, - mc.data != null ? mc.data.getScheme() : null, mc.data, - categories, "test"); - if ( (result & IntentFilter.MATCH_CATEGORY_MASK) - != (mc.result & IntentFilter.MATCH_CATEGORY_MASK) ) { - StringBuilder msg = new StringBuilder(); - msg.append("Error matching against IntentFilter:\n"); - filter.dump(new StringBuilderPrinter(msg), " "); - msg.append("Match action: "); - msg.append(mc.action); - msg.append("\nMatch mimeType: "); - msg.append(mc.mimeType); - msg.append("\nMatch data: "); - msg.append(mc.data); - msg.append("\nMatch categories: "); - if (mc.categories != null) { - for (int j = 0; j < mc.categories.length; j++) { - if (j > 0) msg.append(", "); - msg.append(mc.categories[j]); - } - } - msg.append("\nExpected result: 0x"); - msg.append(Integer.toHexString(mc.result)); - msg.append(", got result: 0x"); - msg.append(Integer.toHexString(result)); - throw new RuntimeException(msg.toString()); - } - } - } - - @SmallTest - public void testActions() throws Exception { - IntentFilter filter = new Match( - new String[]{"action1"}, null, null, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, "action1", - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_ACTION, "action2", - null, null, null), - }); - - filter = new Match( - new String[]{"action1", "action2"}, - null, null, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, "action1", - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, "action2", - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_ACTION, "action3", - null, null, null), - }); - } - - @SmallTest - public void testCategories() throws Exception { - IntentFilter filter = new Match( - null, new String[]{"category1"}, null, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - new String[]{"category1"}, null, null), - new MatchCondition(IntentFilter.NO_MATCH_CATEGORY, null, - new String[]{"category2"}, null, null), - new MatchCondition(IntentFilter.NO_MATCH_CATEGORY, null, - new String[]{"category1", "category2"}, null, null), - }); - - filter = new Match( - null, new String[]{"category1", "category2"}, null, null, - null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - new String[]{"category1"}, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - new String[]{"category2"}, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, - new String[]{"category1", "category2"}, null, null), - new MatchCondition(IntentFilter.NO_MATCH_CATEGORY, null, - new String[]{"category3"}, null, null), - new MatchCondition(IntentFilter.NO_MATCH_CATEGORY, null, - new String[]{"category1", "category2", "category3"}, - null, null), - }); - } - - @SmallTest - public void testMimeTypes() throws Exception { - IntentFilter filter = new Match( - null, null, new String[]{"which1/what1"}, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what1", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "*/*", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which2/what2", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which2/*", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which1/what2", null), - }); - - filter = new Match(null, null, - new String[]{"which1/what1", "which2/what2"}, null, null, - null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what1", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "*/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which2/what2", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which2/*", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which1/what2", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which3/what3", null), - }); - - filter = new Match(null, null, - new String[]{"which1/*"}, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what1", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "*/*", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which2/what2", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which2/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what2", null), - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, null, - "which3/what3", null), - }); - - filter = new Match(null, null, - new String[]{"*/*"}, null, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_TYPE, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what1", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "*/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which2/what2", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which2/*", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which1/what2", null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_TYPE, null, null, - "which3/what3", null), - }); - } - - @SmallTest - public void testSchemes() throws Exception { - IntentFilter filter = new Match(null, null, null, - new String[]{"scheme1"}, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_SCHEME, null, - null, null, "scheme1:foo"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme2:foo"), - }); - - filter = new Match(null, null, null, - new String[]{"scheme1", "scheme2"}, null, null); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_SCHEME, null, - null, null, "scheme1:foo"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_SCHEME, null, - null, null, "scheme2:foo"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme3:foo"), - }); - } - - @SmallTest - public void testAuthorities() throws Exception { - IntentFilter filter = new Match(null, null, null, - new String[]{"scheme1"}, - new String[]{"authority1"}, new String[]{null}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1:foo"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_HOST, null, - null, null, "scheme1://authority1/"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority2/"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_HOST, null, - null, null, "scheme1://authority1:100/"), - }); - - filter = new Match(null, null, null, new String[]{"scheme1"}, - new String[]{"authority1"}, new String[]{"100"}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1:foo"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority1/"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority2/"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PORT, null, - null, null, "scheme1://authority1:100/"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority1:200/"), - }); - - filter = new Match(null, null, null, new String[]{"scheme1"}, - new String[]{"authority1", "authority2"}, - new String[]{"100", null}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1:foo"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority1/"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_HOST, null, - null, null, "scheme1://authority2/"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PORT, null, - null, null, "scheme1://authority1:100/"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme1://authority1:200/"), - }); - } - - @SmallTest - public void testPaths() throws Exception { - IntentFilter filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/literal1", "/2literal"}, - new int[]{PATTERN_LITERAL, PATTERN_LITERAL}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/literal1"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/2literal"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/literal"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/literal12"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/literal1", "/2literal"}, - new int[]{PATTERN_PREFIX, PATTERN_PREFIX}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/literal1"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/2literal"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/literal"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/literal12"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/.*"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/literal1"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{".*"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/literal1"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a1*b"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a1b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a11b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a2b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a1bc"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a1*"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a1"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a11"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a1b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a11"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a2"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a\\.*b"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a..b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a2b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a.bc"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a.*b"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.1b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a2b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a.bc"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a.*"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.1b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a2b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.bc"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a.\\*b"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.*b"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a1*b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a2b"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a.bc"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/"), - }); - filter = new Match(null, null, null, - new String[]{"scheme"}, new String[]{"authority"}, null, - new String[]{"/a.\\*"}, - new int[]{PATTERN_SIMPLE_GLOB}); - checkMatches(filter, new MatchCondition[]{ - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, null), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/ab"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a.*"), - new MatchCondition(IntentFilter.MATCH_CATEGORY_PATH, null, - null, null, "scheme://authority/a1*"), - new MatchCondition(IntentFilter.NO_MATCH_DATA, null, - null, null, "scheme://authority/a1b"), - }); - } - -} - diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/PluralResourcesTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/PluralResourcesTest.java deleted file mode 100644 index c3d1478..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/PluralResourcesTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.AssetManager; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.TypedValue; -import android.util.Log; -import com.android.unit_tests.R; - -import junit.framework.Assert; - -import java.util.Locale; - -public class PluralResourcesTest extends AndroidTestCase { - private static final String TAG = "PluralResourcesTest"; - - private Resources mResources; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); - } - - Resources resourcesForLanguage(String lang) { - Configuration config = new Configuration(); - config.updateFrom(mResources.getConfiguration()); - config.locale = new Locale(lang); - return new Resources(mResources.getAssets(), mResources.getDisplayMetrics(), config); - } - - @SmallTest - public void testPlurals() throws Exception { - CharSequence cs; - Resources res = resourcesForLanguage("en"); - - cs = res.getQuantityText(R.plurals.plurals_test, 0); - Log.d(TAG, "english 0 cs=" + cs); - Assert.assertEquals(cs.toString(), "Some dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 1); - Log.d(TAG, "english 1 cs=" + cs); - Assert.assertEquals(cs.toString(), "A dog"); - - cs = res.getQuantityText(R.plurals.plurals_test, 2); - Assert.assertEquals(cs.toString(), "Some dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 5); - Assert.assertEquals(cs.toString(), "Some dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 500); - Assert.assertEquals(cs.toString(), "Some dogs"); - } - - @SmallTest - public void testCzech() throws Exception { - CharSequence cs; - Resources res = resourcesForLanguage("cs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 0); - Log.d(TAG, "czech 0 cs=" + cs); - Assert.assertEquals(cs.toString(), "Some Czech dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 1); - Log.d(TAG, "czech 1 cs=" + cs); - Assert.assertEquals(cs.toString(), "A Czech dog"); - - cs = res.getQuantityText(R.plurals.plurals_test, 2); - Log.d(TAG, "czech 2 cs=" + cs); - Assert.assertEquals(cs.toString(), "Few Czech dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 5); - Assert.assertEquals(cs.toString(), "Some Czech dogs"); - - cs = res.getQuantityText(R.plurals.plurals_test, 500); - Assert.assertEquals(cs.toString(), "Some Czech dogs"); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/PrimitiveTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/PrimitiveTest.java deleted file mode 100644 index 44098cc..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/PrimitiveTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.util.TypedValue; -import com.android.unit_tests.R; - -public class PrimitiveTest extends AndroidTestCase { - private Resources mResources; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); - } - - private void tryEnum(int resid, int expected) { - TypedArray sa = - mContext.obtainStyledAttributes(resid, R.styleable.EnumStyle); - int value = sa.getInt(R.styleable.EnumStyle_testEnum, -1); - sa.recycle(); - - assertEquals("Expecting value " + expected + " got " + value - + ": in resource 0x" + Integer.toHexString(resid), - expected, value); - } - - @SmallTest - public void testEnum() throws Exception { - tryEnum(R.style.TestEnum1, 1); - tryEnum(R.style.TestEnum2, 2); - tryEnum(R.style.TestEnum10, 10); - tryEnum(R.style.TestEnum1_EmptyInherit, 1); - } - - private void tryFlag(int resid, int expected) { - TypedArray sa = - mContext.obtainStyledAttributes(resid, R.styleable.FlagStyle); - int value = sa.getInt(R.styleable.FlagStyle_testFlags, -1); - sa.recycle(); - - assertEquals("Expecting value " + expected + " got " + value - + ": in resource 0x" + Integer.toHexString(resid), - expected, value); - } - - @SmallTest - public void testFlags() throws Exception { - tryFlag(R.style.TestFlag1, 0x1); - tryFlag(R.style.TestFlag2, 0x2); - tryFlag(R.style.TestFlag31, 0x40000000); - tryFlag(R.style.TestFlag1And2, 0x3); - tryFlag(R.style.TestFlag1And2And31, 0x40000003); - } - - private void tryBoolean(int resid, boolean expected) { - TypedValue v = new TypedValue(); - mContext.getResources().getValue(resid, v, true); - assertEquals(TypedValue.TYPE_INT_BOOLEAN, v.type); - assertEquals("Expecting boolean value " + expected + " got " + v - + " from TypedValue: in resource 0x" + Integer.toHexString(resid), - expected, v.data != 0); - assertEquals("Expecting boolean value " + expected + " got " + v - + " from getBoolean(): in resource 0x" + Integer.toHexString(resid), - expected, mContext.getResources().getBoolean(resid)); - } - - @SmallTest - public void testBoolean() throws Exception { - tryBoolean(R.bool.trueRes, true); - tryBoolean(R.bool.falseRes, false); - } - - private void tryString(int resid, String expected) { - TypedValue v = new TypedValue(); - mContext.getResources().getValue(resid, v, true); - assertEquals(TypedValue.TYPE_STRING, v.type); - assertEquals("Expecting string value " + expected + " got " + v - + ": in resource 0x" + Integer.toHexString(resid), - expected, v.string); - } - - @SmallTest - public void testStringCoerce() throws Exception { - tryString(R.string.coerceIntegerToString, "100"); - tryString(R.string.coerceBooleanToString, "true"); - tryString(R.string.coerceColorToString, "#fff"); - tryString(R.string.coerceFloatToString, "100.0"); - tryString(R.string.coerceDimensionToString, "100px"); - tryString(R.string.coerceFractionToString, "100%"); - } - - private static void checkString(int resid, String actual, String expected) { - assertEquals("Expecting string value \"" + expected + "\" got \"" - + actual + "\" in resources 0x" + Integer.toHexString(resid), - expected, actual); - } - - @SmallTest - public void testFormattedString() throws Exception { - // Make sure the regular one doesn't format anything - checkString(R.string.formattedStringNone, - mResources.getString(R.string.formattedStringNone), - "Format[]"); - checkString(R.string.formattedStringOne, - mResources.getString(R.string.formattedStringOne), - "Format[%d]"); - checkString(R.string.formattedStringTwo, - mResources.getString(R.string.formattedStringTwo), - "Format[%3$d,%2$s]"); - // Make sure the formatted one works - checkString(R.string.formattedStringNone, - mResources.getString(R.string.formattedStringNone), - "Format[]"); - checkString(R.string.formattedStringOne, - mResources.getString(R.string.formattedStringOne, 42), - "Format[42]"); - checkString(R.string.formattedStringTwo, - mResources.getString(R.string.formattedStringTwo, "unused", "hi", 43), - "Format[43,hi]"); - } -} - diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/RawResourceTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/RawResourceTest.java deleted file mode 100644 index 1786dc4..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/RawResourceTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.Resources; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import com.android.unit_tests.R; - -import java.io.InputStream; - -public class RawResourceTest extends AndroidTestCase { - private Resources mResources; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); - } - - @SmallTest - public void testReadToEnd() throws Exception { - InputStream is = mResources.openRawResource(R.raw.text); - AssetTest.verifyTextAsset(is); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ResourceNameTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/ResourceNameTest.java deleted file mode 100644 index 2a56243..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ResourceNameTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import android.content.res.Resources; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; - -import com.android.unit_tests.R; - -public class ResourceNameTest extends AndroidTestCase { - - @SmallTest - public void testGetResourceName() { - Resources res = mContext.getResources(); - - String fullName = res.getResourceName(R.configVarying.simple); - assertEquals("com.android.unit_tests:configVarying/simple", fullName); - - String packageName = res.getResourcePackageName(R.configVarying.simple); - assertEquals("com.android.unit_tests", packageName); - - String typeName = res.getResourceTypeName(R.configVarying.simple); - assertEquals("configVarying", typeName); - - String entryName = res.getResourceEntryName(R.configVarying.simple); - assertEquals("simple", entryName); - } - - @SmallTest - public void testGetResourceIdentifier() { - Resources res = mContext.getResources(); - int resid = res.getIdentifier( - "com.android.unit_tests:configVarying/simple", - null, null); - assertEquals(R.configVarying.simple, resid); - - resid = res.getIdentifier("configVarying/simple", null, - "com.android.unit_tests"); - assertEquals(R.configVarying.simple, resid); - - resid = res.getIdentifier("simple", "configVarying", - "com.android.unit_tests"); - assertEquals(R.configVarying.simple, resid); - } -} - diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ResourceTests.java b/tests/AndroidTests/src/com/android/unit_tests/content/ResourceTests.java deleted file mode 100644 index 943941e..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ResourceTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.content; - -import junit.framework.TestSuite; - -public class ResourceTests { - public static TestSuite suite() { - TestSuite suite = new TestSuite(ResourceTests.class.getName()); - - suite.addTestSuite(FractionTest.class); - suite.addTestSuite(PrimitiveTest.class); - suite.addTestSuite(ArrayTest.class); - suite.addTestSuite(ConfigTest.class); - suite.addTestSuite(RawResourceTest.class); - suite.addTestSuite(ResourceNameTest.class); - return suite; - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/os/HandlerStateMachineTest.java b/tests/AndroidTests/src/com/android/unit_tests/os/HandlerStateMachineTest.java deleted file mode 100644 index 29045a3..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/os/HandlerStateMachineTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.os; - -import junit.framework.TestCase; -import java.util.Vector; - -import android.os.Handler; -import android.os.HandlerState; -import android.os.HandlerStateMachine; -import android.os.HandlerThread; -import android.os.Looper; -import android.os.Process; -import android.os.Message; -import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; - -import android.util.Log; - -public class HandlerStateMachineTest extends TestCase { - private static final int TEST_WHAT_1 = 1; - private static final int TEST_WHAT_2 = 2; - - private static final boolean DBG = false; - private static final String TAG = "HandlerStateMachineTest"; - - private boolean mDidEnter = false; - private boolean mDidExit = false; - private Vector<Integer> mGotMessagesWhat = new Vector<Integer>(); - - /** - * This test statemachine has two states, it receives - * two messages in state mS1 deferring them until what == TEST_WHAT_2 - * and then transitions to state mS2. State mS2 should then receive - * both of the deferred messages first TEST_WHAT_1 and then TEST_WHAT_2. - * When TEST_WHAT_2 is received it invokes notifyAll so the test can - * conclude. - */ - class StateMachine1 extends HandlerStateMachine { - StateMachine1(String name) { - super(name); - mThisSm = this; - setDbg(DBG); - setInitialState(mS1); - } - - class S1 extends HandlerState { - @Override public void enter(Message message) { - mDidEnter = true; - } - - @Override public void processMessage(Message message) { - deferMessage(message); - if (message.what == TEST_WHAT_2) { - transitionTo(mS2); - } - } - - @Override public void exit(Message message) { - mDidExit = true; - } - } - - class S2 extends HandlerState { - @Override public void processMessage(Message message) { - mGotMessagesWhat.add(message.what); - if (message.what == TEST_WHAT_2) { - synchronized (mThisSm) { - mThisSm.notifyAll(); - } - } - } - } - - private StateMachine1 mThisSm; - private S1 mS1 = new S1(); - private S2 mS2 = new S2(); - } - - @SmallTest - public void testStateMachine1() throws Exception { - StateMachine1 sm1 = new StateMachine1("sm1"); - if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 E"); - - synchronized (sm1) { - // Send two messages - sm1.sendMessage(sm1.obtainMessage(TEST_WHAT_1)); - sm1.sendMessage(sm1.obtainMessage(TEST_WHAT_2)); - - try { - // wait for the messages to be handled - sm1.wait(); - } catch (InterruptedException e) { - Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage()); - } - } - - assertTrue(mDidEnter); - assertTrue(mDidExit); - assertTrue(mGotMessagesWhat.size() == 2); - assertTrue(mGotMessagesWhat.get(0) == TEST_WHAT_1); - assertTrue(mGotMessagesWhat.get(1) == TEST_WHAT_2); - if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 X"); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/os/HierarchicalStateMachineTest.java b/tests/AndroidTests/src/com/android/unit_tests/os/HierarchicalStateMachineTest.java new file mode 100644 index 0000000..c5ca5a7 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/os/HierarchicalStateMachineTest.java @@ -0,0 +1,1392 @@ +/** + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.os; + +import junit.framework.TestCase; + +import android.os.Debug; +import android.os.HandlerThread; +import android.os.Looper; +import android.os.Message; +import android.os.SystemClock; +import android.test.suitebuilder.annotation.SmallTest; + +import android.util.Log; + +import com.android.internal.util.HierarchicalStateMachine; +import com.android.internal.util.HierarchicalState; +import com.android.internal.util.ProcessedMessages; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Test for HierarchicalStateMachine. + * + * @author wink@google.com (Wink Saville) + */ +public class HierarchicalStateMachineTest extends TestCase { + private static final int TEST_CMD_1 = 1; + private static final int TEST_CMD_2 = 2; + private static final int TEST_CMD_3 = 3; + private static final int TEST_CMD_4 = 4; + private static final int TEST_CMD_5 = 5; + private static final int TEST_CMD_6 = 6; + + private static final boolean DBG = true; + private static final boolean WAIT_FOR_DEBUGGER = false; + private static final String TAG = "HierarchicalStateMachineTest"; + + /** + * Tests that ProcessedMessage works as a circular buffer. + */ + class StateMachine0 extends HierarchicalStateMachine { + StateMachine0(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + setProcessedMessagesSize(3); + + // Setup state machine with 1 state + addState(mS1); + + // Set the initial state + setInitialState(mS1); + } + + class S1 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_6) { + transitionToHaltingState(); + } + return true; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine0 mThisSm; + private S1 mS1 = new S1(); + } + + @SmallTest + public void testStateMachine0() throws Exception { + if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger(); + + StateMachine0 sm0 = new StateMachine0("sm0"); + sm0.start(); + if (sm0.isDbg()) Log.d(TAG, "testStateMachine0 E"); + + synchronized (sm0) { + // Send 6 messages + for (int i = 1; i <= 6; i++) { + sm0.sendMessage(sm0.obtainMessage(i)); + } + + try { + // wait for the messages to be handled + sm0.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine0: exception while waiting " + e.getMessage()); + } + } + + assertTrue(sm0.getProcessedMessagesCount() == 6); + assertTrue(sm0.getProcessedMessagesSize() == 3); + + ProcessedMessages.Info pmi; + pmi = sm0.getProcessedMessage(0); + assertEquals(TEST_CMD_4, pmi.getWhat()); + assertEquals(sm0.mS1, pmi.getState()); + assertEquals(sm0.mS1, pmi.getOriginalState()); + + pmi = sm0.getProcessedMessage(1); + assertEquals(TEST_CMD_5, pmi.getWhat()); + assertEquals(sm0.mS1, pmi.getState()); + assertEquals(sm0.mS1, pmi.getOriginalState()); + + pmi = sm0.getProcessedMessage(2); + assertEquals(TEST_CMD_6, pmi.getWhat()); + assertEquals(sm0.mS1, pmi.getState()); + assertEquals(sm0.mS1, pmi.getOriginalState()); + + if (sm0.isDbg()) Log.d(TAG, "testStateMachine0 X"); + } + + /** + * This tests enter/exit and transitions to the same state. + * The state machine has one state, it receives two messages + * in state mS1. With the first message it transitions to + * itself which causes it to be exited and reentered. + */ + class StateMachine1 extends HierarchicalStateMachine { + StateMachine1(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup state machine with 1 state + addState(mS1); + + // Set the initial state + setInitialState(mS1); + if (DBG) Log.d(TAG, "StateMachine1: ctor X"); + } + + class S1 extends HierarchicalState { + @Override protected void enter() { + mEnterCount++; + } + + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_1) { + assertEquals(1, mEnterCount); + assertEquals(0, mExitCount); + transitionTo(mS1); + } else if (message.what == TEST_CMD_2) { + assertEquals(2, mEnterCount); + assertEquals(1, mExitCount); + transitionToHaltingState(); + } + return true; + } + + @Override protected void exit() { + mExitCount++; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine1 mThisSm; + private S1 mS1 = new S1(); + + private int mEnterCount; + private int mExitCount; + } + + @SmallTest + public void testStateMachine1() throws Exception { + StateMachine1 sm1 = new StateMachine1("sm1"); + sm1.start(); + if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 E"); + + synchronized (sm1) { + // Send two messages + sm1.sendMessage(sm1.obtainMessage(TEST_CMD_1)); + sm1.sendMessage(sm1.obtainMessage(TEST_CMD_2)); + + try { + // wait for the messages to be handled + sm1.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage()); + } + } + + assertEquals(2, sm1.mEnterCount); + assertEquals(2, sm1.mExitCount); + + assertTrue(sm1.getProcessedMessagesSize() == 2); + + ProcessedMessages.Info pmi; + pmi = sm1.getProcessedMessage(0); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm1.mS1, pmi.getState()); + assertEquals(sm1.mS1, pmi.getOriginalState()); + + pmi = sm1.getProcessedMessage(1); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm1.mS1, pmi.getState()); + assertEquals(sm1.mS1, pmi.getOriginalState()); + + assertEquals(2, sm1.mEnterCount); + assertEquals(2, sm1.mExitCount); + + if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 X"); + } + + /** + * Test deferring messages and states with no parents. The state machine + * has two states, it receives two messages in state mS1 deferring them + * until what == TEST_CMD_2 and then transitions to state mS2. State + * mS2 then receives both of the deferred messages first TEST_CMD_1 and + * then TEST_CMD_2. + */ + class StateMachine2 extends HierarchicalStateMachine { + StateMachine2(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup the hierarchy + addState(mS1); + addState(mS2); + + // Set the initial state + setInitialState(mS1); + if (DBG) Log.d(TAG, "StateMachine2: ctor X"); + } + + class S1 extends HierarchicalState { + @Override protected void enter() { + mDidEnter = true; + } + + @Override protected boolean processMessage(Message message) { + deferMessage(message); + if (message.what == TEST_CMD_2) { + transitionTo(mS2); + } + return true; + } + + @Override protected void exit() { + mDidExit = true; + } + } + + class S2 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_2) { + transitionToHaltingState(); + } + return true; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine2 mThisSm; + private S1 mS1 = new S1(); + private S2 mS2 = new S2(); + + private boolean mDidEnter = false; + private boolean mDidExit = false; + } + + @SmallTest + public void testStateMachine2() throws Exception { + StateMachine2 sm2 = new StateMachine2("sm2"); + sm2.start(); + if (sm2.isDbg()) Log.d(TAG, "testStateMachine2 E"); + + synchronized (sm2) { + // Send two messages + sm2.sendMessage(sm2.obtainMessage(TEST_CMD_1)); + sm2.sendMessage(sm2.obtainMessage(TEST_CMD_2)); + + try { + // wait for the messages to be handled + sm2.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine2: exception while waiting " + e.getMessage()); + } + } + + assertTrue(sm2.getProcessedMessagesSize() == 4); + + ProcessedMessages.Info pmi; + pmi = sm2.getProcessedMessage(0); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm2.mS1, pmi.getState()); + + pmi = sm2.getProcessedMessage(1); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm2.mS1, pmi.getState()); + + pmi = sm2.getProcessedMessage(2); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm2.mS2, pmi.getState()); + + pmi = sm2.getProcessedMessage(3); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm2.mS2, pmi.getState()); + + assertTrue(sm2.mDidEnter); + assertTrue(sm2.mDidExit); + + if (sm2.isDbg()) Log.d(TAG, "testStateMachine2 X"); + } + + /** + * Test that unhandled messages in a child are handled by the parent. + * When TEST_CMD_2 is received. + */ + class StateMachine3 extends HierarchicalStateMachine { + StateMachine3(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup the simplest hierarchy of two states + // mParentState and mChildState. + // (Use indentation to help visualize hierarchy) + addState(mParentState); + addState(mChildState, mParentState); + + // Set the initial state will be the child + setInitialState(mChildState); + if (DBG) Log.d(TAG, "StateMachine3: ctor X"); + } + + class ParentState extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_2) { + transitionToHaltingState(); + } + return true; + } + } + + class ChildState extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + return false; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine3 mThisSm; + private ParentState mParentState = new ParentState(); + private ChildState mChildState = new ChildState(); + } + + @SmallTest + public void testStateMachine3() throws Exception { + StateMachine3 sm3 = new StateMachine3("sm3"); + sm3.start(); + if (sm3.isDbg()) Log.d(TAG, "testStateMachine3 E"); + + synchronized (sm3) { + // Send two messages + sm3.sendMessage(sm3.obtainMessage(TEST_CMD_1)); + sm3.sendMessage(sm3.obtainMessage(TEST_CMD_2)); + + try { + // wait for the messages to be handled + sm3.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine3: exception while waiting " + e.getMessage()); + } + } + + assertTrue(sm3.getProcessedMessagesSize() == 2); + + ProcessedMessages.Info pmi; + pmi = sm3.getProcessedMessage(0); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm3.mParentState, pmi.getState()); + assertEquals(sm3.mChildState, pmi.getOriginalState()); + + pmi = sm3.getProcessedMessage(1); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm3.mParentState, pmi.getState()); + assertEquals(sm3.mChildState, pmi.getOriginalState()); + + if (sm3.isDbg()) Log.d(TAG, "testStateMachine3 X"); + } + + /** + * Test a hierarchy of 3 states a parent and two children + * with transition from child 1 to child 2 and child 2 + * lets the parent handle the messages. + */ + class StateMachine4 extends HierarchicalStateMachine { + StateMachine4(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup a hierarchy of three states + // mParentState, mChildState1 & mChildState2 + // (Use indentation to help visualize hierarchy) + addState(mParentState); + addState(mChildState1, mParentState); + addState(mChildState2, mParentState); + + // Set the initial state will be child 1 + setInitialState(mChildState1); + if (DBG) Log.d(TAG, "StateMachine4: ctor X"); + } + + class ParentState extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_2) { + transitionToHaltingState(); + } + return true; + } + } + + class ChildState1 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + transitionTo(mChildState2); + return true; + } + } + + class ChildState2 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + return false; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine4 mThisSm; + private ParentState mParentState = new ParentState(); + private ChildState1 mChildState1 = new ChildState1(); + private ChildState2 mChildState2 = new ChildState2(); + } + + @SmallTest + public void testStateMachine4() throws Exception { + StateMachine4 sm4 = new StateMachine4("sm4"); + sm4.start(); + if (sm4.isDbg()) Log.d(TAG, "testStateMachine4 E"); + + synchronized (sm4) { + // Send two messages + sm4.sendMessage(sm4.obtainMessage(TEST_CMD_1)); + sm4.sendMessage(sm4.obtainMessage(TEST_CMD_2)); + + try { + // wait for the messages to be handled + sm4.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine4: exception while waiting " + e.getMessage()); + } + } + + + assertTrue(sm4.getProcessedMessagesSize() == 2); + + ProcessedMessages.Info pmi; + pmi = sm4.getProcessedMessage(0); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm4.mChildState1, pmi.getState()); + assertEquals(sm4.mChildState1, pmi.getOriginalState()); + + pmi = sm4.getProcessedMessage(1); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm4.mParentState, pmi.getState()); + assertEquals(sm4.mChildState2, pmi.getOriginalState()); + + if (sm4.isDbg()) Log.d(TAG, "testStateMachine4 X"); + } + + /** + * Test transition from one child to another of a "complex" + * hierarchy with two parents and multiple children. + */ + class StateMachine5 extends HierarchicalStateMachine { + StateMachine5(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup a hierarchy with two parents and some children. + // (Use indentation to help visualize hierarchy) + addState(mParentState1); + addState(mChildState1, mParentState1); + addState(mChildState2, mParentState1); + + addState(mParentState2); + addState(mChildState3, mParentState2); + addState(mChildState4, mParentState2); + addState(mChildState5, mChildState4); + + // Set the initial state will be the child + setInitialState(mChildState1); + if (DBG) Log.d(TAG, "StateMachine5: ctor X"); + } + + class ParentState1 extends HierarchicalState { + @Override protected void enter() { + mParentState1EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + return true; + } + @Override protected void exit() { + mParentState1ExitCount += 1; + } + } + + class ChildState1 extends HierarchicalState { + @Override protected void enter() { + mChildState1EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(0, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(0, mChildState1ExitCount); + assertEquals(0, mChildState2EnterCount); + assertEquals(0, mChildState2ExitCount); + assertEquals(0, mParentState2EnterCount); + assertEquals(0, mParentState2ExitCount); + assertEquals(0, mChildState3EnterCount); + assertEquals(0, mChildState3ExitCount); + assertEquals(0, mChildState4EnterCount); + assertEquals(0, mChildState4ExitCount); + assertEquals(0, mChildState5EnterCount); + assertEquals(0, mChildState5ExitCount); + + transitionTo(mChildState2); + return true; + } + @Override protected void exit() { + mChildState1ExitCount += 1; + } + } + + class ChildState2 extends HierarchicalState { + @Override protected void enter() { + mChildState2EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(0, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(1, mChildState1ExitCount); + assertEquals(1, mChildState2EnterCount); + assertEquals(0, mChildState2ExitCount); + assertEquals(0, mParentState2EnterCount); + assertEquals(0, mParentState2ExitCount); + assertEquals(0, mChildState3EnterCount); + assertEquals(0, mChildState3ExitCount); + assertEquals(0, mChildState4EnterCount); + assertEquals(0, mChildState4ExitCount); + assertEquals(0, mChildState5EnterCount); + assertEquals(0, mChildState5ExitCount); + + transitionTo(mChildState5); + return true; + } + @Override protected void exit() { + mChildState2ExitCount += 1; + } + } + + class ParentState2 extends HierarchicalState { + @Override protected void enter() { + mParentState2EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(1, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(1, mChildState1ExitCount); + assertEquals(1, mChildState2EnterCount); + assertEquals(1, mChildState2ExitCount); + assertEquals(2, mParentState2EnterCount); + assertEquals(1, mParentState2ExitCount); + assertEquals(1, mChildState3EnterCount); + assertEquals(1, mChildState3ExitCount); + assertEquals(2, mChildState4EnterCount); + assertEquals(2, mChildState4ExitCount); + assertEquals(1, mChildState5EnterCount); + assertEquals(1, mChildState5ExitCount); + + transitionToHaltingState(); + return true; + } + @Override protected void exit() { + mParentState2ExitCount += 1; + } + } + + class ChildState3 extends HierarchicalState { + @Override protected void enter() { + mChildState3EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(1, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(1, mChildState1ExitCount); + assertEquals(1, mChildState2EnterCount); + assertEquals(1, mChildState2ExitCount); + assertEquals(1, mParentState2EnterCount); + assertEquals(0, mParentState2ExitCount); + assertEquals(1, mChildState3EnterCount); + assertEquals(0, mChildState3ExitCount); + assertEquals(1, mChildState4EnterCount); + assertEquals(1, mChildState4ExitCount); + assertEquals(1, mChildState5EnterCount); + assertEquals(1, mChildState5ExitCount); + + transitionTo(mChildState4); + return true; + } + @Override protected void exit() { + mChildState3ExitCount += 1; + } + } + + class ChildState4 extends HierarchicalState { + @Override protected void enter() { + mChildState4EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(1, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(1, mChildState1ExitCount); + assertEquals(1, mChildState2EnterCount); + assertEquals(1, mChildState2ExitCount); + assertEquals(1, mParentState2EnterCount); + assertEquals(0, mParentState2ExitCount); + assertEquals(1, mChildState3EnterCount); + assertEquals(1, mChildState3ExitCount); + assertEquals(2, mChildState4EnterCount); + assertEquals(1, mChildState4ExitCount); + assertEquals(1, mChildState5EnterCount); + assertEquals(1, mChildState5ExitCount); + + transitionTo(mParentState2); + return true; + } + @Override protected void exit() { + mChildState4ExitCount += 1; + } + } + + class ChildState5 extends HierarchicalState { + @Override protected void enter() { + mChildState5EnterCount += 1; + } + @Override protected boolean processMessage(Message message) { + assertEquals(1, mParentState1EnterCount); + assertEquals(1, mParentState1ExitCount); + assertEquals(1, mChildState1EnterCount); + assertEquals(1, mChildState1ExitCount); + assertEquals(1, mChildState2EnterCount); + assertEquals(1, mChildState2ExitCount); + assertEquals(1, mParentState2EnterCount); + assertEquals(0, mParentState2ExitCount); + assertEquals(0, mChildState3EnterCount); + assertEquals(0, mChildState3ExitCount); + assertEquals(1, mChildState4EnterCount); + assertEquals(0, mChildState4ExitCount); + assertEquals(1, mChildState5EnterCount); + assertEquals(0, mChildState5ExitCount); + + transitionTo(mChildState3); + return true; + } + @Override protected void exit() { + mChildState5ExitCount += 1; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine5 mThisSm; + private ParentState1 mParentState1 = new ParentState1(); + private ChildState1 mChildState1 = new ChildState1(); + private ChildState2 mChildState2 = new ChildState2(); + private ParentState2 mParentState2 = new ParentState2(); + private ChildState3 mChildState3 = new ChildState3(); + private ChildState4 mChildState4 = new ChildState4(); + private ChildState5 mChildState5 = new ChildState5(); + + private int mParentState1EnterCount = 0; + private int mParentState1ExitCount = 0; + private int mChildState1EnterCount = 0; + private int mChildState1ExitCount = 0; + private int mChildState2EnterCount = 0; + private int mChildState2ExitCount = 0; + private int mParentState2EnterCount = 0; + private int mParentState2ExitCount = 0; + private int mChildState3EnterCount = 0; + private int mChildState3ExitCount = 0; + private int mChildState4EnterCount = 0; + private int mChildState4ExitCount = 0; + private int mChildState5EnterCount = 0; + private int mChildState5ExitCount = 0; + } + + @SmallTest + public void testStateMachine5() throws Exception { + StateMachine5 sm5 = new StateMachine5("sm5"); + sm5.start(); + if (sm5.isDbg()) Log.d(TAG, "testStateMachine5 E"); + + synchronized (sm5) { + // Send 6 messages + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_1)); + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_2)); + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_3)); + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_4)); + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_5)); + sm5.sendMessage(sm5.obtainMessage(TEST_CMD_6)); + + try { + // wait for the messages to be handled + sm5.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine5: exception while waiting " + e.getMessage()); + } + } + + + assertTrue(sm5.getProcessedMessagesSize() == 6); + + assertEquals(1, sm5.mParentState1EnterCount); + assertEquals(1, sm5.mParentState1ExitCount); + assertEquals(1, sm5.mChildState1EnterCount); + assertEquals(1, sm5.mChildState1ExitCount); + assertEquals(1, sm5.mChildState2EnterCount); + assertEquals(1, sm5.mChildState2ExitCount); + assertEquals(2, sm5.mParentState2EnterCount); + assertEquals(2, sm5.mParentState2ExitCount); + assertEquals(1, sm5.mChildState3EnterCount); + assertEquals(1, sm5.mChildState3ExitCount); + assertEquals(2, sm5.mChildState4EnterCount); + assertEquals(2, sm5.mChildState4ExitCount); + assertEquals(1, sm5.mChildState5EnterCount); + assertEquals(1, sm5.mChildState5ExitCount); + + ProcessedMessages.Info pmi; + pmi = sm5.getProcessedMessage(0); + assertEquals(TEST_CMD_1, pmi.getWhat()); + assertEquals(sm5.mChildState1, pmi.getState()); + assertEquals(sm5.mChildState1, pmi.getOriginalState()); + + pmi = sm5.getProcessedMessage(1); + assertEquals(TEST_CMD_2, pmi.getWhat()); + assertEquals(sm5.mChildState2, pmi.getState()); + assertEquals(sm5.mChildState2, pmi.getOriginalState()); + + pmi = sm5.getProcessedMessage(2); + assertEquals(TEST_CMD_3, pmi.getWhat()); + assertEquals(sm5.mChildState5, pmi.getState()); + assertEquals(sm5.mChildState5, pmi.getOriginalState()); + + pmi = sm5.getProcessedMessage(3); + assertEquals(TEST_CMD_4, pmi.getWhat()); + assertEquals(sm5.mChildState3, pmi.getState()); + assertEquals(sm5.mChildState3, pmi.getOriginalState()); + + pmi = sm5.getProcessedMessage(4); + assertEquals(TEST_CMD_5, pmi.getWhat()); + assertEquals(sm5.mChildState4, pmi.getState()); + assertEquals(sm5.mChildState4, pmi.getOriginalState()); + + pmi = sm5.getProcessedMessage(5); + assertEquals(TEST_CMD_6, pmi.getWhat()); + assertEquals(sm5.mParentState2, pmi.getState()); + assertEquals(sm5.mParentState2, pmi.getOriginalState()); + + if (sm5.isDbg()) Log.d(TAG, "testStateMachine5 X"); + } + + /** + * Test that the initial state enter is invoked immediately + * after construction and before any other messages arrive and that + * sendMessageDelayed works. + */ + class StateMachine6 extends HierarchicalStateMachine { + StateMachine6(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup state machine with 1 state + addState(mS1); + + // Set the initial state + setInitialState(mS1); + if (DBG) Log.d(TAG, "StateMachine6: ctor X"); + } + + class S1 extends HierarchicalState { + + @Override protected void enter() { + sendMessage(obtainMessage(TEST_CMD_1)); + } + + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_1) { + mArrivalTimeMsg1 = SystemClock.elapsedRealtime(); + } else if (message.what == TEST_CMD_2) { + mArrivalTimeMsg2 = SystemClock.elapsedRealtime(); + transitionToHaltingState(); + } + return true; + } + + @Override protected void exit() { + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine6 mThisSm; + private S1 mS1 = new S1(); + + private long mArrivalTimeMsg1; + private long mArrivalTimeMsg2; + } + + @SmallTest + public void testStateMachine6() throws Exception { + long sentTimeMsg2; + final int DELAY_TIME = 250; + final int DELAY_FUDGE = 20; + + StateMachine6 sm6 = new StateMachine6("sm6"); + sm6.start(); + if (sm6.isDbg()) Log.d(TAG, "testStateMachine6 E"); + + synchronized (sm6) { + // Send a message + sentTimeMsg2 = SystemClock.elapsedRealtime(); + sm6.sendMessageDelayed(sm6.obtainMessage(TEST_CMD_2), DELAY_TIME); + + try { + // wait for the messages to be handled + sm6.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine6: exception while waiting " + e.getMessage()); + } + } + + /** + * TEST_CMD_1 was sent in enter and must always have been processed + * immediately after construction and hence the arrival time difference + * should always >= to the DELAY_TIME + */ + long arrivalTimeDiff = sm6.mArrivalTimeMsg2 - sm6.mArrivalTimeMsg1; + long expectedDelay = DELAY_TIME - DELAY_FUDGE; + if (sm6.isDbg()) Log.d(TAG, "testStateMachine6: expect " + arrivalTimeDiff + + " >= " + expectedDelay); + assertTrue(arrivalTimeDiff >= expectedDelay); + + if (sm6.isDbg()) Log.d(TAG, "testStateMachine6 X"); + } + + /** + * Test that enter is invoked immediately after exit. This validates + * that enter can be used to send a watch dog message for its state. + */ + class StateMachine7 extends HierarchicalStateMachine { + private final int SM7_DELAY_TIME = 250; + + StateMachine7(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup state machine with 1 state + addState(mS1); + addState(mS2); + + // Set the initial state + setInitialState(mS1); + if (DBG) Log.d(TAG, "StateMachine7: ctor X"); + } + + class S1 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + transitionTo(mS2); + return true; + } + @Override protected void exit() { + sendMessage(obtainMessage(TEST_CMD_2)); + } + } + + class S2 extends HierarchicalState { + + @Override protected void enter() { + // Send a delayed message as a watch dog + sendMessageDelayed(obtainMessage(TEST_CMD_3), SM7_DELAY_TIME); + } + + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_2) { + mMsgCount += 1; + mArrivalTimeMsg2 = SystemClock.elapsedRealtime(); + } else if (message.what == TEST_CMD_3) { + mMsgCount += 1; + mArrivalTimeMsg3 = SystemClock.elapsedRealtime(); + } + + if (mMsgCount == 2) { + transitionToHaltingState(); + } + return true; + } + + @Override protected void exit() { + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachine7 mThisSm; + private S1 mS1 = new S1(); + private S2 mS2 = new S2(); + + private int mMsgCount = 0; + private long mArrivalTimeMsg2; + private long mArrivalTimeMsg3; + } + + @SmallTest + public void testStateMachine7() throws Exception { + long sentTimeMsg2; + final int SM7_DELAY_FUDGE = 20; + + StateMachine7 sm7 = new StateMachine7("sm7"); + sm7.start(); + if (sm7.isDbg()) Log.d(TAG, "testStateMachine7 E"); + + synchronized (sm7) { + // Send a message + sentTimeMsg2 = SystemClock.elapsedRealtime(); + sm7.sendMessage(sm7.obtainMessage(TEST_CMD_1)); + + try { + // wait for the messages to be handled + sm7.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachine7: exception while waiting " + e.getMessage()); + } + } + + /** + * TEST_CMD_3 was sent in S2.enter with a delay and must always have been + * processed immediately after S1.exit. Since S1.exit sent TEST_CMD_2 + * without a delay the arrival time difference should always >= to SM7_DELAY_TIME. + */ + long arrivalTimeDiff = sm7.mArrivalTimeMsg3 - sm7.mArrivalTimeMsg2; + long expectedDelay = sm7.SM7_DELAY_TIME - SM7_DELAY_FUDGE; + if (sm7.isDbg()) Log.d(TAG, "testStateMachine7: expect " + arrivalTimeDiff + + " >= " + expectedDelay); + assertTrue(arrivalTimeDiff >= expectedDelay); + + if (sm7.isDbg()) Log.d(TAG, "testStateMachine7 X"); + } + + /** + * Test unhandledMessage. + */ + class StateMachineUnhandledMessage extends HierarchicalStateMachine { + StateMachineUnhandledMessage(String name) { + super(name); + mThisSm = this; + setDbg(DBG); + + // Setup state machine with 1 state + addState(mS1); + + // Set the initial state + setInitialState(mS1); + } + + @Override protected void unhandledMessage(Message message) { + mUnhandledMessageCount += 1; + } + + class S1 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_2) { + transitionToHaltingState(); + } + return false; + } + } + + @Override + protected void halting() { + synchronized (mThisSm) { + mThisSm.notifyAll(); + } + } + + private StateMachineUnhandledMessage mThisSm; + private int mUnhandledMessageCount; + private S1 mS1 = new S1(); + } + + @SmallTest + public void testStateMachineUnhandledMessage() throws Exception { + + StateMachineUnhandledMessage sm = new StateMachineUnhandledMessage("sm"); + sm.start(); + if (sm.isDbg()) Log.d(TAG, "testStateMachineUnhandledMessage E"); + + synchronized (sm) { + // Send 2 messages + for (int i = 1; i <= 2; i++) { + sm.sendMessage(sm.obtainMessage(i)); + } + + try { + // wait for the messages to be handled + sm.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachineUnhandledMessage: exception while waiting " + + e.getMessage()); + } + } + + assertTrue(sm.getProcessedMessagesCount() == 2); + assertEquals(2, sm.mUnhandledMessageCount); + + if (sm.isDbg()) Log.d(TAG, "testStateMachineUnhandledMessage X"); + } + + /** + * Test state machines sharing the same thread/looper. Multiple instances + * of the same state machine will be created. They will all share the + * same thread and thus each can update <code>sharedCounter</code> which + * will be used to notify testStateMachineSharedThread that the test is + * complete. + */ + class StateMachineSharedThread extends HierarchicalStateMachine { + StateMachineSharedThread(Looper looper, String name, int maxCount) { + super(looper, name); + mMaxCount = maxCount; + setDbg(DBG); + + // Setup state machine with 1 state + addState(mS1); + + // Set the initial state + setInitialState(mS1); + } + + class S1 extends HierarchicalState { + @Override protected boolean processMessage(Message message) { + if (message.what == TEST_CMD_4) { + transitionToHaltingState(); + } + return true; + } + } + + @Override + protected void halting() { + // Update the shared counter, which is OK since all state + // machines are using the same thread. + sharedCounter += 1; + if (sharedCounter == mMaxCount) { + synchronized (waitObject) { + waitObject.notifyAll(); + } + } + } + + private int mMaxCount; + private S1 mS1 = new S1(); + } + private static int sharedCounter = 0; + private static Object waitObject = new Object(); + + @SmallTest + public void testStateMachineSharedThread() throws Exception { + if (DBG) Log.d(TAG, "testStateMachineSharedThread E"); + + // Create and start the handler thread + HandlerThread smThread = new HandlerThread("testStateMachineSharedThread"); + smThread.start(); + + // Create the state machines + StateMachineSharedThread sms[] = new StateMachineSharedThread[10]; + for (int i = 0; i < sms.length; i++) { + sms[i] = new StateMachineSharedThread(smThread.getLooper(), "sm", sms.length); + sms[i].start(); + } + + synchronized (waitObject) { + // Send messages to each of the state machines + for (StateMachineSharedThread sm : sms) { + for (int i = 1; i <= 4; i++) { + sm.sendMessage(sm.obtainMessage(i)); + } + } + + // Wait for the last state machine to notify its done + try { + waitObject.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testStateMachineSharedThread: exception while waiting " + + e.getMessage()); + } + } + + for (StateMachineSharedThread sm : sms) { + assertTrue(sm.getProcessedMessagesCount() == 4); + for (int i = 0; i < sm.getProcessedMessagesCount(); i++) { + ProcessedMessages.Info pmi = sm.getProcessedMessage(i); + assertEquals(i+1, pmi.getWhat()); + assertEquals(sm.mS1, pmi.getState()); + assertEquals(sm.mS1, pmi.getOriginalState()); + } + } + + if (DBG) Log.d(TAG, "testStateMachineSharedThread X"); + } + + @SmallTest + public void testHsm1() throws Exception { + if (DBG) Log.d(TAG, "testHsm1 E"); + + Hsm1 sm = Hsm1.makeHsm1(); + + // Send messages + sm.sendMessage(sm.obtainMessage(Hsm1.CMD_1)); + sm.sendMessage(sm.obtainMessage(Hsm1.CMD_2)); + + synchronized (sm) { + // Wait for the last state machine to notify its done + try { + sm.wait(); + } catch (InterruptedException e) { + Log.e(TAG, "testHsm1: exception while waiting " + e.getMessage()); + } + } + + assertEquals(7, sm.getProcessedMessagesCount()); + ProcessedMessages.Info pmi = sm.getProcessedMessage(0); + assertEquals(Hsm1.CMD_1, pmi.getWhat()); + assertEquals(sm.mS1, pmi.getState()); + assertEquals(sm.mS1, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(1); + assertEquals(Hsm1.CMD_2, pmi.getWhat()); + assertEquals(sm.mP1, pmi.getState()); + assertEquals(sm.mS1, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(2); + assertEquals(Hsm1.CMD_2, pmi.getWhat()); + assertEquals(sm.mS2, pmi.getState()); + assertEquals(sm.mS2, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(3); + assertEquals(Hsm1.CMD_3, pmi.getWhat()); + assertEquals(sm.mS2, pmi.getState()); + assertEquals(sm.mS2, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(4); + assertEquals(Hsm1.CMD_3, pmi.getWhat()); + assertEquals(sm.mP2, pmi.getState()); + assertEquals(sm.mP2, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(5); + assertEquals(Hsm1.CMD_4, pmi.getWhat()); + assertEquals(sm.mP2, pmi.getState()); + assertEquals(sm.mP2, pmi.getOriginalState()); + + pmi = sm.getProcessedMessage(6); + assertEquals(Hsm1.CMD_5, pmi.getWhat()); + assertEquals(sm.mP2, pmi.getState()); + assertEquals(sm.mP2, pmi.getOriginalState()); + + if (DBG) Log.d(TAG, "testStateMachineSharedThread X"); + } +} + +class Hsm1 extends HierarchicalStateMachine { + private static final String TAG = "hsm1"; + + public static final int CMD_1 = 1; + public static final int CMD_2 = 2; + public static final int CMD_3 = 3; + public static final int CMD_4 = 4; + public static final int CMD_5 = 5; + + public static Hsm1 makeHsm1() { + Log.d(TAG, "makeHsm1 E"); + Hsm1 sm = new Hsm1("hsm1"); + sm.start(); + Log.d(TAG, "makeHsm1 X"); + return sm; + } + + Hsm1(String name) { + super(name); + Log.d(TAG, "ctor E"); + + // Add states, use indentation to show hierarchy + addState(mP1); + addState(mS1, mP1); + addState(mS2, mP1); + addState(mP2); + + // Set the initial state + setInitialState(mS1); + Log.d(TAG, "ctor X"); + } + + class P1 extends HierarchicalState { + @Override protected void enter() { + Log.d(TAG, "P1.enter"); + } + @Override protected boolean processMessage(Message message) { + boolean retVal; + Log.d(TAG, "P1.processMessage what=" + message.what); + switch(message.what) { + case CMD_2: + // CMD_2 will arrive in mS2 before CMD_3 + sendMessage(obtainMessage(CMD_3)); + deferMessage(message); + transitionTo(mS2); + retVal = true; + break; + default: + // Any message we don't understand in this state invokes unhandledMessage + retVal = false; + break; + } + return retVal; + } + @Override protected void exit() { + Log.d(TAG, "P1.exit"); + } + } + + class S1 extends HierarchicalState { + @Override protected void enter() { + Log.d(TAG, "S1.enter"); + } + @Override protected boolean processMessage(Message message) { + Log.d(TAG, "S1.processMessage what=" + message.what); + if (message.what == CMD_1) { + // Transition to ourself to show that enter/exit is called + transitionTo(mS1); + return true; + } else { + // Let parent process all other messages + return false; + } + } + @Override protected void exit() { + Log.d(TAG, "S1.exit"); + } + } + + class S2 extends HierarchicalState { + @Override protected void enter() { + Log.d(TAG, "S2.enter"); + } + @Override protected boolean processMessage(Message message) { + boolean retVal; + Log.d(TAG, "S2.processMessage what=" + message.what); + switch(message.what) { + case(CMD_2): + sendMessage(obtainMessage(CMD_4)); + retVal = true; + break; + case(CMD_3): + deferMessage(message); + transitionTo(mP2); + retVal = true; + break; + default: + retVal = false; + break; + } + return retVal; + } + @Override protected void exit() { + Log.d(TAG, "S2.exit"); + } + } + + class P2 extends HierarchicalState { + @Override protected void enter() { + Log.d(TAG, "P2.enter"); + sendMessage(obtainMessage(CMD_5)); + } + @Override protected boolean processMessage(Message message) { + Log.d(TAG, "P2.processMessage what=" + message.what); + switch(message.what) { + case(CMD_3): + break; + case(CMD_4): + break; + case(CMD_5): + transitionToHaltingState(); + break; + } + return true; + } + @Override protected void exit() { + Log.d(TAG, "P2.exit"); + } + } + + @Override + protected void halting() { + Log.d(TAG, "halting"); + synchronized (this) { + this.notifyAll(); + } + } + + P1 mP1 = new P1(); + S1 mS1 = new S1(); + S2 mS2 = new S2(); + P2 mP2 = new P2(); +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesBuilder.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesBuilder.java new file mode 100644 index 0000000..e99e4cb --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesBuilder.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.vcard; + +import android.content.ContentValues; + +/** + * ContentValues-like class which enables users to chain put() methods and restricts + * the other methods. + */ +/* package */ class ContentValuesBuilder { + private final ContentValues mContentValues; + + public ContentValuesBuilder(final ContentValues contentValues) { + mContentValues = contentValues; + } + + public ContentValuesBuilder put(String key, String value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Byte value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Short value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Integer value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Long value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Float value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Double value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, Boolean value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder put(String key, byte[] value) { + mContentValues.put(key, value); + return this; + } + + public ContentValuesBuilder putNull(String key) { + mContentValues.putNull(key); + return this; + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifier.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifier.java new file mode 100644 index 0000000..3fa6ae6 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifier.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.pim.vcard.VCardConfig; +import android.pim.vcard.VCardEntry; +import android.pim.vcard.VCardEntryConstructor; +import android.pim.vcard.VCardEntryHandler; +import android.pim.vcard.VCardParser; +import android.pim.vcard.VCardParser_V21; +import android.pim.vcard.VCardParser_V30; +import android.pim.vcard.exception.VCardException; +import android.test.AndroidTestCase; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/* package */ class ContentValuesVerifier implements VCardEntryHandler { + private AndroidTestCase mTestCase; + private List<ContentValuesVerifierElem> mContentValuesVerifierElemList = + new ArrayList<ContentValuesVerifierElem>(); + private int mIndex; + + public ContentValuesVerifierElem addElem(AndroidTestCase androidTestCase) { + mTestCase = androidTestCase; + ContentValuesVerifierElem importVerifier = new ContentValuesVerifierElem(androidTestCase); + mContentValuesVerifierElemList.add(importVerifier); + return importVerifier; + } + + public void verify(int resId, int vCardType) throws IOException, VCardException { + verify(mTestCase.getContext().getResources().openRawResource(resId), vCardType); + } + + public void verify(int resId, int vCardType, final VCardParser vCardParser) + throws IOException, VCardException { + verify(mTestCase.getContext().getResources().openRawResource(resId), + vCardType, vCardParser); + } + + public void verify(InputStream is, int vCardType) throws IOException, VCardException { + final VCardParser vCardParser; + if (VCardConfig.isV30(vCardType)) { + vCardParser = new VCardParser_V30(true); // use StrictParsing + } else { + vCardParser = new VCardParser_V21(); + } + verify(is, vCardType, vCardParser); + } + + public void verify(InputStream is, int vCardType, final VCardParser vCardParser) + throws IOException, VCardException { + VCardEntryConstructor builder = + new VCardEntryConstructor(null, null, false, vCardType, null); + builder.addEntryHandler(this); + try { + vCardParser.parse(is, builder); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + } + + public void onStart() { + for (ContentValuesVerifierElem elem : mContentValuesVerifierElemList) { + elem.onParsingStart(); + } + } + + public void onEntryCreated(VCardEntry entry) { + mTestCase.assertTrue(mIndex < mContentValuesVerifierElemList.size()); + mContentValuesVerifierElemList.get(mIndex).onEntryCreated(entry); + mIndex++; + } + + public void onEnd() { + for (ContentValuesVerifierElem elem : mContentValuesVerifierElemList) { + elem.onParsingEnd(); + elem.verifyResolver(); + } + } +}
\ No newline at end of file diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifierElem.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifierElem.java new file mode 100644 index 0000000..f511217 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/ContentValuesVerifierElem.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentValues; +import android.pim.vcard.VCardConfig; +import android.pim.vcard.VCardEntry; +import android.pim.vcard.VCardEntryCommitter; +import android.pim.vcard.VCardEntryConstructor; +import android.pim.vcard.VCardEntryHandler; +import android.pim.vcard.VCardParser; +import android.pim.vcard.VCardParser_V21; +import android.pim.vcard.VCardParser_V30; +import android.pim.vcard.exception.VCardException; +import android.provider.ContactsContract.Data; +import android.test.AndroidTestCase; + +import java.io.IOException; +import java.io.InputStream; + +/* package */ class ContentValuesVerifierElem { + private final AndroidTestCase mTestCase; + private final ImportTestResolver mResolver; + private final VCardEntryHandler mHandler; + + public ContentValuesVerifierElem(AndroidTestCase androidTestCase) { + mTestCase = androidTestCase; + mResolver = new ImportTestResolver(androidTestCase); + mHandler = new VCardEntryCommitter(mResolver); + } + + public ContentValuesBuilder addExpected(String mimeType) { + ContentValues contentValues = new ContentValues(); + contentValues.put(Data.MIMETYPE, mimeType); + mResolver.addExpectedContentValues(contentValues); + return new ContentValuesBuilder(contentValues); + } + + public void verify(int resId, int vCardType) + throws IOException, VCardException { + verify(mTestCase.getContext().getResources().openRawResource(resId), vCardType); + } + + public void verify(InputStream is, int vCardType) throws IOException, VCardException { + final VCardParser vCardParser; + if (VCardConfig.isV30(vCardType)) { + vCardParser = new VCardParser_V30(true); // use StrictParsing + } else { + vCardParser = new VCardParser_V21(); + } + VCardEntryConstructor builder = + new VCardEntryConstructor(null, null, false, vCardType, null); + builder.addEntryHandler(mHandler); + try { + vCardParser.parse(is, builder); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + verifyResolver(); + } + + public void verifyResolver() { + mResolver.verify(); + } + + public void onParsingStart() { + mHandler.onStart(); + } + + public void onEntryCreated(VCardEntry entry) { + mHandler.onEntryCreated(entry); + } + + public void onParsingEnd() { + mHandler.onEnd(); + } +}
\ No newline at end of file diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/ExportTestResolver.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/ExportTestResolver.java new file mode 100644 index 0000000..a76dfd8 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/ExportTestResolver.java @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Entity; +import android.content.EntityIterator; +import android.database.Cursor; +import android.net.Uri; +import android.pim.vcard.VCardComposer; +import android.provider.ContactsContract.Contacts; +import android.provider.ContactsContract.Data; +import android.provider.ContactsContract.RawContacts; +import android.test.mock.MockContentResolver; +import android.test.mock.MockCursor; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/* package */ public class ExportTestResolver extends MockContentResolver { + ExportTestProvider mProvider; + public ExportTestResolver(TestCase testCase) { + mProvider = new ExportTestProvider(testCase); + addProvider(VCardComposer.VCARD_TEST_AUTHORITY, mProvider); + addProvider(RawContacts.CONTENT_URI.getAuthority(), mProvider); + } + + public ContactEntry addInputContactEntry() { + return mProvider.buildInputEntry(); + } +} + +/* package */ class MockEntityIterator implements EntityIterator { + List<Entity> mEntityList; + Iterator<Entity> mIterator; + + public MockEntityIterator(List<ContentValues> contentValuesList) { + mEntityList = new ArrayList<Entity>(); + Entity entity = new Entity(new ContentValues()); + for (ContentValues contentValues : contentValuesList) { + entity.addSubValue(Data.CONTENT_URI, contentValues); + } + mEntityList.add(entity); + mIterator = mEntityList.iterator(); + } + + public boolean hasNext() { + return mIterator.hasNext(); + } + + public Entity next() { + return mIterator.next(); + } + + public void reset() { + mIterator = mEntityList.iterator(); + } + + public void close() { + } +} + +/** + * Represents one contact, which should contain multiple ContentValues like + * StructuredName, Email, etc. + */ +/* package */ class ContactEntry { + private final List<ContentValues> mContentValuesList = new ArrayList<ContentValues>(); + + public ContentValuesBuilder addContentValues(String mimeType) { + ContentValues contentValues = new ContentValues(); + contentValues.put(Data.MIMETYPE, mimeType); + mContentValuesList.add(contentValues); + return new ContentValuesBuilder(contentValues); + } + + public List<ContentValues> getList() { + return mContentValuesList; + } +} + +/* package */ class ExportTestProvider extends MockContentProvider { + final private TestCase mTestCase; + final private ArrayList<ContactEntry> mContactEntryList = new ArrayList<ContactEntry>(); + + public ExportTestProvider(TestCase testCase) { + mTestCase = testCase; + } + + public ContactEntry buildInputEntry() { + ContactEntry contactEntry = new ContactEntry(); + mContactEntryList.add(contactEntry); + return contactEntry; + } + + /** + * <p> + * An old method which had existed but was removed from ContentResolver. + * </p> + * <p> + * We still keep using this method since we don't have a propeer way to know + * which value in the ContentValue corresponds to the entry in Contacts database. + * </p> + * <p> + * Detail: + * There's an easy way to know which index "family name" corresponds to, via + * {@link android.provider.ContactsContract}. + * FAMILY_NAME equals DATA3, so the corresponding index + * for "family name" should be 2 (note that index is 0-origin). + * However, we cannot know what the index 2 corresponds to; it may be "family name", + * "label" for now, but may be the other some column in the future. We don't have + * convenient way to know the original data structure. + * </p> + */ + public EntityIterator queryEntities(Uri uri, + String selection, String[] selectionArgs, String sortOrder) { + mTestCase.assertTrue(uri != null); + mTestCase.assertTrue(ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())); + final String authority = uri.getAuthority(); + mTestCase.assertTrue(RawContacts.CONTENT_URI.getAuthority().equals(authority)); + mTestCase.assertTrue((Data.CONTACT_ID + "=?").equals(selection)); + mTestCase.assertEquals(1, selectionArgs.length); + final int id = Integer.parseInt(selectionArgs[0]); + mTestCase.assertTrue(id >= 0 && id < mContactEntryList.size()); + + return new MockEntityIterator(mContactEntryList.get(id).getList()); + } + + @Override + public Cursor query(Uri uri,String[] projection, + String selection, String[] selectionArgs, String sortOrder) { + mTestCase.assertTrue(VCardComposer.CONTACTS_TEST_CONTENT_URI.equals(uri)); + // In this test, following arguments are not supported. + mTestCase.assertNull(selection); + mTestCase.assertNull(selectionArgs); + mTestCase.assertNull(sortOrder); + + return new MockCursor() { + int mCurrentPosition = -1; + + @Override + public int getCount() { + return mContactEntryList.size(); + } + + @Override + public boolean moveToFirst() { + mCurrentPosition = 0; + return true; + } + + @Override + public boolean moveToNext() { + if (mCurrentPosition < mContactEntryList.size()) { + mCurrentPosition++; + return true; + } else { + return false; + } + } + + @Override + public boolean isBeforeFirst() { + return mCurrentPosition < 0; + } + + @Override + public boolean isAfterLast() { + return mCurrentPosition >= mContactEntryList.size(); + } + + @Override + public int getColumnIndex(String columnName) { + mTestCase.assertEquals(Contacts._ID, columnName); + return 0; + } + + @Override + public int getInt(int columnIndex) { + mTestCase.assertEquals(0, columnIndex); + mTestCase.assertTrue(mCurrentPosition >= 0 + && mCurrentPosition < mContactEntryList.size()); + return mCurrentPosition; + } + + @Override + public String getString(int columnIndex) { + return String.valueOf(getInt(columnIndex)); + } + + @Override + public void close() { + } + }; + } +}
\ No newline at end of file diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/ImportTestResolver.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/ImportTestResolver.java new file mode 100644 index 0000000..a1e9d75 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/ImportTestResolver.java @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentProviderOperation; +import android.content.ContentProviderResult; +import android.content.ContentValues; +import android.net.Uri; +import android.provider.ContactsContract.Data; +import android.provider.ContactsContract.RawContacts; +import android.provider.ContactsContract.CommonDataKinds.Email; +import android.provider.ContactsContract.CommonDataKinds.Event; +import android.provider.ContactsContract.CommonDataKinds.GroupMembership; +import android.provider.ContactsContract.CommonDataKinds.Im; +import android.provider.ContactsContract.CommonDataKinds.Nickname; +import android.provider.ContactsContract.CommonDataKinds.Note; +import android.provider.ContactsContract.CommonDataKinds.Organization; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.CommonDataKinds.Photo; +import android.provider.ContactsContract.CommonDataKinds.Relation; +import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; +import android.provider.ContactsContract.CommonDataKinds.Website; +import android.test.mock.MockContentResolver; +import android.text.TextUtils; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.Map.Entry; + +/* package */ class ImportTestResolver extends MockContentResolver { + final ImportTestProvider mProvider; + + public ImportTestResolver(TestCase testCase) { + mProvider = new ImportTestProvider(testCase); + } + + @Override + public ContentProviderResult[] applyBatch(String authority, + ArrayList<ContentProviderOperation> operations) { + equalsString(authority, RawContacts.CONTENT_URI.toString()); + return mProvider.applyBatch(operations); + } + + public void addExpectedContentValues(ContentValues expectedContentValues) { + mProvider.addExpectedContentValues(expectedContentValues); + } + + public void verify() { + mProvider.verify(); + } + + private static boolean equalsString(String a, String b) { + if (a == null || a.length() == 0) { + return b == null || b.length() == 0; + } else { + return a.equals(b); + } + } +} + +/* package */ class ImportTestProvider extends MockContentProvider { + private static final Set<String> sKnownMimeTypeSet = + new HashSet<String>(Arrays.asList(StructuredName.CONTENT_ITEM_TYPE, + Nickname.CONTENT_ITEM_TYPE, Phone.CONTENT_ITEM_TYPE, + Email.CONTENT_ITEM_TYPE, StructuredPostal.CONTENT_ITEM_TYPE, + Im.CONTENT_ITEM_TYPE, Organization.CONTENT_ITEM_TYPE, + Event.CONTENT_ITEM_TYPE, Photo.CONTENT_ITEM_TYPE, + Note.CONTENT_ITEM_TYPE, Website.CONTENT_ITEM_TYPE, + Relation.CONTENT_ITEM_TYPE, Event.CONTENT_ITEM_TYPE, + GroupMembership.CONTENT_ITEM_TYPE)); + + final Map<String, Collection<ContentValues>> mMimeTypeToExpectedContentValues; + + private final TestCase mTestCase; + + public ImportTestProvider(TestCase testCase) { + mTestCase = testCase; + mMimeTypeToExpectedContentValues = + new HashMap<String, Collection<ContentValues>>(); + for (String acceptanbleMimeType : sKnownMimeTypeSet) { + // Do not use HashSet since the current implementation changes the content of + // ContentValues after the insertion, which make the result of hashCode() + // changes... + mMimeTypeToExpectedContentValues.put( + acceptanbleMimeType, new ArrayList<ContentValues>()); + } + } + + public void addExpectedContentValues(ContentValues expectedContentValues) { + final String mimeType = expectedContentValues.getAsString(Data.MIMETYPE); + if (!sKnownMimeTypeSet.contains(mimeType)) { + mTestCase.fail(String.format( + "Unknow MimeType %s in the test code. Test code should be broken.", + mimeType)); + } + + final Collection<ContentValues> contentValuesCollection = + mMimeTypeToExpectedContentValues.get(mimeType); + contentValuesCollection.add(expectedContentValues); + } + + @Override + public ContentProviderResult[] applyBatch( + ArrayList<ContentProviderOperation> operations) { + if (operations == null) { + mTestCase.fail("There is no operation."); + } + + final int size = operations.size(); + ContentProviderResult[] fakeResultArray = new ContentProviderResult[size]; + for (int i = 0; i < size; i++) { + Uri uri = Uri.withAppendedPath(RawContacts.CONTENT_URI, String.valueOf(i)); + fakeResultArray[i] = new ContentProviderResult(uri); + } + + for (int i = 0; i < size; i++) { + ContentProviderOperation operation = operations.get(i); + ContentValues contentValues = operation.resolveValueBackReferences( + fakeResultArray, i); + } + for (int i = 0; i < size; i++) { + ContentProviderOperation operation = operations.get(i); + ContentValues actualContentValues = operation.resolveValueBackReferences( + fakeResultArray, i); + final Uri uri = operation.getUri(); + if (uri.equals(RawContacts.CONTENT_URI)) { + mTestCase.assertNull(actualContentValues.get(RawContacts.ACCOUNT_NAME)); + mTestCase.assertNull(actualContentValues.get(RawContacts.ACCOUNT_TYPE)); + } else if (uri.equals(Data.CONTENT_URI)) { + final String mimeType = actualContentValues.getAsString(Data.MIMETYPE); + if (!sKnownMimeTypeSet.contains(mimeType)) { + mTestCase.fail(String.format( + "Unknown MimeType %s. Probably added after developing this test", + mimeType)); + } + // Remove data meaningless in this unit tests. + // Specifically, Data.DATA1 - DATA7 are set to null or empty String + // regardless of the input, but it may change depending on how + // resolver-related code handles it. + // Here, we ignore these implementation-dependent specs and + // just check whether vCard importer correctly inserts rellevent data. + Set<String> keyToBeRemoved = new HashSet<String>(); + for (Entry<String, Object> entry : actualContentValues.valueSet()) { + Object value = entry.getValue(); + if (value == null || TextUtils.isEmpty(value.toString())) { + keyToBeRemoved.add(entry.getKey()); + } + } + for (String key: keyToBeRemoved) { + actualContentValues.remove(key); + } + /* for testing + Log.d("@@@", + String.format("MimeType: %s, data: %s", + mimeType, actualContentValues.toString())); */ + // Remove RAW_CONTACT_ID entry just for safety, since we do not care + // how resolver-related code handles the entry in this unit test, + if (actualContentValues.containsKey(Data.RAW_CONTACT_ID)) { + actualContentValues.remove(Data.RAW_CONTACT_ID); + } + final Collection<ContentValues> contentValuesCollection = + mMimeTypeToExpectedContentValues.get(mimeType); + if (contentValuesCollection.isEmpty()) { + mTestCase.fail("ContentValues for MimeType " + mimeType + + " is not expected at all (" + actualContentValues + ")"); + } + boolean checked = false; + for (ContentValues expectedContentValues : contentValuesCollection) { + /*for testing + Log.d("@@@", "expected: " + + convertToEasilyReadableString(expectedContentValues)); + Log.d("@@@", "actual : " + + convertToEasilyReadableString(actualContentValues));*/ + if (equalsForContentValues(expectedContentValues, + actualContentValues)) { + mTestCase.assertTrue(contentValuesCollection.remove(expectedContentValues)); + checked = true; + break; + } + } + if (!checked) { + final StringBuilder builder = new StringBuilder(); + builder.append("Unexpected: "); + builder.append(convertToEasilyReadableString(actualContentValues)); + builder.append("\nExpected: "); + for (ContentValues expectedContentValues : contentValuesCollection) { + builder.append(convertToEasilyReadableString(expectedContentValues)); + } + mTestCase.fail(builder.toString()); + } + } else { + mTestCase.fail("Unexpected Uri has come: " + uri); + } + } // for (int i = 0; i < size; i++) { + return null; + } + + public void verify() { + StringBuilder builder = new StringBuilder(); + for (Collection<ContentValues> contentValuesCollection : + mMimeTypeToExpectedContentValues.values()) { + for (ContentValues expectedContentValues: contentValuesCollection) { + builder.append(convertToEasilyReadableString(expectedContentValues)); + builder.append("\n"); + } + } + if (builder.length() > 0) { + final String failMsg = + "There is(are) remaining expected ContentValues instance(s): \n" + + builder.toString(); + mTestCase.fail(failMsg); + } + } + + /** + * Utility method to print ContentValues whose content is printed with sorted keys. + */ + private String convertToEasilyReadableString(ContentValues contentValues) { + if (contentValues == null) { + return "null"; + } + String mimeTypeValue = ""; + SortedMap<String, String> sortedMap = new TreeMap<String, String>(); + for (Entry<String, Object> entry : contentValues.valueSet()) { + final String key = entry.getKey(); + final Object value = entry.getValue(); + final String valueString = (value != null ? value.toString() : null); + if (Data.MIMETYPE.equals(key)) { + mimeTypeValue = valueString; + } else { + mTestCase.assertNotNull(key); + sortedMap.put(key, valueString); + } + } + StringBuilder builder = new StringBuilder(); + builder.append(Data.MIMETYPE); + builder.append('='); + builder.append(mimeTypeValue); + for (Entry<String, String> entry : sortedMap.entrySet()) { + final String key = entry.getKey(); + final String value = entry.getValue(); + builder.append(' '); + builder.append(key); + builder.append("=\""); + builder.append(value); + builder.append('"'); + } + return builder.toString(); + } + + private static boolean equalsForContentValues( + ContentValues expected, ContentValues actual) { + if (expected == actual) { + return true; + } else if (expected == null || actual == null || expected.size() != actual.size()) { + return false; + } + + for (Entry<String, Object> entry : expected.valueSet()) { + final String key = entry.getKey(); + final Object value = entry.getValue(); + if (!actual.containsKey(key)) { + return false; + } + if (value instanceof byte[]) { + Object actualValue = actual.get(key); + if (!Arrays.equals((byte[])value, (byte[])actualValue)) { + return false; + } + } else if (!value.equals(actual.get(key))) { + return false; + } + } + return true; + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifier.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifier.java new file mode 100644 index 0000000..27b95a6 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifier.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.content.Context; +import android.pim.vcard.VCardComposer; + +import junit.framework.TestCase; + +import java.util.ArrayList; + +class LineVerifier implements VCardComposer.OneEntryHandler { + private final TestCase mTestCase; + private final ArrayList<LineVerifierElem> mLineVerifierElemList; + private int mVCardType; + private int index; + + public LineVerifier(TestCase testCase, int vcardType) { + mTestCase = testCase; + mLineVerifierElemList = new ArrayList<LineVerifierElem>(); + mVCardType = vcardType; + } + + public LineVerifierElem addLineVerifierElem() { + LineVerifierElem lineVerifier = new LineVerifierElem(mTestCase, mVCardType); + mLineVerifierElemList.add(lineVerifier); + return lineVerifier; + } + + public void verify(String vcard) { + if (index >= mLineVerifierElemList.size()) { + mTestCase.fail("Insufficient number of LineVerifier (" + index + ")"); + } + + LineVerifierElem lineVerifier = mLineVerifierElemList.get(index); + lineVerifier.verify(vcard); + + index++; + } + + public boolean onEntryCreated(String vcard) { + verify(vcard); + return true; + } + + public boolean onInit(Context context) { + return true; + } + + public void onTerminate() { + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifierElem.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifierElem.java new file mode 100644 index 0000000..fc478afcf --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/LineVerifierElem.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.android.unit_tests.vcard; + +import android.pim.vcard.VCardConfig; +import android.text.TextUtils; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.List; + +class LineVerifierElem { + private final TestCase mTestCase; + private final List<String> mExpectedLineList = new ArrayList<String>(); + private final boolean mIsV30; + + public LineVerifierElem(TestCase testCase, int vcardType) { + mTestCase = testCase; + mIsV30 = VCardConfig.isV30(vcardType); + } + + public LineVerifierElem addExpected(final String line) { + if (!TextUtils.isEmpty(line)) { + mExpectedLineList.add(line); + } + return this; + } + + public void verify(final String vcard) { + final String[] lineArray = vcard.split("\\r?\\n"); + final int length = lineArray.length; + boolean beginExists = false; + boolean endExists = false; + boolean versionExists = false; + + for (int i = 0; i < length; i++) { + final String line = lineArray[i]; + if (TextUtils.isEmpty(line)) { + continue; + } + + if ("BEGIN:VCARD".equalsIgnoreCase(line)) { + if (beginExists) { + mTestCase.fail("Multiple \"BEGIN:VCARD\" line found"); + } else { + beginExists = true; + continue; + } + } else if ("END:VCARD".equalsIgnoreCase(line)) { + if (endExists) { + mTestCase.fail("Multiple \"END:VCARD\" line found"); + } else { + endExists = true; + continue; + } + } else if ((mIsV30 ? "VERSION:3.0" : "VERSION:2.1").equalsIgnoreCase(line)) { + if (versionExists) { + mTestCase.fail("Multiple VERSION line + found"); + } else { + versionExists = true; + continue; + } + } + + if (!beginExists) { + mTestCase.fail("Property other than BEGIN came before BEGIN property: " + + line); + } else if (endExists) { + mTestCase.fail("Property other than END came after END property: " + + line); + } + + final int index = mExpectedLineList.indexOf(line); + if (index >= 0) { + mExpectedLineList.remove(index); + } else { + mTestCase.fail("Unexpected line: " + line); + } + } + + if (!mExpectedLineList.isEmpty()) { + StringBuffer buffer = new StringBuffer(); + for (String expectedLine : mExpectedLineList) { + buffer.append(expectedLine); + buffer.append("\n"); + } + + mTestCase.fail("Expected line(s) not found:" + buffer.toString()); + } + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNode.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNode.java index 0ee74df..14a789a 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNode.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNode.java @@ -16,19 +16,22 @@ package com.android.unit_tests.vcard; import android.content.ContentValues; - -import org.apache.commons.codec.binary.Base64; +import android.pim.vcard.VCardEntry; +import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.Map.Entry; -import java.util.regex.Pattern; /** - * @hide old class just for test + * Previously used in main vCard handling code but now exists only for testing. + * + * Especially useful for testing parser code (VCardParser), since all properties can be + * checked via this class unlike {@link VCardEntry}, which only emits the result of + * interpretation of the content of each vCard. We cannot know whether vCard parser or + * ContactStruct is wrong withouth this class. */ public class PropertyNode { public String propName; @@ -101,6 +104,15 @@ public class PropertyNode { } @Override + public int hashCode() { + // vCard may contain more than one same line in one entry, while HashSet or any other + // library which utilize hashCode() does not honor that, so intentionally throw an + // Exception. + throw new UnsupportedOperationException( + "PropertyNode does not provide hashCode() implementation intentionally."); + } + + @Override public boolean equals(Object obj) { if (!(obj instanceof PropertyNode)) { return false; @@ -110,18 +122,17 @@ public class PropertyNode { if (propName == null || !propName.equals(node.propName)) { return false; - } else if (!paramMap.equals(node.paramMap)) { + } else if (!paramMap_TYPE.equals(node.paramMap_TYPE)) { return false; } else if (!paramMap_TYPE.equals(node.paramMap_TYPE)) { return false; } else if (!propGroupSet.equals(node.propGroupSet)) { return false; } - + if (propValue_bytes != null && Arrays.equals(propValue_bytes, node.propValue_bytes)) { return true; } else { - // Log.d("@@@", propValue + ", " + node.propValue); if (!propValue.equals(node.propValue)) { return false; } @@ -143,10 +154,34 @@ public class PropertyNode { builder.append(propName); builder.append(", paramMap: "); builder.append(paramMap.toString()); - builder.append(", propmMap_TYPE: "); - builder.append(paramMap_TYPE.toString()); - builder.append(", propGroupSet: "); - builder.append(propGroupSet.toString()); + builder.append(", paramMap_TYPE: ["); + boolean first = true; + for (String elem : paramMap_TYPE) { + if (first) { + first = false; + } else { + builder.append(", "); + } + builder.append('"'); + builder.append(elem); + builder.append('"'); + } + builder.append("]"); + if (!propGroupSet.isEmpty()) { + builder.append(", propGroupSet: ["); + first = true; + for (String elem : propGroupSet) { + if (first) { + first = false; + } else { + builder.append(", "); + } + builder.append('"'); + builder.append(elem); + builder.append('"'); + } + builder.append("]"); + } if (propValue_vector != null && propValue_vector.size() > 1) { builder.append(", propValue_vector size: "); builder.append(propValue_vector.size()); @@ -155,168 +190,9 @@ public class PropertyNode { builder.append(", propValue_bytes size: "); builder.append(propValue_bytes.length); } - builder.append(", propValue: "); + builder.append(", propValue: \""); builder.append(propValue); + builder.append("\""); return builder.toString(); } - - /** - * Encode this object into a string which can be decoded. - */ - public String encode() { - // PropertyNode#toString() is for reading, not for parsing in the future. - // We construct appropriate String here. - StringBuilder builder = new StringBuilder(); - if (propName.length() > 0) { - builder.append("propName:["); - builder.append(propName); - builder.append("],"); - } - int size = propGroupSet.size(); - if (size > 0) { - Set<String> set = propGroupSet; - builder.append("propGroup:["); - int i = 0; - for (String group : set) { - // We do not need to double quote groups. - // group = 1*(ALPHA / DIGIT / "-") - builder.append(group); - if (i < size - 1) { - builder.append(","); - } - i++; - } - builder.append("],"); - } - - if (paramMap.size() > 0 || paramMap_TYPE.size() > 0) { - ContentValues values = paramMap; - builder.append("paramMap:["); - size = paramMap.size(); - int i = 0; - for (Entry<String, Object> entry : values.valueSet()) { - // Assuming param-key does not contain NON-ASCII nor symbols. - // - // According to vCard 3.0: - // param-name = iana-token / x-name - builder.append(entry.getKey()); - - // param-value may contain any value including NON-ASCIIs. - // We use the following replacing rule. - // \ -> \\ - // , -> \, - // In String#replaceAll(), "\\\\" means a single backslash. - builder.append("="); - builder.append(entry.getValue().toString() - .replaceAll("\\\\", "\\\\\\\\") - .replaceAll(",", "\\\\,")); - if (i < size -1) { - builder.append(","); - } - i++; - } - - Set<String> set = paramMap_TYPE; - size = paramMap_TYPE.size(); - if (i > 0 && size > 0) { - builder.append(","); - } - i = 0; - for (String type : set) { - builder.append("TYPE="); - builder.append(type - .replaceAll("\\\\", "\\\\\\\\") - .replaceAll(",", "\\\\,")); - if (i < size - 1) { - builder.append(","); - } - i++; - } - builder.append("],"); - } - - size = propValue_vector.size(); - if (size > 0) { - builder.append("propValue:["); - List<String> list = propValue_vector; - for (int i = 0; i < size; i++) { - builder.append(list.get(i) - .replaceAll("\\\\", "\\\\\\\\") - .replaceAll(",", "\\\\,")); - if (i < size -1) { - builder.append(","); - } - } - builder.append("],"); - } - - return builder.toString(); - } - - public static PropertyNode decode(String encodedString) { - PropertyNode propertyNode = new PropertyNode(); - String trimed = encodedString.trim(); - if (trimed.length() == 0) { - return propertyNode; - } - String[] elems = trimed.split("],"); - - for (String elem : elems) { - int index = elem.indexOf('['); - String name = elem.substring(0, index - 1); - Pattern pattern = Pattern.compile("(?<!\\\\),"); - String[] values = pattern.split(elem.substring(index + 1), -1); - if (name.equals("propName")) { - propertyNode.propName = values[0]; - } else if (name.equals("propGroupSet")) { - for (String value : values) { - propertyNode.propGroupSet.add(value); - } - } else if (name.equals("paramMap")) { - ContentValues paramMap = propertyNode.paramMap; - Set<String> paramMap_TYPE = propertyNode.paramMap_TYPE; - for (String value : values) { - String[] tmp = value.split("=", 2); - String mapKey = tmp[0]; - // \, -> , - // \\ -> \ - // In String#replaceAll(), "\\\\" means a single backslash. - String mapValue = - tmp[1].replaceAll("\\\\,", ",").replaceAll("\\\\\\\\", "\\\\"); - if (mapKey.equalsIgnoreCase("TYPE")) { - paramMap_TYPE.add(mapValue); - } else { - paramMap.put(mapKey, mapValue); - } - } - } else if (name.equals("propValue")) { - StringBuilder builder = new StringBuilder(); - List<String> list = propertyNode.propValue_vector; - int length = values.length; - for (int i = 0; i < length; i++) { - String normValue = values[i] - .replaceAll("\\\\,", ",") - .replaceAll("\\\\\\\\", "\\\\"); - list.add(normValue); - builder.append(normValue); - if (i < length - 1) { - builder.append(";"); - } - } - propertyNode.propValue = builder.toString(); - } - } - - // At this time, QUOTED-PRINTABLE is already decoded to Java String. - // We just need to decode BASE64 String to binary. - String encoding = propertyNode.paramMap.getAsString("ENCODING"); - if (encoding != null && - (encoding.equalsIgnoreCase("BASE64") || - encoding.equalsIgnoreCase("B"))) { - propertyNode.propValue_bytes = - Base64.decodeBase64(propertyNode.propValue_vector.get(0).getBytes()); - } - - return propertyNode; - } } diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java new file mode 100644 index 0000000..0afad49 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/PropertyNodesVerifier.java @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentValues; +import android.pim.vcard.VCardConfig; +import android.pim.vcard.VCardParser; +import android.pim.vcard.VCardParser_V21; +import android.pim.vcard.VCardParser_V30; +import android.pim.vcard.exception.VCardException; +import android.test.AndroidTestCase; + +import junit.framework.TestCase; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +/* package */ class PropertyNodesVerifier extends VNodeBuilder { + private final List<PropertyNodesVerifierElem> mPropertyNodesVerifierElemList; + private final AndroidTestCase mAndroidTestCase; + private int mIndex; + + public PropertyNodesVerifier(AndroidTestCase testCase) { + mPropertyNodesVerifierElemList = new ArrayList<PropertyNodesVerifierElem>(); + mAndroidTestCase = testCase; + } + + public PropertyNodesVerifierElem addPropertyNodesVerifierElem() { + PropertyNodesVerifierElem elem = new PropertyNodesVerifierElem(mAndroidTestCase); + mPropertyNodesVerifierElemList.add(elem); + return elem; + } + + public void verify(int resId, int vCardType) + throws IOException, VCardException { + verify(mAndroidTestCase.getContext().getResources().openRawResource(resId), vCardType); + } + + public void verify(int resId, int vCardType, final VCardParser vCardParser) + throws IOException, VCardException { + verify(mAndroidTestCase.getContext().getResources().openRawResource(resId), + vCardType, vCardParser); + } + + public void verify(InputStream is, int vCardType) throws IOException, VCardException { + final VCardParser vCardParser; + if (VCardConfig.isV30(vCardType)) { + vCardParser = new VCardParser_V30(true); // Use StrictParsing. + } else { + vCardParser = new VCardParser_V21(); + } + verify(is, vCardType, vCardParser); + } + + public void verify(InputStream is, int vCardType, final VCardParser vCardParser) + throws IOException, VCardException { + try { + vCardParser.parse(is, this); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + } + + @Override + public void endEntry() { + super.endEntry(); + mAndroidTestCase.assertTrue(mIndex < mPropertyNodesVerifierElemList.size()); + mAndroidTestCase.assertTrue(mIndex < vNodeList.size()); + mPropertyNodesVerifierElemList.get(mIndex).verify(vNodeList.get(mIndex)); + mIndex++; + } +} + +/** + * Utility class which verifies input VNode. + * + * This class first checks whether each propertyNode in the VNode is in the + * "ordered expected property list". + * If the node does not exist in the "ordered list", the class refers to + * "unorderd expected property set" and checks the node is expected somewhere. + */ +/* package */ class PropertyNodesVerifierElem { + public static class TypeSet extends HashSet<String> { + public TypeSet(String ... array) { + super(Arrays.asList(array)); + } + } + + public static class GroupSet extends HashSet<String> { + public GroupSet(String ... array) { + super(Arrays.asList(array)); + } + } + + private final HashMap<String, List<PropertyNode>> mOrderedNodeMap; + // Intentionally use ArrayList instead of Set, assuming there may be more than one + // exactly same objects. + private final ArrayList<PropertyNode> mUnorderedNodeList; + private final TestCase mTestCase; + + public PropertyNodesVerifierElem(TestCase testCase) { + mOrderedNodeMap = new HashMap<String, List<PropertyNode>>(); + mUnorderedNodeList = new ArrayList<PropertyNode>(); + mTestCase = testCase; + } + + // WithOrder + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, String propValue) { + return addExpectedNodeWithOrder(propName, propValue, null, null, null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder( + String propName, String propValue, ContentValues contentValues) { + return addExpectedNodeWithOrder(propName, propValue, null, + null, contentValues, null, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder( + String propName, List<String> propValueList, ContentValues contentValues) { + return addExpectedNodeWithOrder(propName, null, propValueList, + null, contentValues, null, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder( + String propName, String propValue, List<String> propValueList) { + return addExpectedNodeWithOrder(propName, propValue, propValueList, null, + null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder( + String propName, List<String> propValueList) { + final String propValue = concatinateListWithSemiColon(propValueList); + return addExpectedNodeWithOrder(propName, propValue.toString(), propValueList, + null, null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, String propValue, + TypeSet paramMap_TYPE) { + return addExpectedNodeWithOrder(propName, propValue, null, + null, null, paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, + List<String> propValueList, TypeSet paramMap_TYPE) { + return addExpectedNodeWithOrder(propName, null, propValueList, null, null, + paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, String propValue, + ContentValues paramMap, TypeSet paramMap_TYPE) { + return addExpectedNodeWithOrder(propName, propValue, null, null, + paramMap, paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, String propValue, + List<String> propValueList, TypeSet paramMap_TYPE) { + return addExpectedNodeWithOrder(propName, propValue, propValueList, null, null, + paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNodeWithOrder(String propName, String propValue, + List<String> propValueList, byte[] propValue_bytes, + ContentValues paramMap, TypeSet paramMap_TYPE, GroupSet propGroupSet) { + if (propValue == null && propValueList != null) { + propValue = concatinateListWithSemiColon(propValueList); + } + PropertyNode propertyNode = new PropertyNode(propName, + propValue, propValueList, propValue_bytes, + paramMap, paramMap_TYPE, propGroupSet); + List<PropertyNode> expectedNodeList = mOrderedNodeMap.get(propName); + if (expectedNodeList == null) { + expectedNodeList = new ArrayList<PropertyNode>(); + mOrderedNodeMap.put(propName, expectedNodeList); + } + expectedNodeList.add(propertyNode); + return this; + } + + // WithoutOrder + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue) { + return addExpectedNode(propName, propValue, null, null, null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + ContentValues contentValues) { + return addExpectedNode(propName, propValue, null, null, contentValues, null, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, + List<String> propValueList, ContentValues contentValues) { + return addExpectedNode(propName, null, + propValueList, null, contentValues, null, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + List<String> propValueList) { + return addExpectedNode(propName, propValue, propValueList, null, null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, + List<String> propValueList) { + return addExpectedNode(propName, null, propValueList, + null, null, null, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + TypeSet paramMap_TYPE) { + return addExpectedNode(propName, propValue, null, null, null, paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, + List<String> propValueList, TypeSet paramMap_TYPE) { + final String propValue = concatinateListWithSemiColon(propValueList); + return addExpectedNode(propName, propValue, propValueList, null, null, + paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + List<String> propValueList, TypeSet paramMap_TYPE) { + return addExpectedNode(propName, propValue, propValueList, null, null, + paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + ContentValues paramMap, TypeSet paramMap_TYPE) { + return addExpectedNode(propName, propValue, null, null, + paramMap, paramMap_TYPE, null); + } + + public PropertyNodesVerifierElem addExpectedNode(String propName, String propValue, + List<String> propValueList, byte[] propValue_bytes, + ContentValues paramMap, TypeSet paramMap_TYPE, GroupSet propGroupSet) { + if (propValue == null && propValueList != null) { + propValue = concatinateListWithSemiColon(propValueList); + } + mUnorderedNodeList.add(new PropertyNode(propName, propValue, + propValueList, propValue_bytes, paramMap, paramMap_TYPE, propGroupSet)); + return this; + } + + public void verify(VNode vnode) { + for (PropertyNode actualNode : vnode.propList) { + verifyNode(actualNode.propName, actualNode); + } + if (!mOrderedNodeMap.isEmpty() || !mUnorderedNodeList.isEmpty()) { + List<String> expectedProps = new ArrayList<String>(); + for (List<PropertyNode> nodes : mOrderedNodeMap.values()) { + for (PropertyNode node : nodes) { + if (!expectedProps.contains(node.propName)) { + expectedProps.add(node.propName); + } + } + } + for (PropertyNode node : mUnorderedNodeList) { + if (!expectedProps.contains(node.propName)) { + expectedProps.add(node.propName); + } + } + mTestCase.fail("Expected property " + Arrays.toString(expectedProps.toArray()) + + " was not found."); + } + } + + private void verifyNode(final String propName, final PropertyNode actualNode) { + List<PropertyNode> expectedNodeList = mOrderedNodeMap.get(propName); + final int size = (expectedNodeList != null ? expectedNodeList.size() : 0); + if (size > 0) { + for (int i = 0; i < size; i++) { + PropertyNode expectedNode = expectedNodeList.get(i); + List<PropertyNode> expectedButDifferentValueList = new ArrayList<PropertyNode>(); + if (expectedNode.propName.equals(propName)) { + if (expectedNode.equals(actualNode)) { + expectedNodeList.remove(i); + if (expectedNodeList.size() == 0) { + mOrderedNodeMap.remove(propName); + } + return; + } else { + expectedButDifferentValueList.add(expectedNode); + } + } + + // "actualNode" is not in ordered expected list. + // Try looking over unordered expected list. + if (tryFoundExpectedNodeFromUnorderedList(actualNode, + expectedButDifferentValueList)) { + return; + } + + if (!expectedButDifferentValueList.isEmpty()) { + // Same propName exists but with different value(s). + failWithExpectedNodeList(propName, actualNode, + expectedButDifferentValueList); + } else { + // There's no expected node with same propName. + mTestCase.fail("Unexpected property \"" + propName + "\" exists."); + } + } + } else { + List<PropertyNode> expectedButDifferentValueList = + new ArrayList<PropertyNode>(); + if (tryFoundExpectedNodeFromUnorderedList(actualNode, expectedButDifferentValueList)) { + return; + } else { + if (!expectedButDifferentValueList.isEmpty()) { + // Same propName exists but with different value(s). + failWithExpectedNodeList(propName, actualNode, + expectedButDifferentValueList); + } else { + // There's no expected node with same propName. + mTestCase.fail("Unexpected property \"" + propName + "\" exists."); + } + } + } + } + + private String concatinateListWithSemiColon(List<String> array) { + StringBuffer buffer = new StringBuffer(); + boolean first = true; + for (String propValueElem : array) { + if (first) { + first = false; + } else { + buffer.append(';'); + } + buffer.append(propValueElem); + } + + return buffer.toString(); + } + + private boolean tryFoundExpectedNodeFromUnorderedList(PropertyNode actualNode, + List<PropertyNode> expectedButDifferentValueList) { + final String propName = actualNode.propName; + int unorderedListSize = mUnorderedNodeList.size(); + for (int i = 0; i < unorderedListSize; i++) { + PropertyNode unorderedExpectedNode = mUnorderedNodeList.get(i); + if (unorderedExpectedNode.propName.equals(propName)) { + if (unorderedExpectedNode.equals(actualNode)) { + mUnorderedNodeList.remove(i); + return true; + } + expectedButDifferentValueList.add(unorderedExpectedNode); + } + } + return false; + } + + private void failWithExpectedNodeList(String propName, PropertyNode actualNode, + List<PropertyNode> expectedNodeList) { + StringBuilder builder = new StringBuilder(); + for (PropertyNode expectedNode : expectedNodeList) { + builder.append("expected: "); + builder.append(expectedNode.toString()); + builder.append("\n"); + } + mTestCase.fail("Property \"" + propName + "\" has wrong value.\n" + + builder.toString() + + " actual: " + actualNode.toString()); + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java new file mode 100644 index 0000000..e744a92 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardExporterTests.java @@ -0,0 +1,959 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.vcard; + +import android.content.ContentValues; +import android.pim.vcard.VCardConfig; +import android.provider.ContactsContract.CommonDataKinds.Email; +import android.provider.ContactsContract.CommonDataKinds.Event; +import android.provider.ContactsContract.CommonDataKinds.Im; +import android.provider.ContactsContract.CommonDataKinds.Nickname; +import android.provider.ContactsContract.CommonDataKinds.Note; +import android.provider.ContactsContract.CommonDataKinds.Organization; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.CommonDataKinds.Photo; +import android.provider.ContactsContract.CommonDataKinds.Relation; +import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; +import android.provider.ContactsContract.CommonDataKinds.Website; + +import com.android.unit_tests.vcard.PropertyNodesVerifierElem.TypeSet; + +import java.util.Arrays; + +/** + * Tests for the code related to vCard exporter, inculding vCard composer. + * This test class depends on vCard importer code, so if tests for vCard importer fail, + * the result of this class will not be reliable. + */ +public class VCardExporterTests extends VCardTestsBase { + private static final byte[] sPhotoByteArray = + VCardImporterTests.sPhotoByteArrayForComplicatedCase; + + public void testSimpleV21() { + mVerifier.initForExportTest(V21); + mVerifier.addInputEntry().addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Ando") + .put(StructuredName.GIVEN_NAME, "Roid"); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("FN", "Roid Ando") + .addExpectedNode("N", "Ando;Roid;;;", + Arrays.asList("Ando", "Roid", "", "", "")); + } + + private void testStructuredNameBasic(int vcardType) { + final boolean isV30 = VCardConfig.isV30(vcardType); + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "AppropriateFamilyName") + .put(StructuredName.GIVEN_NAME, "AppropriateGivenName") + .put(StructuredName.MIDDLE_NAME, "AppropriateMiddleName") + .put(StructuredName.PREFIX, "AppropriatePrefix") + .put(StructuredName.SUFFIX, "AppropriateSuffix") + .put(StructuredName.PHONETIC_FAMILY_NAME, "AppropriatePhoneticFamily") + .put(StructuredName.PHONETIC_GIVEN_NAME, "AppropriatePhoneticGiven") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "AppropriatePhoneticMiddle"); + + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("N", + "AppropriateFamilyName;AppropriateGivenName;AppropriateMiddleName;" + + "AppropriatePrefix;AppropriateSuffix", + Arrays.asList("AppropriateFamilyName", "AppropriateGivenName", + "AppropriateMiddleName", "AppropriatePrefix", "AppropriateSuffix")) + .addExpectedNodeWithOrder("FN", + "AppropriatePrefix AppropriateGivenName " + + "AppropriateMiddleName AppropriateFamilyName AppropriateSuffix") + .addExpectedNode("X-PHONETIC-FIRST-NAME", "AppropriatePhoneticGiven") + .addExpectedNode("X-PHONETIC-MIDDLE-NAME", "AppropriatePhoneticMiddle") + .addExpectedNode("X-PHONETIC-LAST-NAME", "AppropriatePhoneticFamily"); + + if (isV30) { + elem.addExpectedNode("SORT-STRING", + "AppropriatePhoneticGiven AppropriatePhoneticMiddle " + + "AppropriatePhoneticFamily"); + } + } + + public void testStructuredNameBasicV21() { + testStructuredNameBasic(V21); + } + + public void testStructuredNameBasicV30() { + testStructuredNameBasic(V30); + } + + /** + * Test that only "primary" StructuredName is emitted, so that our vCard file + * will not confuse the external importer, assuming there may be some importer + * which presume that there's only one property toward each of "N", "FN", etc. + * Note that more than one "N", "FN", etc. properties are acceptable in vCard spec. + */ + private void testStructuredNameUsePrimaryCommon(int vcardType) { + final boolean isV30 = (vcardType == V30); + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "DoNotEmitFamilyName1") + .put(StructuredName.GIVEN_NAME, "DoNotEmitGivenName1") + .put(StructuredName.MIDDLE_NAME, "DoNotEmitMiddleName1") + .put(StructuredName.PREFIX, "DoNotEmitPrefix1") + .put(StructuredName.SUFFIX, "DoNotEmitSuffix1") + .put(StructuredName.PHONETIC_FAMILY_NAME, "DoNotEmitPhoneticFamily1") + .put(StructuredName.PHONETIC_GIVEN_NAME, "DoNotEmitPhoneticGiven1") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "DoNotEmitPhoneticMiddle1"); + + // With "IS_PRIMARY=1". This is what we should use. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "AppropriateFamilyName") + .put(StructuredName.GIVEN_NAME, "AppropriateGivenName") + .put(StructuredName.MIDDLE_NAME, "AppropriateMiddleName") + .put(StructuredName.PREFIX, "AppropriatePrefix") + .put(StructuredName.SUFFIX, "AppropriateSuffix") + .put(StructuredName.PHONETIC_FAMILY_NAME, "AppropriatePhoneticFamily") + .put(StructuredName.PHONETIC_GIVEN_NAME, "AppropriatePhoneticGiven") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "AppropriatePhoneticMiddle") + .put(StructuredName.IS_PRIMARY, 1); + + // With "IS_PRIMARY=1", but we should ignore this time, since this is second, not first. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "DoNotEmitFamilyName2") + .put(StructuredName.GIVEN_NAME, "DoNotEmitGivenName2") + .put(StructuredName.MIDDLE_NAME, "DoNotEmitMiddleName2") + .put(StructuredName.PREFIX, "DoNotEmitPrefix2") + .put(StructuredName.SUFFIX, "DoNotEmitSuffix2") + .put(StructuredName.PHONETIC_FAMILY_NAME, "DoNotEmitPhoneticFamily2") + .put(StructuredName.PHONETIC_GIVEN_NAME, "DoNotEmitPhoneticGiven2") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "DoNotEmitPhoneticMiddle2") + .put(StructuredName.IS_PRIMARY, 1); + + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("N", + "AppropriateFamilyName;AppropriateGivenName;AppropriateMiddleName;" + + "AppropriatePrefix;AppropriateSuffix", + Arrays.asList("AppropriateFamilyName", "AppropriateGivenName", + "AppropriateMiddleName", "AppropriatePrefix", "AppropriateSuffix")) + .addExpectedNodeWithOrder("FN", + "AppropriatePrefix AppropriateGivenName " + + "AppropriateMiddleName AppropriateFamilyName AppropriateSuffix") + .addExpectedNode("X-PHONETIC-FIRST-NAME", "AppropriatePhoneticGiven") + .addExpectedNode("X-PHONETIC-MIDDLE-NAME", "AppropriatePhoneticMiddle") + .addExpectedNode("X-PHONETIC-LAST-NAME", "AppropriatePhoneticFamily"); + + if (isV30) { + elem.addExpectedNode("SORT-STRING", + "AppropriatePhoneticGiven AppropriatePhoneticMiddle " + + "AppropriatePhoneticFamily"); + } + } + + public void testStructuredNameUsePrimaryV21() { + testStructuredNameUsePrimaryCommon(V21); + } + + public void testStructuredNameUsePrimaryV30() { + testStructuredNameUsePrimaryCommon(V30); + } + + /** + * Tests that only "super primary" StructuredName is emitted. + * See also the comment in {@link #testStructuredNameUsePrimaryCommon(int)}. + */ + private void testStructuredNameUseSuperPrimaryCommon(int vcardType) { + final boolean isV30 = (vcardType == V30); + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "DoNotEmitFamilyName1") + .put(StructuredName.GIVEN_NAME, "DoNotEmitGivenName1") + .put(StructuredName.MIDDLE_NAME, "DoNotEmitMiddleName1") + .put(StructuredName.PREFIX, "DoNotEmitPrefix1") + .put(StructuredName.SUFFIX, "DoNotEmitSuffix1") + .put(StructuredName.PHONETIC_FAMILY_NAME, "DoNotEmitPhoneticFamily1") + .put(StructuredName.PHONETIC_GIVEN_NAME, "DoNotEmitPhoneticGiven1") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "DoNotEmitPhoneticMiddle1"); + + // With "IS_PRIMARY=1", but we should ignore this time. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "DoNotEmitFamilyName2") + .put(StructuredName.GIVEN_NAME, "DoNotEmitGivenName2") + .put(StructuredName.MIDDLE_NAME, "DoNotEmitMiddleName2") + .put(StructuredName.PREFIX, "DoNotEmitPrefix2") + .put(StructuredName.SUFFIX, "DoNotEmitSuffix2") + .put(StructuredName.PHONETIC_FAMILY_NAME, "DoNotEmitPhoneticFamily2") + .put(StructuredName.PHONETIC_GIVEN_NAME, "DoNotEmitPhoneticGiven2") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "DoNotEmitPhoneticMiddle2") + .put(StructuredName.IS_PRIMARY, 1); + + // With "IS_SUPER_PRIMARY=1". This is what we should use. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "AppropriateFamilyName") + .put(StructuredName.GIVEN_NAME, "AppropriateGivenName") + .put(StructuredName.MIDDLE_NAME, "AppropriateMiddleName") + .put(StructuredName.PREFIX, "AppropriatePrefix") + .put(StructuredName.SUFFIX, "AppropriateSuffix") + .put(StructuredName.PHONETIC_FAMILY_NAME, "AppropriatePhoneticFamily") + .put(StructuredName.PHONETIC_GIVEN_NAME, "AppropriatePhoneticGiven") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "AppropriatePhoneticMiddle") + .put(StructuredName.IS_SUPER_PRIMARY, 1); + + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "DoNotEmitFamilyName3") + .put(StructuredName.GIVEN_NAME, "DoNotEmitGivenName3") + .put(StructuredName.MIDDLE_NAME, "DoNotEmitMiddleName3") + .put(StructuredName.PREFIX, "DoNotEmitPrefix3") + .put(StructuredName.SUFFIX, "DoNotEmitSuffix3") + .put(StructuredName.PHONETIC_FAMILY_NAME, "DoNotEmitPhoneticFamily3") + .put(StructuredName.PHONETIC_GIVEN_NAME, "DoNotEmitPhoneticGiven3") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "DoNotEmitPhoneticMiddle3") + .put(StructuredName.IS_PRIMARY, 1); + + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("N", + "AppropriateFamilyName;AppropriateGivenName;AppropriateMiddleName;" + + "AppropriatePrefix;AppropriateSuffix", + Arrays.asList("AppropriateFamilyName", "AppropriateGivenName", + "AppropriateMiddleName", "AppropriatePrefix", "AppropriateSuffix")) + .addExpectedNodeWithOrder("FN", + "AppropriatePrefix AppropriateGivenName " + + "AppropriateMiddleName AppropriateFamilyName AppropriateSuffix") + .addExpectedNode("X-PHONETIC-FIRST-NAME", "AppropriatePhoneticGiven") + .addExpectedNode("X-PHONETIC-MIDDLE-NAME", "AppropriatePhoneticMiddle") + .addExpectedNode("X-PHONETIC-LAST-NAME", "AppropriatePhoneticFamily"); + + if (isV30) { + elem.addExpectedNode("SORT-STRING", + "AppropriatePhoneticGiven AppropriatePhoneticMiddle" + + " AppropriatePhoneticFamily"); + } + } + + public void testStructuredNameUseSuperPrimaryV21() { + testStructuredNameUseSuperPrimaryCommon(V21); + } + + public void testStructuredNameUseSuperPrimaryV30() { + testStructuredNameUseSuperPrimaryCommon(V30); + } + + public void testNickNameV30() { + mVerifier.initForExportTest(V30); + mVerifier.addInputEntry().addContentValues(Nickname.CONTENT_ITEM_TYPE) + .put(Nickname.NAME, "Nicky"); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNodeWithOrder("NICKNAME", "Nicky"); + } + + private void testPhoneBasicCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "1") + .put(Phone.TYPE, Phone.TYPE_HOME); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "1", new TypeSet("HOME")); + } + + public void testPhoneBasicV21() { + testPhoneBasicCommon(V21); + } + + public void testPhoneBasicV30() { + testPhoneBasicCommon(V30); + } + + /** + * Tests that vCard composer emits corresponding type param which we expect. + */ + private void testPhoneVariousTypeSupport(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "10") + .put(Phone.TYPE, Phone.TYPE_HOME); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "20") + .put(Phone.TYPE, Phone.TYPE_WORK); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "30") + .put(Phone.TYPE, Phone.TYPE_FAX_HOME); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "40") + .put(Phone.TYPE, Phone.TYPE_FAX_WORK); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "50") + .put(Phone.TYPE, Phone.TYPE_MOBILE); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "60") + .put(Phone.TYPE, Phone.TYPE_PAGER); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "70") + .put(Phone.TYPE, Phone.TYPE_OTHER); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "80") + .put(Phone.TYPE, Phone.TYPE_CAR); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "90") + .put(Phone.TYPE, Phone.TYPE_COMPANY_MAIN); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "100") + .put(Phone.TYPE, Phone.TYPE_ISDN); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "110") + .put(Phone.TYPE, Phone.TYPE_MAIN); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "120") + .put(Phone.TYPE, Phone.TYPE_OTHER_FAX); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "130") + .put(Phone.TYPE, Phone.TYPE_TELEX); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "140") + .put(Phone.TYPE, Phone.TYPE_WORK_MOBILE); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "150") + .put(Phone.TYPE, Phone.TYPE_WORK_PAGER); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "160") + .put(Phone.TYPE, Phone.TYPE_MMS); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "10", new TypeSet("HOME")) + .addExpectedNode("TEL", "20", new TypeSet("WORK")) + .addExpectedNode("TEL", "30", new TypeSet("HOME", "FAX")) + .addExpectedNode("TEL", "40", new TypeSet("WORK", "FAX")) + .addExpectedNode("TEL", "50", new TypeSet("CELL")) + .addExpectedNode("TEL", "60", new TypeSet("PAGER")) + .addExpectedNode("TEL", "70", new TypeSet("VOICE")) + .addExpectedNode("TEL", "80", new TypeSet("CAR")) + .addExpectedNode("TEL", "90", new TypeSet("WORK", "PREF")) + .addExpectedNode("TEL", "100", new TypeSet("ISDN")) + .addExpectedNode("TEL", "110", new TypeSet("PREF")) + .addExpectedNode("TEL", "120", new TypeSet("FAX")) + .addExpectedNode("TEL", "130", new TypeSet("TLX")) + .addExpectedNode("TEL", "140", new TypeSet("WORK", "CELL")) + .addExpectedNode("TEL", "150", new TypeSet("WORK", "PAGER")) + .addExpectedNode("TEL", "160", new TypeSet("MSG")); + } + + public void testPhoneVariousTypeSupportV21() { + testPhoneVariousTypeSupport(V21); + } + + public void testPhoneVariousTypeSupportV30() { + testPhoneVariousTypeSupport(V30); + } + + /** + * Tests that "PREF"s are emitted appropriately. + */ + private void testPhonePrefHandlingCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "1") + .put(Phone.TYPE, Phone.TYPE_HOME); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "2") + .put(Phone.TYPE, Phone.TYPE_WORK) + .put(Phone.IS_PRIMARY, 1); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "3") + .put(Phone.TYPE, Phone.TYPE_FAX_HOME) + .put(Phone.IS_PRIMARY, 1); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "4") + .put(Phone.TYPE, Phone.TYPE_FAX_WORK); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "4", new TypeSet("WORK", "FAX")) + .addExpectedNode("TEL", "3", new TypeSet("HOME", "FAX", "PREF")) + .addExpectedNode("TEL", "2", new TypeSet("WORK", "PREF")) + .addExpectedNode("TEL", "1", new TypeSet("HOME")); + } + + public void testPhonePrefHandlingV21() { + testPhonePrefHandlingCommon(V21); + } + + public void testPhonePrefHandlingV30() { + testPhonePrefHandlingCommon(V30); + } + + private void testMiscPhoneTypeHandling(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "1") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "Modem"); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "2") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "MSG"); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "3") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "BBS"); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "4") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "VIDEO"); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "5") + .put(Phone.TYPE, Phone.TYPE_CUSTOM); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "6") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "_AUTO_CELL"); // The old indicator for the type mobile. + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "7") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "\u643A\u5E2F"); // Mobile phone in Japanese Kanji + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "8") + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "invalid"); + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElemWithEmptyName(); + elem.addExpectedNode("TEL", "1", new TypeSet("MODEM")) + .addExpectedNode("TEL", "2", new TypeSet("MSG")) + .addExpectedNode("TEL", "3", new TypeSet("BBS")) + .addExpectedNode("TEL", "4", new TypeSet("VIDEO")) + .addExpectedNode("TEL", "5", new TypeSet("VOICE")) + .addExpectedNode("TEL", "6", new TypeSet("CELL")) + .addExpectedNode("TEL", "7", new TypeSet("CELL")) + .addExpectedNode("TEL", "8", new TypeSet("X-invalid")); + } + + public void testPhoneTypeHandlingV21() { + testMiscPhoneTypeHandling(V21); + } + + public void testPhoneTypeHandlingV30() { + testMiscPhoneTypeHandling(V30); + } + + private void testEmailBasicCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "sample@example.com"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("EMAIL", "sample@example.com"); + } + + public void testEmailBasicV21() { + testEmailBasicCommon(V21); + } + + public void testEmailBasicV30() { + testEmailBasicCommon(V30); + } + + private void testEmailVariousTypeSupportCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_home@example.com") + .put(Email.TYPE, Email.TYPE_HOME); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_work@example.com") + .put(Email.TYPE, Email.TYPE_WORK); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_mobile@example.com") + .put(Email.TYPE, Email.TYPE_MOBILE); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_other@example.com") + .put(Email.TYPE, Email.TYPE_OTHER); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("EMAIL", "type_home@example.com", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "type_work@example.com", new TypeSet("WORK")) + .addExpectedNode("EMAIL", "type_mobile@example.com", new TypeSet("CELL")) + .addExpectedNode("EMAIL", "type_other@example.com"); + } + + public void testEmailVariousTypeSupportV21() { + testEmailVariousTypeSupportCommon(V21); + } + + public void testEmailVariousTypeSupportV30() { + testEmailVariousTypeSupportCommon(V30); + } + + private void testEmailPrefHandlingCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_home@example.com") + .put(Email.TYPE, Email.TYPE_HOME) + .put(Email.IS_PRIMARY, 1); + entry.addContentValues(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "type_notype@example.com") + .put(Email.IS_PRIMARY, 1); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("EMAIL", "type_notype@example.com", new TypeSet("PREF")) + .addExpectedNode("EMAIL", "type_home@example.com", new TypeSet("HOME", "PREF")); + } + + public void testEmailPrefHandlingV21() { + testEmailPrefHandlingCommon(V21); + } + + public void testEmailPrefHandlingV30() { + testEmailPrefHandlingCommon(V30); + } + + private void testPostalAddressCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "Pobox") + .put(StructuredPostal.NEIGHBORHOOD, "Neighborhood") + .put(StructuredPostal.STREET, "Street") + .put(StructuredPostal.CITY, "City") + .put(StructuredPostal.REGION, "Region") + .put(StructuredPostal.POSTCODE, "100") + .put(StructuredPostal.COUNTRY, "Country") + .put(StructuredPostal.FORMATTED_ADDRESS, "Formatted Address") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK); + // adr-value = 0*6(text-value ";") text-value + // ; PO Box, Extended Address, Street, Locality, Region, Postal Code, + // ; Country Name + // + // The NEIGHBORHOOD field is appended after the CITY field. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("ADR", + Arrays.asList("Pobox", "", "Street", "City Neighborhood", + "Region", "100", "Country"), new TypeSet("WORK")); + } + + public void testPostalAddressV21() { + testPostalAddressCommon(V21); + } + + public void testPostalAddressV30() { + testPostalAddressCommon(V30); + } + + private void testPostalAddressNonNeighborhood(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.CITY, "City"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("ADR", + Arrays.asList("", "", "", "City", "", "", ""), new TypeSet("HOME")); + } + + public void testPostalAddressNonNeighborhoodV21() { + testPostalAddressNonNeighborhood(V21); + } + + public void testPostalAddressNonNeighborhoodV30() { + testPostalAddressNonNeighborhood(V30); + } + + private void testPostalAddressNonCity(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.NEIGHBORHOOD, "Neighborhood"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("ADR", + Arrays.asList("", "", "", "Neighborhood", "", "", ""), new TypeSet("HOME")); + } + + public void testPostalAddressNonCityV21() { + testPostalAddressNonCity(V21); + } + + public void testPostalAddressNonCityV30() { + testPostalAddressNonCity(V30); + } + + private void testPostalOnlyWithFormattedAddressCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.REGION, "") // Must be ignored. + .put(StructuredPostal.FORMATTED_ADDRESS, + "Formatted address CA 123-334 United Statue"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNodeWithOrder("ADR", ";Formatted address CA 123-334 United Statue;;;;;", + Arrays.asList("", "Formatted address CA 123-334 United Statue", + "", "", "", "", ""), new TypeSet("HOME")); + } + + public void testPostalOnlyWithFormattedAddressV21() { + testPostalOnlyWithFormattedAddressCommon(V21); + } + + public void testPostalOnlyWithFormattedAddressV30() { + testPostalOnlyWithFormattedAddressCommon(V30); + } + + /** + * Tests that the vCard composer honors formatted data when it is available + * even when it is partial. + */ + private void testPostalWithBothStructuredAndFormattedCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "Pobox") + .put(StructuredPostal.COUNTRY, "Country") + .put(StructuredPostal.FORMATTED_ADDRESS, + "Formatted address CA 123-334 United Statue"); // Should be ignored + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("ADR", "Pobox;;;;;;Country", + Arrays.asList("Pobox", "", "", "", "", "", "Country"), + new TypeSet("HOME")); + } + + public void testPostalWithBothStructuredAndFormattedV21() { + testPostalWithBothStructuredAndFormattedCommon(V21); + } + + public void testPostalWithBothStructuredAndFormattedV30() { + testPostalWithBothStructuredAndFormattedCommon(V30); + } + + private void testOrganizationCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "CompanyX") + .put(Organization.DEPARTMENT, "DepartmentY") + .put(Organization.TITLE, "TitleZ") + .put(Organization.JOB_DESCRIPTION, "Description Rambda") // Ignored. + .put(Organization.OFFICE_LOCATION, "Mountain View") // Ignored. + .put(Organization.PHONETIC_NAME, "PhoneticName!") // Ignored + .put(Organization.SYMBOL, "(^o^)/~~"); // Ignore him (her). + entry.addContentValues(Organization.CONTENT_ITEM_TYPE) + .putNull(Organization.COMPANY) + .put(Organization.DEPARTMENT, "DepartmentXX") + .putNull(Organization.TITLE); + entry.addContentValues(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "CompanyXYZ") + .putNull(Organization.DEPARTMENT) + .put(Organization.TITLE, "TitleXYZYX"); + // Currently we do not use group but depend on the order. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNodeWithOrder("ORG", "CompanyX;DepartmentY", + Arrays.asList("CompanyX", "DepartmentY")) + .addExpectedNodeWithOrder("TITLE", "TitleZ") + .addExpectedNodeWithOrder("ORG", "DepartmentXX") + .addExpectedNodeWithOrder("ORG", "CompanyXYZ") + .addExpectedNodeWithOrder("TITLE", "TitleXYZYX"); + } + + public void testOrganizationV21() { + testOrganizationCommon(V21); + } + + public void testOrganizationV30() { + testOrganizationCommon(V30); + } + + private void testImVariousTypeSupportCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_AIM) + .put(Im.DATA, "aim"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_MSN) + .put(Im.DATA, "msn"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_YAHOO) + .put(Im.DATA, "yahoo"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_SKYPE) + .put(Im.DATA, "skype"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_QQ) + .put(Im.DATA, "qq"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_GOOGLE_TALK) + .put(Im.DATA, "google talk"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_ICQ) + .put(Im.DATA, "icq"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_JABBER) + .put(Im.DATA, "jabber"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_NETMEETING) + .put(Im.DATA, "netmeeting"); + + // No determined way to express unknown type... + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("X-JABBER", "jabber") + .addExpectedNode("X-ICQ", "icq") + .addExpectedNode("X-GOOGLE-TALK", "google talk") + .addExpectedNode("X-QQ", "qq") + .addExpectedNode("X-SKYPE-USERNAME", "skype") + .addExpectedNode("X-YAHOO", "yahoo") + .addExpectedNode("X-MSN", "msn") + .addExpectedNode("X-NETMEETING", "netmeeting") + .addExpectedNode("X-AIM", "aim"); + } + + public void testImBasiV21() { + testImVariousTypeSupportCommon(V21); + } + + public void testImBasicV30() { + testImVariousTypeSupportCommon(V30); + } + + private void testImPrefHandlingCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_AIM) + .put(Im.DATA, "aim1"); + entry.addContentValues(Im.CONTENT_ITEM_TYPE) + .put(Im.PROTOCOL, Im.PROTOCOL_AIM) + .put(Im.DATA, "aim2") + .put(Im.TYPE, Im.TYPE_HOME) + .put(Im.IS_PRIMARY, 1); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("X-AIM", "aim1") + .addExpectedNode("X-AIM", "aim2", new TypeSet("HOME", "PREF")); + } + + public void testImPrefHandlingV21() { + testImPrefHandlingCommon(V21); + } + + public void testImPrefHandlingV30() { + testImPrefHandlingCommon(V30); + } + + private void testWebsiteCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Website.CONTENT_ITEM_TYPE) + .put(Website.URL, "http://website.example.android.com/index.html") + .put(Website.TYPE, Website.TYPE_BLOG); + entry.addContentValues(Website.CONTENT_ITEM_TYPE) + .put(Website.URL, "ftp://ftp.example.android.com/index.html") + .put(Website.TYPE, Website.TYPE_FTP); + + // We drop TYPE information since vCard (especially 3.0) does not allow us to emit it. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("URL", "ftp://ftp.example.android.com/index.html") + .addExpectedNode("URL", "http://website.example.android.com/index.html"); + } + + public void testWebsiteV21() { + testWebsiteCommon(V21); + } + + public void testWebsiteV30() { + testWebsiteCommon(V30); + } + + private String getAndroidPropValue(final String mimeType, String value, Integer type) { + return getAndroidPropValue(mimeType, value, type, null); + } + + private String getAndroidPropValue(final String mimeType, String value, + Integer type, String label) { + return (mimeType + ";" + value + ";" + + (type != null ? type : "") + ";" + + (label != null ? label : "") + ";;;;;;;;;;;;"); + } + + private void testEventCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Event.CONTENT_ITEM_TYPE) + .put(Event.TYPE, Event.TYPE_ANNIVERSARY) + .put(Event.START_DATE, "1982-06-16"); + entry.addContentValues(Event.CONTENT_ITEM_TYPE) + .put(Event.TYPE, Event.TYPE_BIRTHDAY) + .put(Event.START_DATE, "2008-10-22"); + entry.addContentValues(Event.CONTENT_ITEM_TYPE) + .put(Event.TYPE, Event.TYPE_OTHER) + .put(Event.START_DATE, "2018-03-12"); + entry.addContentValues(Event.CONTENT_ITEM_TYPE) + .put(Event.TYPE, Event.TYPE_CUSTOM) + .put(Event.LABEL, "The last day") + .put(Event.START_DATE, "When the Tower of Hanoi with 64 rings is completed."); + entry.addContentValues(Event.CONTENT_ITEM_TYPE) + .put(Event.TYPE, Event.TYPE_BIRTHDAY) + .put(Event.START_DATE, "2009-05-19"); // Should be ignored. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("BDAY", "2008-10-22") + .addExpectedNode("X-ANDROID-CUSTOM", + getAndroidPropValue( + Event.CONTENT_ITEM_TYPE, "1982-06-16", Event.TYPE_ANNIVERSARY)) + .addExpectedNode("X-ANDROID-CUSTOM", + getAndroidPropValue( + Event.CONTENT_ITEM_TYPE, "2018-03-12", Event.TYPE_OTHER)) + .addExpectedNode("X-ANDROID-CUSTOM", + getAndroidPropValue( + Event.CONTENT_ITEM_TYPE, + "When the Tower of Hanoi with 64 rings is completed.", + Event.TYPE_CUSTOM, "The last day")); + } + + public void testEventV21() { + testEventCommon(V21); + } + + public void testEventV30() { + testEventCommon(V30); + } + + private void testNoteCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "note1"); + entry.addContentValues(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "note2") + .put(Note.IS_PRIMARY, 1); // Just ignored. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNodeWithOrder("NOTE", "note1") + .addExpectedNodeWithOrder("NOTE", "note2"); + } + + public void testNoteV21() { + testNoteCommon(V21); + } + + public void testNoteV30() { + testNoteCommon(V30); + } + + private void testPhotoCommon(int vcardType) { + final boolean isV30 = vcardType == V30; + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "PhotoTest"); + entry.addContentValues(Photo.CONTENT_ITEM_TYPE) + .put(Photo.PHOTO, sPhotoByteArray); + + ContentValues contentValuesForPhoto = new ContentValues(); + contentValuesForPhoto.put("ENCODING", (isV30 ? "b" : "BASE64")); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("FN", "PhotoTest") + .addExpectedNode("N", "PhotoTest;;;;", + Arrays.asList("PhotoTest", "", "", "", "")) + .addExpectedNodeWithOrder("PHOTO", null, null, sPhotoByteArray, + contentValuesForPhoto, new TypeSet("JPEG"), null); + } + + public void testPhotoV21() { + testPhotoCommon(V21); + } + + public void testPhotoV30() { + testPhotoCommon(V30); + } + + private void testRelationCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + mVerifier.addInputEntry().addContentValues(Relation.CONTENT_ITEM_TYPE) + .put(Relation.TYPE, Relation.TYPE_MOTHER) + .put(Relation.NAME, "Ms. Mother"); + mVerifier.addContentValuesVerifierElem().addExpected(Relation.CONTENT_ITEM_TYPE) + .put(Relation.TYPE, Relation.TYPE_MOTHER) + .put(Relation.NAME, "Ms. Mother"); + } + + public void testRelationV21() { + testRelationCommon(V21); + } + + public void testRelationV30() { + testRelationCommon(V30); + } + + public void testV30HandleEscape() { + mVerifier.initForExportTest(V30); + mVerifier.addInputEntry().addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\\") + .put(StructuredName.GIVEN_NAME, ";") + .put(StructuredName.MIDDLE_NAME, ",") + .put(StructuredName.PREFIX, "\n") + .put(StructuredName.DISPLAY_NAME, "[<{Unescaped:Asciis}>]"); + // Verifies the vCard String correctly escapes each character which must be escaped. + mVerifier.addLineVerifierElem() + .addExpected("N:\\\\;\\;;\\,;\\n;") + .addExpected("FN:[<{Unescaped:Asciis}>]"); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("FN", "[<{Unescaped:Asciis}>]") + .addExpectedNode("N", Arrays.asList("\\", ";", ",", "\n", "")); + } + + /** + * There's no "NICKNAME" property in vCard 2.1, while there is in vCard 3.0. + * We use Android-specific "X-ANDROID-CUSTOM" property. + * This test verifies the functionality. + */ + public void testNickNameV21() { + mVerifier.initForExportTest(V21); + mVerifier.addInputEntry().addContentValues(Nickname.CONTENT_ITEM_TYPE) + .put(Nickname.NAME, "Nicky"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("X-ANDROID-CUSTOM", + Nickname.CONTENT_ITEM_TYPE + ";Nicky;;;;;;;;;;;;;;"); + mVerifier.addContentValuesVerifierElem().addExpected(Nickname.CONTENT_ITEM_TYPE) + .put(Nickname.NAME, "Nicky"); + } + + public void testTolerateBrokenPhoneNumberEntryV21() { + mVerifier.initForExportTest(V21); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_HOME) + .put(Phone.NUMBER, "111-222-3333 (Miami)\n444-5555-666 (Tokyo);" + + "777-888-9999 (Chicago);111-222-3333 (Miami)"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "111-222-3333", new TypeSet("HOME")) + .addExpectedNode("TEL", "444-555-5666", new TypeSet("HOME")) + .addExpectedNode("TEL", "777-888-9999", new TypeSet("HOME")); + } + + private void testPickUpNonEmptyContentValuesCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.IS_PRIMARY, 1); // Empty name. Should be ignored. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "family1"); // Not primary. Should be ignored. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.IS_PRIMARY, 1) + .put(StructuredName.FAMILY_NAME, "family2"); // This entry is what we want. + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.IS_PRIMARY, 1) + .put(StructuredName.FAMILY_NAME, "family3"); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "family4"); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("N", Arrays.asList("family2", "", "", "", "")) + .addExpectedNode("FN", "family2"); + } + + public void testPickUpNonEmptyContentValuesV21() { + testPickUpNonEmptyContentValuesCommon(V21); + } + + public void testPickUpNonEmptyContentValuesV30() { + testPickUpNonEmptyContentValuesCommon(V30); + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardImporterTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardImporterTests.java new file mode 100644 index 0000000..45d3e3c --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardImporterTests.java @@ -0,0 +1,1011 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentValues; +import android.pim.vcard.VCardConfig; +import android.provider.ContactsContract.Data; +import android.provider.ContactsContract.CommonDataKinds.Email; +import android.provider.ContactsContract.CommonDataKinds.Event; +import android.provider.ContactsContract.CommonDataKinds.Note; +import android.provider.ContactsContract.CommonDataKinds.Organization; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.CommonDataKinds.Photo; +import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; +import android.provider.ContactsContract.CommonDataKinds.Website; + +import com.android.unit_tests.R; +import com.android.unit_tests.vcard.PropertyNodesVerifierElem.TypeSet; + +import java.util.Arrays; + +public class VCardImporterTests extends VCardTestsBase { + // Push data into int array at first since values like 0x80 are + // interpreted as int by the compiler and casting all of them is + // cumbersome... + private static final int[] sPhotoIntArrayForComplicatedCase = { + 0xff, 0xd8, 0xff, 0xe1, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x66, 0x00, + 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0d, + 0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xaa, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0xba, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0xc2, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x28, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x32, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xe6, 0x02, 0x13, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x82, + 0x98, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xfa, + 0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, + 0x84, 0xc4, 0xa5, 0x00, 0x07, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, + 0x01, 0x08, 0x00, 0x00, 0x04, 0x1e, 0x32, 0x30, 0x30, 0x38, 0x31, + 0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31, 0x00, 0x00, + 0x44, 0x6f, 0x43, 0x6f, 0x4d, 0x6f, 0x00, 0x00, 0x44, 0x39, 0x30, + 0x35, 0x69, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x44, 0x39, 0x30, + 0x35, 0x69, 0x20, 0x56, 0x65, 0x72, 0x31, 0x2e, 0x30, 0x30, 0x00, + 0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, + 0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x49, 0x4d, 0x00, 0x30, 0x33, + 0x30, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x14, 0x00, + 0x14, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x34, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x09, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x0f, 0x0b, 0x00, + 0x00, 0x27, 0x10, 0x00, 0x00, 0x05, 0x97, 0x00, 0x00, 0x27, 0x10, + 0x00, 0x00, 0x08, 0xb0, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1c, + 0x01, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x02, 0x5e, 0x00, 0x00, + 0x27, 0x10, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x27, 0x10, 0x00, + 0x00, 0x03, 0xcb, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1b, 0xe5, + 0x00, 0x00, 0x27, 0x10, 0x00, 0x28, 0x82, 0x9a, 0x00, 0x05, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x6a, 0x82, 0x9d, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x72, 0x88, 0x22, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x90, 0x00, + 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90, + 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03, 0x7a, + 0x90, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03, + 0x8e, 0x91, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, + 0x03, 0x00, 0x91, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x03, 0xa2, 0x92, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x03, 0xaa, 0x92, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x03, 0xb2, 0x92, 0x04, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0xba, 0x92, 0x05, 0x00, 0x05, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xc2, 0x92, 0x07, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x92, 0x08, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, + 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xca, + 0x92, 0x7c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x92, 0x86, 0x00, 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, + 0x03, 0xd2, 0xa0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, + 0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x60, 0x00, 0x00, 0xa0, 0x03, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0xa2, 0x0e, 0x00, 0x05, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe8, 0xa2, 0x0f, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xf0, 0xa2, 0x10, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0xa2, + 0x17, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, + 0xa3, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, + 0x00, 0xa3, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x04, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x03, 0xf8, 0xa4, 0x05, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x1d, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x07, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, + 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0xa4, 0x0a, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0xa4, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, + 0x00, 0x27, 0x10, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64, + 0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, + 0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x33, 0x31, 0x00, 0x32, 0x30, + 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, 0x31, 0x33, + 0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x00, 0x00, 0x29, 0x88, + 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0xb2, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x25, 0x00, + 0x00, 0x00, 0x0a, 0x00, 0x00, 0x0e, 0x92, 0x00, 0x00, 0x03, 0xe8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x30, 0x30, + 0x38, 0x31, 0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31, + 0x00, 0x00, 0x20, 0x2a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x2a, + 0xe2, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x52, 0x39, 0x38, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, + 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x04, 0x6c, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x04, 0x74, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x04, 0x7c, 0x02, 0x02, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x8b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, + 0x00, 0x20, 0x16, 0x18, 0x1c, 0x18, 0x14, 0x20, 0x1c, 0x1a, 0x1c, + 0x24, 0x22, 0x20, 0x26, 0x30, 0x50, 0x34, 0x30, 0x2c, 0x2c, 0x30, + 0x62, 0x46, 0x4a, 0x3a, 0x50, 0x74, 0x66, 0x7a, 0x78, 0x72, 0x66, + 0x70, 0x6e, 0x80, 0x90, 0xb8, 0x9c, 0x80, 0x88, 0xae, 0x8a, 0x6e, + 0x70, 0xa0, 0xda, 0xa2, 0xae, 0xbe, 0xc4, 0xce, 0xd0, 0xce, 0x7c, + 0x9a, 0xe2, 0xf2, 0xe0, 0xc8, 0xf0, 0xb8, 0xca, 0xce, 0xc6, 0x01, + 0x22, 0x24, 0x24, 0x30, 0x2a, 0x30, 0x5e, 0x34, 0x34, 0x5e, 0xc6, + 0x84, 0x70, 0x84, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xff, 0xc0, + 0x00, 0x11, 0x08, 0x00, 0x78, 0x00, 0xa0, 0x03, 0x01, 0x21, 0x00, + 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00, + 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, + 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, + 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, + 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, + 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, + 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, + 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, + 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, + 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, + 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, + 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00, + 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, + 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, + 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, + 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, + 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, + 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, + 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, + 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, + 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, + 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, + 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, + 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, + 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, + 0x14, 0x54, 0xaa, 0x2a, 0x46, 0x48, 0xa2, 0xa4, 0x55, 0xa6, 0x04, + 0x8a, 0x29, 0xe0, 0x53, 0x10, 0xe0, 0x29, 0xc0, 0x50, 0x03, 0xb1, + 0x46, 0x29, 0x80, 0x84, 0x52, 0x11, 0x40, 0x0d, 0x22, 0x9a, 0x45, + 0x20, 0x23, 0x61, 0x51, 0x30, 0xa0, 0x08, 0xc8, 0xa8, 0xd8, 0x52, + 0x02, 0x26, 0x15, 0x0b, 0x0a, 0x00, 0xb4, 0xa2, 0xa5, 0x5a, 0x00, + 0x91, 0x45, 0x4a, 0xa2, 0x81, 0x92, 0x01, 0x4e, 0x02, 0x98, 0x87, + 0x0a, 0x70, 0xa0, 0x07, 0x62, 0x8c, 0x50, 0x21, 0x0d, 0x25, 0x00, + 0x34, 0x8a, 0x61, 0x14, 0x0c, 0x63, 0x0a, 0x89, 0x85, 0x00, 0x46, + 0xd5, 0x1b, 0x52, 0x02, 0x16, 0xa8, 0x98, 0x50, 0x05, 0x94, 0xa9, + 0x16, 0x80, 0x25, 0x5a, 0x95, 0x68, 0x18, 0xf1, 0x4f, 0x14, 0xc4, + 0x3b, 0xb5, 0x22, 0xb6, 0x38, 0x34, 0x00, 0xe3, 0x22, 0x8e, 0xf4, + 0x79, 0x8a, 0x7b, 0xd1, 0x71, 0x03, 0x30, 0xc7, 0x14, 0x83, 0xa5, + 0x00, 0x06, 0x98, 0x68, 0x01, 0x8d, 0x51, 0x35, 0x03, 0x22, 0x6a, + 0x8d, 0xa9, 0x01, 0x13, 0x54, 0x4d, 0x40, 0x13, 0xa5, 0x4a, 0x28, + 0x02, 0x45, 0x35, 0x2a, 0x9a, 0x00, 0x78, 0x34, 0xf0, 0x69, 0x80, + 0x34, 0x81, 0x45, 0x40, 0xce, 0x58, 0xe6, 0xa2, 0x4c, 0x06, 0xe4, + 0xfa, 0xd1, 0x93, 0x50, 0x21, 0xca, 0xe4, 0x55, 0x84, 0x90, 0x30, + 0xab, 0x8b, 0x18, 0xa6, 0x9a, 0x6a, 0xc4, 0x31, 0xaa, 0x26, 0xa0, + 0x64, 0x4d, 0x51, 0xb5, 0x20, 0x23, 0x6a, 0x89, 0xa8, 0x02, 0x44, + 0x35, 0x2a, 0x9a, 0x00, 0x95, 0x4d, 0x48, 0xa6, 0x80, 0x24, 0x53, + 0x4e, 0xce, 0x05, 0x30, 0x2b, 0x3b, 0xee, 0x6a, 0x91, 0x5d, 0x76, + 0x63, 0xbd, 0x65, 0x7d, 0x40, 0x66, 0x68, 0xa9, 0x02, 0x45, 0x2b, + 0xb3, 0x9e, 0xb4, 0xc5, 0x6d, 0xad, 0x9a, 0xa0, 0x2c, 0x06, 0xc8, + 0xcd, 0x04, 0xd6, 0xa2, 0x23, 0x63, 0x51, 0xb1, 0xa0, 0x64, 0x4d, + 0x51, 0x93, 0x48, 0x08, 0xda, 0xa2, 0x6a, 0x00, 0x72, 0x1a, 0x99, + 0x4d, 0x00, 0x48, 0xa6, 0xa4, 0x53, 0x4c, 0x07, 0x86, 0x03, 0xbd, + 0x2b, 0x9c, 0xa7, 0x14, 0x98, 0x10, 0x85, 0x34, 0xe0, 0xa6, 0xb3, + 0xb0, 0x0b, 0xb5, 0xa8, 0x0a, 0xd4, 0x58, 0x42, 0xed, 0x3e, 0x94, + 0xd2, 0xa6, 0x8b, 0x01, 0x34, 0x44, 0xed, 0xe6, 0x9c, 0x4d, 0x6a, + 0x80, 0x8d, 0x8d, 0x46, 0xc6, 0x80, 0x23, 0x63, 0x51, 0x9a, 0x06, + 0x46, 0xd5, 0x13, 0x52, 0x01, 0x54, 0xd4, 0xaa, 0x68, 0x02, 0x40, + 0x6a, 0x40, 0x78, 0xa0, 0x08, 0x59, 0xce, 0xee, 0xb5, 0x2a, 0x39, + 0xd9, 0x59, 0xa7, 0xa8, 0x00, 0x73, 0xeb, 0x4e, 0x0e, 0x7d, 0x69, + 0x5c, 0x05, 0xf3, 0x0f, 0xad, 0x1e, 0x61, 0xf5, 0xa7, 0x71, 0x0b, + 0xe6, 0x35, 0x21, 0x90, 0xd3, 0xb8, 0x0e, 0x32, 0x10, 0x95, 0x10, + 0x91, 0xb3, 0xd6, 0x9b, 0x60, 0x4b, 0x9c, 0x8a, 0x63, 0x1a, 0xb0, + 0x18, 0x4d, 0x46, 0xc6, 0x80, 0x22, 0x6a, 0x61, 0xa4, 0x31, 0xaa, + 0x6a, 0x55, 0x34, 0x01, 0x2a, 0x9a, 0x7e, 0x78, 0xa0, 0x08, 0x09, + 0xf9, 0xaa, 0x58, 0xcf, 0xca, 0x6b, 0x3e, 0xa0, 0x00, 0xd3, 0x81, + 0xa9, 0x01, 0x73, 0x46, 0x69, 0x80, 0xb9, 0xa4, 0xcd, 0x00, 0x2b, + 0x1f, 0x92, 0xa3, 0x07, 0x9a, 0x6f, 0x70, 0x26, 0xcf, 0x14, 0xd2, + 0x6b, 0x51, 0x0c, 0x63, 0x51, 0xb1, 0xa0, 0x08, 0xda, 0x98, 0x69, + 0x0c, 0x8d, 0x4d, 0x4a, 0xa6, 0x80, 0x24, 0x53, 0x52, 0x03, 0xc5, + 0x02, 0x21, 0x27, 0xe6, 0xa9, 0x23, 0x3f, 0x29, 0xac, 0xfa, 0x8c, + 0x01, 0xe6, 0x9c, 0x0d, 0x48, 0x0a, 0x0d, 0x2e, 0x68, 0x01, 0x73, + 0x49, 0x9a, 0x60, 0x2b, 0x1f, 0x92, 0x98, 0x3a, 0xd3, 0x7b, 0x81, + 0x36, 0x78, 0xa6, 0x93, 0x5a, 0x88, 0x8c, 0x9a, 0x63, 0x1a, 0x00, + 0x8c, 0xd3, 0x0d, 0x21, 0x91, 0x29, 0xa9, 0x14, 0xd0, 0x04, 0x8a, + 0x69, 0xe0, 0xd3, 0x11, 0x1b, 0x1e, 0x6a, 0x48, 0xcf, 0xca, 0x6b, + 0x3e, 0xa3, 0x10, 0x1a, 0x70, 0x35, 0x20, 0x38, 0x1a, 0x5c, 0xd2, + 0x01, 0x73, 0x49, 0x9a, 0x60, 0x39, 0x8f, 0xca, 0x29, 0x8b, 0xf7, + 0xaa, 0xba, 0x88, 0x96, 0x9a, 0x6b, 0x40, 0x18, 0xc6, 0xa3, 0x26, + 0x80, 0x18, 0x69, 0xa6, 0x90, 0xc8, 0x14, 0xd4, 0x8a, 0x69, 0x80, + 0xf0, 0x6a, 0x40, 0x68, 0x10, 0xbb, 0x41, 0xa7, 0xe3, 0x0b, 0xc5, + 0x2b, 0x01, 0x10, 0xa7, 0x03, 0x59, 0x0c, 0x76, 0x69, 0x73, 0x40, + 0x0b, 0x9a, 0x28, 0x11, 0x28, 0x19, 0x5e, 0x69, 0x02, 0x81, 0x5a, + 0xd8, 0x00, 0xd3, 0x4d, 0x50, 0x0c, 0x6a, 0x8c, 0xd2, 0x01, 0xa6, + 0x98, 0x69, 0x0c, 0xae, 0xa6, 0xa4, 0x06, 0x80, 0x1e, 0xa6, 0x9e, + 0x0d, 0x31, 0x12, 0x03, 0x4f, 0x06, 0x80, 0x13, 0x60, 0x34, 0xd3, + 0xc1, 0xa8, 0x92, 0x01, 0xf1, 0x8d, 0xdd, 0x69, 0xcc, 0xa1, 0x69, + 0x5b, 0x4b, 0x80, 0x83, 0x93, 0x52, 0x04, 0x14, 0xe2, 0xae, 0x03, + 0xa9, 0x0d, 0x68, 0x03, 0x4d, 0x34, 0xd0, 0x03, 0x0d, 0x30, 0xd2, + 0x01, 0x86, 0x9a, 0x68, 0x19, 0x58, 0x1a, 0x78, 0xa4, 0x04, 0x8a, + 0x69, 0xe0, 0xd3, 0x10, 0xe0, 0x69, 0xe0, 0xd0, 0x03, 0xc1, 0xa8, + 0xdb, 0xad, 0x4c, 0x81, 0x12, 0x45, 0xd6, 0x9d, 0x25, 0x1d, 0x00, + 0x6a, 0xf5, 0xa9, 0xe8, 0x80, 0x31, 0x29, 0x0d, 0x58, 0x08, 0x69, + 0x86, 0x80, 0x1a, 0x69, 0x86, 0x90, 0x0c, 0x34, 0xd3, 0x48, 0x65, + 0x51, 0x4f, 0x06, 0x98, 0x0f, 0x14, 0xf0, 0x68, 0x10, 0xf0, 0x69, + 0xe0, 0xd0, 0x03, 0x81, 0xa5, 0x2b, 0x9a, 0x1a, 0xb8, 0x87, 0xa8, + 0xdb, 0x4a, 0x46, 0x68, 0xb6, 0x80, 0x2a, 0xa8, 0x14, 0xea, 0x12, + 0xb0, 0x05, 0x21, 0xa6, 0x02, 0x1a, 0x61, 0xa0, 0x06, 0x9a, 0x61, + 0xa4, 0x31, 0x86, 0x9a, 0x69, 0x0c, 0xa8, 0x0d, 0x3c, 0x53, 0x01, + 0xe2, 0x9e, 0x28, 0x10, 0xf1, 0x4e, 0x06, 0x98, 0x0f, 0x06, 0x9e, + 0x0d, 0x02, 0x1c, 0x29, 0xc2, 0x80, 0x16, 0x96, 0x80, 0x0a, 0x4a, + 0x00, 0x43, 0x4d, 0x34, 0x0c, 0x61, 0xa6, 0x1a, 0x40, 0x34, 0xd3, + 0x4d, 0x21, 0x80, 0xff, 0xd9, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0a, + 0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08, 0x08, 0x08, 0x0b, 0x0a, + 0x0a, 0x0b, 0x0e, 0x18, 0x10, 0x0e, 0x0d, 0x0d, 0x0e, 0x1d, 0x15, + 0x16, 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24, 0x22, 0x1f, 0x22, 0x21, + 0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29, 0x34, 0x29, 0x21, 0x22, 0x30, + 0x41, 0x31, 0x34, 0x39, 0x3b, 0x3e, 0x3e, 0x3e, 0x25, 0x2e, 0x44, + 0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e, 0x3b, 0x01, 0x0a, 0x0b, + 0x0b, 0x0e, 0x0d, 0x0e, 0x1c, 0x10, 0x10, 0x1c, 0x3b, 0x28, 0x22, + 0x28, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, + 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0xff, 0xc0, 0x00, 0x11, + 0x08, 0x00, 0x48, 0x00, 0x60, 0x03, 0x01, 0x21, 0x00, 0x02, 0x11, + 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01, + 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, + 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, + 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, + 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, + 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, + 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, + 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, + 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, + 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, + 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, + 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, + 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, + 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00, 0x03, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, + 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, + 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, + 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, + 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, + 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, + 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, + 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, + 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, + 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, + 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, + 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x9e, 0xd2, + 0x2e, 0x07, 0x15, 0xaf, 0x6d, 0x08, 0xe2, 0xb3, 0x45, 0x1a, 0xf6, + 0xd0, 0x00, 0x01, 0xc5, 0x68, 0x45, 0x17, 0x4a, 0xb4, 0x22, 0xe4, + 0x70, 0x8c, 0x74, 0xa9, 0x3c, 0xa1, 0x8e, 0x95, 0x48, 0x96, 0x31, + 0xe2, 0x18, 0xe9, 0x55, 0xa5, 0x8c, 0x7a, 0x50, 0x05, 0x0b, 0x88, + 0x86, 0x0f, 0x15, 0x8f, 0x75, 0x1f, 0x26, 0x93, 0x19, 0x91, 0x77, + 0x18, 0xc1, 0xac, 0x4b, 0xc8, 0xfa, 0xd6, 0x63, 0x37, 0x6d, 0x31, + 0xb4, 0x73, 0x5b, 0x36, 0xa0, 0x1c, 0x50, 0x80, 0xd7, 0x83, 0xa0, + 0xab, 0xd1, 0x62, 0xad, 0x09, 0x8f, 0x17, 0x29, 0x03, 0xb2, 0xcc, + 0xe0, 0x77, 0x14, 0xa3, 0x56, 0xb3, 0x27, 0x1e, 0x67, 0xe9, 0x52, + 0xea, 0xc6, 0x3a, 0x36, 0x48, 0xef, 0x3d, 0x27, 0x70, 0x22, 0x60, + 0x47, 0x52, 0x69, 0xb2, 0xe2, 0xad, 0x3b, 0xea, 0x80, 0xa3, 0x38, + 0xe0, 0xd6, 0x3d, 0xd8, 0x1c, 0xd0, 0xca, 0x46, 0x3d, 0xd0, 0x18, + 0x35, 0x89, 0x78, 0xa3, 0x9a, 0xcd, 0x8c, 0xd2, 0xb3, 0x93, 0x2a, + 0x2b, 0x66, 0xd5, 0xf1, 0x8a, 0x10, 0x1a, 0xd6, 0xf2, 0x03, 0x8a, + 0x9e, 0xe6, 0xf4, 0x5a, 0xdb, 0xef, 0xfe, 0x23, 0xc0, 0xa7, 0x27, + 0xcb, 0x16, 0xc4, 0xcc, 0xdd, 0xe2, 0x78, 0x9a, 0x69, 0x66, 0xcc, + 0x99, 0xe1, 0x4d, 0x47, 0xba, 0xbc, 0xd9, 0x6a, 0xee, 0x26, 0x59, + 0x59, 0x4d, 0xac, 0x69, 0x34, 0x52, 0xe5, 0x8f, 0x55, 0xad, 0x58, + 0xae, 0x85, 0xc4, 0x22, 0x41, 0xdf, 0xad, 0x76, 0x61, 0xe5, 0x6f, + 0x74, 0x45, 0x69, 0xdc, 0x00, 0x79, 0xac, 0x8b, 0xa6, 0xc9, 0x35, + 0xd4, 0x34, 0x64, 0xdc, 0x37, 0x06, 0xb1, 0xae, 0x88, 0xc1, 0xac, + 0xd8, 0xc9, 0x2c, 0xa6, 0xe0, 0x73, 0x5b, 0x36, 0xf3, 0x74, 0xe6, + 0x84, 0x05, 0xe3, 0xa9, 0x47, 0x6a, 0x14, 0xb6, 0x49, 0x3d, 0x85, + 0x3a, 0xee, 0xee, 0x2b, 0xa8, 0xe2, 0x6f, 0x30, 0x81, 0xe9, 0x8a, + 0xca, 0xa4, 0xe2, 0xd3, 0x8b, 0x01, 0xb1, 0xf9, 0x04, 0x7f, 0xaf, + 0x23, 0xf0, 0xa9, 0x54, 0x41, 0x9c, 0xfd, 0xa3, 0xf4, 0xae, 0x65, + 0x18, 0xf7, 0x25, 0x8a, 0xe2, 0x02, 0x38, 0xb8, 0xfd, 0x2a, 0x7b, + 0x5b, 0xa8, 0x6d, 0x6d, 0x5d, 0x9a, 0x5d, 0xcb, 0xbb, 0xd2, 0xb6, + 0xa6, 0xa3, 0x19, 0x5e, 0xe2, 0x03, 0x7b, 0x1d, 0xc2, 0x17, 0x8d, + 0xb8, 0xac, 0xfb, 0x89, 0x39, 0x35, 0xd6, 0x9a, 0x6a, 0xe8, 0x66, + 0x55, 0xcb, 0xf5, 0xac, 0x7b, 0x96, 0xeb, 0x50, 0xc6, 0x88, 0x6d, + 0x66, 0xe9, 0xcd, 0x6c, 0xdb, 0x4f, 0xd3, 0x9a, 0x00, 0x2f, 0xe6, + 0xf9, 0xa3, 0xe7, 0xb5, 0x4a, 0x93, 0x7f, 0xa2, 0xc6, 0x73, 0xdc, + 0xd7, 0x15, 0x55, 0xef, 0x48, 0x7d, 0x09, 0x52, 0x6e, 0x3a, 0xd4, + 0xab, 0x2f, 0xbd, 0x61, 0x16, 0x0c, 0x73, 0x49, 0xc5, 0x24, 0x92, + 0x7f, 0xa2, 0x63, 0xfd, 0xaa, 0xd6, 0x2f, 0x71, 0x0e, 0xb1, 0x93, + 0xf7, 0x2d, 0xf5, 0xa4, 0x9e, 0x4e, 0xb5, 0xdd, 0x4b, 0xf8, 0x68, + 0x4c, 0xcb, 0xb9, 0x93, 0xad, 0x65, 0xce, 0xd9, 0x26, 0xa9, 0x8d, + 0x19, 0xf6, 0xf2, 0xf4, 0xe6, 0xb5, 0xad, 0xe7, 0xc6, 0x39, 0xa0, + 0x18, 0xeb, 0xc9, 0x77, 0x6c, 0x35, 0x2a, 0x4b, 0xfe, 0x8a, 0x9c, + 0xff, 0x00, 0x11, 0xae, 0x3a, 0x8b, 0xde, 0x61, 0xd0, 0x9e, 0x39, + 0xb8, 0xeb, 0x53, 0xac, 0xb9, 0xae, 0x5b, 0x00, 0xf3, 0x27, 0x14, + 0x92, 0xc9, 0xfe, 0x8a, 0x3f, 0xde, 0x35, 0xac, 0x3a, 0x88, 0x92, + 0xcd, 0xb1, 0x6e, 0x7d, 0xcd, 0x32, 0x67, 0xeb, 0xcd, 0x7a, 0x14, + 0xfe, 0x04, 0x26, 0x66, 0xce, 0xf9, 0x26, 0xb3, 0xe6, 0x6e, 0xb4, + 0xd9, 0x48, 0xc8, 0x82, 0x4e, 0x07, 0x35, 0xa7, 0x6f, 0x2f, 0x02, + 0x9a, 0x06, 0x5f, 0x8c, 0xa4, 0x83, 0x0e, 0x32, 0x2a, 0x69, 0xe3, + 0xdd, 0x12, 0x08, 0x97, 0x85, 0xec, 0x2a, 0x2a, 0x42, 0xf1, 0x76, + 0x26, 0xe4, 0x6a, 0x59, 0x0e, 0x18, 0x10, 0x6a, 0xd2, 0x89, 0x02, + 0x6e, 0x2a, 0x71, 0xeb, 0x5c, 0x1c, 0x8c, 0xa6, 0x48, 0xbb, 0xdc, + 0x61, 0x41, 0x35, 0x72, 0x28, 0x87, 0xd9, 0xf6, 0x4a, 0xb9, 0xe7, + 0x38, 0xae, 0x8c, 0x3d, 0x36, 0xdd, 0xde, 0xc4, 0xb0, 0x21, 0x51, + 0x76, 0xa8, 0xc0, 0xaa, 0x93, 0x31, 0xe6, 0xbb, 0x2d, 0x65, 0x61, + 0x19, 0xd3, 0x1e, 0xb5, 0x46, 0x5a, 0x96, 0x5a, 0x30, 0xa0, 0x7e, + 0x05, 0x69, 0x5b, 0xc9, 0xc6, 0x28, 0x40, 0xcd, 0x08, 0x64, 0x3c, + 0x73, 0x57, 0xe1, 0x94, 0xf1, 0xcd, 0x5a, 0x21, 0x8c, 0xb9, 0x63, + 0xe7, 0x67, 0x1d, 0xab, 0x40, 0xb1, 0xfb, 0x00, 0x1d, 0xf0, 0x2b, + 0x99, 0x2d, 0x66, 0x3e, 0x88, 0x75, 0x81, 0x3f, 0x31, 0xf6, 0xab, + 0x64, 0xd6, 0xb4, 0x17, 0xee, 0xd0, 0x9e, 0xe4, 0x32, 0x1a, 0xa7, + 0x31, 0xad, 0x18, 0x14, 0x26, 0xef, 0x54, 0xa5, 0xa8, 0x65, 0xa3, + 0x9c, 0x81, 0xfa, 0x56, 0x8c, 0x2d, 0xce, 0x68, 0x40, 0xcb, 0xf1, + 0x37, 0xbd, 0x5e, 0x85, 0xea, 0xd1, 0x0c, 0xbb, 0x19, 0x56, 0x23, + 0x20, 0x1f, 0xad, 0x5c, 0x42, 0x08, 0x03, 0xb5, 0x55, 0x91, 0x04, + 0xc9, 0x80, 0x38, 0x00, 0x0a, 0x71, 0x34, 0x6c, 0x32, 0x27, 0xe9, + 0x55, 0x25, 0x15, 0x2c, 0x68, 0xa3, 0x30, 0xeb, 0x54, 0xa5, 0x15, + 0x0c, 0xd1, 0x00, 0xff, 0xd9}; + + /* package */ static final byte[] sPhotoByteArrayForComplicatedCase; + + static { + final int length = sPhotoIntArrayForComplicatedCase.length; + sPhotoByteArrayForComplicatedCase = new byte[length]; + for (int i = 0; i < length; i++) { + sPhotoByteArrayForComplicatedCase[i] = (byte)sPhotoIntArrayForComplicatedCase[i]; + } + } + + public void testV21SimpleCase1_Parsing() { + mVerifier.initForImportTest(V21, R.raw.v21_simple_1); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("N", "Ando;Roid;", Arrays.asList("Ando", "Roid", "")); + } + + public void testV21SimpleCase1_Type_Generic() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC_UTF8, R.raw.v21_simple_1); + mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Ando") + .put(StructuredName.GIVEN_NAME, "Roid") + .put(StructuredName.DISPLAY_NAME, "Roid Ando"); + } + + public void testV21SimpleCase1_Type_Japanese() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, R.raw.v21_simple_1); + mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Ando") + .put(StructuredName.GIVEN_NAME, "Roid") + // If name-related strings only contains printable Ascii, + // the order is remained to be US's: + // "Prefix Given Middle Family Suffix" + .put(StructuredName.DISPLAY_NAME, "Roid Ando"); + } + + public void testV21SimpleCase2() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, R.raw.v21_simple_2); + mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.DISPLAY_NAME, "Ando Roid"); + } + + public void testV21SimpleCase3() { + mVerifier.initForImportTest(V21, R.raw.v21_simple_3); + mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Ando") + .put(StructuredName.GIVEN_NAME, "Roid") + // "FN" field should be prefered since it should contain the original + // order intended by the author of the file. + .put(StructuredName.DISPLAY_NAME, "Ando Roid"); + } + + /** + * Tests ';' is properly handled by VCardParser implementation. + */ + public void testV21BackslashCase_Parsing() { + mVerifier.initForImportTest(V21, R.raw.v21_backslash); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", ";A;B\\;C\\;;D;:E;\\\\;", + Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", "")) + .addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\"); + + } + + /** + * Tests ContactStruct correctly ignores redundant fields in "N" property values and + * inserts name related data. + */ + public void testV21BackslashCase() { + mVerifier.initForImportTest(V21, R.raw.v21_backslash); + mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE) + // FAMILY_NAME is empty and removed in this test... + .put(StructuredName.GIVEN_NAME, "A;B\\") + .put(StructuredName.MIDDLE_NAME, "C\\;") + .put(StructuredName.PREFIX, "D") + .put(StructuredName.SUFFIX, ":E") + .put(StructuredName.DISPLAY_NAME, "A;B\\C\\;D:E\\\\"); + } + + public void testOrgBeforTitle() { + mVerifier.initForImportTest(V21, R.raw.v21_org_before_title); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.DISPLAY_NAME, "Normal Guy"); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Company") + .put(Organization.DEPARTMENT, "Organization Devision Room Sheet No.") + .put(Organization.TITLE, "Excellent Janitor") + .put(Organization.TYPE, Organization.TYPE_WORK); + } + + public void testTitleBeforOrg() { + mVerifier.initForImportTest(V21, R.raw.v21_title_before_org); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.DISPLAY_NAME, "Nice Guy"); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Marverous") + .put(Organization.DEPARTMENT, "Perfect Great Good Bad Poor") + .put(Organization.TITLE, "Cool Title") + .put(Organization.TYPE, Organization.TYPE_WORK); + } + + /** + * Verifies that vCard importer correctly interpret "PREF" attribute to IS_PRIMARY. + * The data contain three cases: one "PREF", no "PREF" and multiple "PREF", in each type. + */ + public void testV21PrefToIsPrimary() { + mVerifier.initForImportTest(V21, R.raw.v21_pref_handling); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.DISPLAY_NAME, "Smith"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "1") + .put(Phone.TYPE, Phone.TYPE_HOME); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "2") + .put(Phone.TYPE, Phone.TYPE_WORK) + .put(Phone.IS_PRIMARY, 1); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "3") + .put(Phone.TYPE, Phone.TYPE_ISDN); + elem.addExpected(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "test@example.com") + .put(Email.TYPE, Email.TYPE_HOME) + .put(Email.IS_PRIMARY, 1); + elem.addExpected(Email.CONTENT_ITEM_TYPE) + .put(Email.DATA, "test2@examination.com") + .put(Email.TYPE, Email.TYPE_MOBILE) + .put(Email.IS_PRIMARY, 1); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Company") + .put(Organization.TITLE, "Engineer") + .put(Organization.TYPE, Organization.TYPE_WORK); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Mystery") + .put(Organization.TITLE, "Blogger") + .put(Organization.TYPE, Organization.TYPE_WORK); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Poetry") + .put(Organization.TITLE, "Poet") + .put(Organization.TYPE, Organization.TYPE_WORK); + } + + /** + * Tests all the properties in a complicated vCard are correctly parsed by the VCardParser. + */ + public void testV21ComplicatedCase_Parsing() { + mVerifier.initForImportTest(V21, R.raw.v21_complicated); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", "Gump;Forrest;Hoge;Pos;Tao", + Arrays.asList("Gump", "Forrest", "Hoge", "Pos", "Tao")) + .addExpectedNodeWithOrder("FN", "Joe Due") + .addExpectedNodeWithOrder("ORG", "Gump Shrimp Co.;Sales Dept.;Manager;Fish keeper", + Arrays.asList("Gump Shrimp Co.", "Sales Dept.;Manager", "Fish keeper")) + .addExpectedNodeWithOrder("ROLE", "Fish Cake Keeper!") + .addExpectedNodeWithOrder("TITLE", "Shrimp Man") + .addExpectedNodeWithOrder("X-CLASS", "PUBLIC") + .addExpectedNodeWithOrder("TEL", "(111) 555-1212", new TypeSet("WORK", "VOICE")) + .addExpectedNodeWithOrder("TEL", "(404) 555-1212", new TypeSet("HOME", "VOICE")) + .addExpectedNodeWithOrder("TEL", "0311111111", new TypeSet("CELL")) + .addExpectedNodeWithOrder("TEL", "0322222222", new TypeSet("VIDEO")) + .addExpectedNodeWithOrder("TEL", "0333333333", new TypeSet("VOICE")) + .addExpectedNodeWithOrder("ADR", + ";;100 Waters Edge;Baytown;LA;30314;United States of America", + Arrays.asList("", "", "100 Waters Edge", "Baytown", + "LA", "30314", "United States of America"), + null, null, new TypeSet("WORK"), null) + .addExpectedNodeWithOrder("LABEL", + "100 Waters Edge\r\nBaytown, LA 30314\r\nUnited States of America", + null, null, mContentValuesForQP, new TypeSet("WORK"), null) + .addExpectedNodeWithOrder("ADR", + ";;42 Plantation St.;Baytown;LA;30314;United States of America", + Arrays.asList("", "", "42 Plantation St.", "Baytown", + "LA", "30314", "United States of America"), null, null, + new TypeSet("HOME"), null) + .addExpectedNodeWithOrder("LABEL", + "42 Plantation St.\r\nBaytown, LA 30314\r\nUnited States of America", + null, null, mContentValuesForQP, + new TypeSet("HOME"), null) + .addExpectedNodeWithOrder("EMAIL", "forrestgump@walladalla.com", + new TypeSet("PREF", "INTERNET")) + .addExpectedNodeWithOrder("EMAIL", "cell@example.com", new TypeSet("CELL")) + .addExpectedNodeWithOrder("NOTE", "The following note is the example from RFC 2045.") + .addExpectedNodeWithOrder("NOTE", + "Now's the time for all folk to come to the aid of their country.", + null, null, mContentValuesForQP, null, null) + .addExpectedNodeWithOrder("PHOTO", null, + null, sPhotoByteArrayForComplicatedCase, mContentValuesForBase64V21, + new TypeSet("JPEG"), null) + .addExpectedNodeWithOrder("X-ATTRIBUTE", "Some String") + .addExpectedNodeWithOrder("BDAY", "19800101") + .addExpectedNodeWithOrder("GEO", "35.6563854,139.6994233") + .addExpectedNodeWithOrder("URL", "http://www.example.com/") + .addExpectedNodeWithOrder("REV", "20080424T195243Z"); + } + + /** + * Checks ContactStruct correctly inserts values in a complicated vCard + * into ContentResolver. + */ + public void testV21ComplicatedCase() { + mVerifier.initForImportTest(V21, R.raw.v21_complicated); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Gump") + .put(StructuredName.GIVEN_NAME, "Forrest") + .put(StructuredName.MIDDLE_NAME, "Hoge") + .put(StructuredName.PREFIX, "Pos") + .put(StructuredName.SUFFIX, "Tao") + .put(StructuredName.DISPLAY_NAME, "Joe Due"); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.TYPE, Organization.TYPE_WORK) + .put(Organization.COMPANY, "Gump Shrimp Co.") + .put(Organization.DEPARTMENT, "Sales Dept.;Manager Fish keeper") + .put(Organization.TITLE, "Shrimp Man"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_WORK) + // Phone number is expected to be formated with NAMP format in default. + .put(Phone.NUMBER, "111-555-1212"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_HOME) + .put(Phone.NUMBER, "404-555-1212"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_MOBILE) + .put(Phone.NUMBER, "031-111-1111"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "VIDEO") + .put(Phone.NUMBER, "032-222-2222"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "VOICE") + .put(Phone.NUMBER, "033-333-3333"); + elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK) + .put(StructuredPostal.COUNTRY, "United States of America") + .put(StructuredPostal.POSTCODE, "30314") + .put(StructuredPostal.REGION, "LA") + .put(StructuredPostal.CITY, "Baytown") + .put(StructuredPostal.STREET, "100 Waters Edge") + .put(StructuredPostal.FORMATTED_ADDRESS, + "100 Waters Edge Baytown LA 30314 United States of America"); + elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME) + .put(StructuredPostal.COUNTRY, "United States of America") + .put(StructuredPostal.POSTCODE, "30314") + .put(StructuredPostal.REGION, "LA") + .put(StructuredPostal.CITY, "Baytown") + .put(StructuredPostal.STREET, "42 Plantation St.") + .put(StructuredPostal.FORMATTED_ADDRESS, + "42 Plantation St. Baytown LA 30314 United States of America"); + elem.addExpected(Email.CONTENT_ITEM_TYPE) + // "TYPE=INTERNET" -> TYPE_CUSTOM + the label "INTERNET" + .put(Email.TYPE, Email.TYPE_CUSTOM) + .put(Email.LABEL, "INTERNET") + .put(Email.DATA, "forrestgump@walladalla.com") + .put(Email.IS_PRIMARY, 1); + elem.addExpected(Email.CONTENT_ITEM_TYPE) + .put(Email.TYPE, Email.TYPE_MOBILE) + .put(Email.DATA, "cell@example.com"); + elem.addExpected(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "The following note is the example from RFC 2045."); + elem.addExpected(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, + "Now's the time for all folk to come to the aid of their country."); + elem.addExpected(Photo.CONTENT_ITEM_TYPE) + // No information about its image format can be inserted. + .put(Photo.PHOTO, sPhotoByteArrayForComplicatedCase); + elem.addExpected(Event.CONTENT_ITEM_TYPE) + .put(Event.START_DATE, "19800101") + .put(Event.TYPE, Event.TYPE_BIRTHDAY); + elem.addExpected(Website.CONTENT_ITEM_TYPE) + .put(Website.URL, "http://www.example.com/") + .put(Website.TYPE, Website.TYPE_HOMEPAGE); + } + + public void testV30Simple_Parsing() { + mVerifier.initForImportTest(V30, R.raw.v30_simple); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "3.0") + .addExpectedNodeWithOrder("FN", "And Roid") + .addExpectedNodeWithOrder("N", "And;Roid;;;", Arrays.asList("And", "Roid", "", "", "")) + .addExpectedNodeWithOrder("ORG", "Open;Handset; Alliance", + Arrays.asList("Open", "Handset", " Alliance")) + .addExpectedNodeWithOrder("SORT-STRING", "android") + .addExpectedNodeWithOrder("TEL", "0300000000", new TypeSet("PREF", "VOICE")) + .addExpectedNodeWithOrder("CLASS", "PUBLIC") + .addExpectedNodeWithOrder("X-GNO", "0") + .addExpectedNodeWithOrder("X-GN", "group0") + .addExpectedNodeWithOrder("X-REDUCTION", "0") + .addExpectedNodeWithOrder("REV", "20081031T065854Z"); + } + + public void testV30Simple() { + mVerifier.initForImportTest(V30, R.raw.v30_simple); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "And") + .put(StructuredName.GIVEN_NAME, "Roid") + .put(StructuredName.DISPLAY_NAME, "And Roid") + .put(StructuredName.PHONETIC_GIVEN_NAME, "android"); + elem.addExpected(Organization.CONTENT_ITEM_TYPE) + .put(Organization.COMPANY, "Open") + .put(Organization.DEPARTMENT, "Handset Alliance") + .put(Organization.TYPE, Organization.TYPE_WORK); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "VOICE") + .put(Phone.NUMBER, "030-000-0000") + .put(Phone.IS_PRIMARY, 1); + } + + public void testV21Japanese1_Parsing() { + // Though Japanese careers append ";;;;" at the end of the value of "SOUND", + // vCard 2.1/3.0 specification does not allow multiple values. + // Do not need to handle it as multiple values. + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, + R.raw.v21_japanese_1); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1", null, null, null, null, null) + .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9;;;;", + Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9", "", "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("SOUND", + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E;;;;", + null, null, mContentValuesForSJis, + new TypeSet("X-IRMC-N"), null) + .addExpectedNodeWithOrder("TEL", "0300000000", null, null, null, + new TypeSet("VOICE", "PREF"), null); + } + + private void testV21Japanese1Common(int resId, int vcardType, boolean japanese) { + mVerifier.initForImportTest(vcardType, resId); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9") + .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9") + // While vCard parser does not split "SOUND" property values, + // ContactStruct care it. + .put(StructuredName.PHONETIC_GIVEN_NAME, + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + // Phone number formatting is different. + .put(Phone.NUMBER, (japanese ? "03-0000-0000" : "030-000-0000")) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "VOICE") + .put(Phone.IS_PRIMARY, 1); + } + + /** + * Verifies vCard with Japanese can be parsed correctly with + * {@link android.pim.vcard.VCardConfig#VCARD_TYPE_V21_GENERIC_UTF8}. + */ + public void testV21Japanese1_Type_Generic_Utf8() { + testV21Japanese1Common( + R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_GENERIC_UTF8, false); + } + + /** + * Verifies vCard with Japanese can be parsed correctly with + * {@link android.pim.vcard.VCardConfig#VCARD_TYPE_V21_JAPANESE_SJIS}. + */ + public void testV21Japanese1_Type_Japanese_Sjis() { + testV21Japanese1Common( + R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, true); + } + + /** + * Verifies vCard with Japanese can be parsed correctly with + * {@link android.pim.vcard.VCardConfig#VCARD_TYPE_V21_JAPANESE_UTF8}. + * since vCard 2.1 specifies the charset of each line if it contains non-Ascii. + */ + public void testV21Japanese1_Type_Japanese_Utf8() { + testV21Japanese1Common( + R.raw.v21_japanese_1, VCardConfig.VCARD_TYPE_V21_JAPANESE_UTF8, true); + } + + public void testV21Japanese2_Parsing() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, + R.raw.v21_japanese_2); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", "\u5B89\u85E4;\u30ED\u30A4\u30C9\u0031;;;", + Arrays.asList("\u5B89\u85E4", "\u30ED\u30A4\u30C9\u0031", + "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("FN", "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9\u0020\u0031", + null, null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("SOUND", + "\uFF71\uFF9D\uFF84\uFF9E\uFF73;\uFF9B\uFF72\uFF84\uFF9E\u0031;;;", + null, null, mContentValuesForSJis, + new TypeSet("X-IRMC-N"), null) + .addExpectedNodeWithOrder("ADR", + ";\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + + "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + + "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC\u0036" + + "\u968E;;;;150-8512;", + Arrays.asList("", + "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + + "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + + "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" + + "\u0036\u968E", "", "", "", "150-8512", ""), + null, mContentValuesForQPAndSJis, new TypeSet("HOME"), null) + .addExpectedNodeWithOrder("NOTE", "\u30E1\u30E2", null, null, + mContentValuesForQPAndSJis, null, null); + } + + public void testV21Japanese2_Type_Generic_Utf8() { + mVerifier.initForImportTest(V21, R.raw.v21_japanese_2); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4") + .put(StructuredName.GIVEN_NAME, "\u30ED\u30A4\u30C9\u0031") + .put(StructuredName.DISPLAY_NAME, + "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9\u0020\u0031") + // ContactStruct should correctly split "SOUND" property into several elements, + // even though VCardParser side does not care it. + .put(StructuredName.PHONETIC_FAMILY_NAME, "\uFF71\uFF9D\uFF84\uFF9E\uFF73") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\uFF9B\uFF72\uFF84\uFF9E\u0031"); + elem.addExpected(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POSTCODE, "150-8512") + .put(StructuredPostal.STREET, + "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + + "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + + "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" + + "\u0036\u968E") + .put(StructuredPostal.FORMATTED_ADDRESS, + "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + + "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + + "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" + + "\u0036\u968E 150-8512") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME); + elem.addExpected(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "\u30E1\u30E2"); + } + + public void testV21MultipleEntryCase_Parse() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, + R.raw.v21_multiple_entry); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033;;;;", + Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0033", "", "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("SOUND", + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0033;;;;", + null, null, mContentValuesForSJis, + new TypeSet("X-IRMC-N"), null) + .addExpectedNodeWithOrder("TEL", "9", new TypeSet("X-NEC-SECRET")) + .addExpectedNodeWithOrder("TEL", "10", new TypeSet("X-NEC-HOTEL")) + .addExpectedNodeWithOrder("TEL", "11", new TypeSet("X-NEC-SCHOOL")) + .addExpectedNodeWithOrder("TEL", "12", new TypeSet("FAX", "HOME")); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034;;;;", + Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0034", "", "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("SOUND", + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0034;;;;", + null, null, mContentValuesForSJis, + new TypeSet("X-IRMC-N"), null) + .addExpectedNodeWithOrder("TEL", "13", new TypeSet("MODEM")) + .addExpectedNodeWithOrder("TEL", "14", new TypeSet("PAGER")) + .addExpectedNodeWithOrder("TEL", "15", new TypeSet("X-NEC-FAMILY")) + .addExpectedNodeWithOrder("TEL", "16", new TypeSet("X-NEC-GIRL")); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035;;;;", + Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0035", "", "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNodeWithOrder("SOUND", + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0035;;;;", + null, null, mContentValuesForSJis, + new TypeSet("X-IRMC-N"), null) + .addExpectedNodeWithOrder("TEL", "17", new TypeSet("X-NEC-BOY")) + .addExpectedNodeWithOrder("TEL", "18", new TypeSet("X-NEC-FRIEND")) + .addExpectedNodeWithOrder("TEL", "19", new TypeSet("X-NEC-PHS")) + .addExpectedNodeWithOrder("TEL", "20", new TypeSet("X-NEC-RESTAURANT")); + } + + public void testV21MultipleEntryCase() { + mVerifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS, + R.raw.v21_multiple_entry); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033") + .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033") + .put(StructuredName.PHONETIC_GIVEN_NAME, + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0033"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-SECRET") + .put(Phone.NUMBER, "9"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-HOTEL") + .put(Phone.NUMBER, "10"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-SCHOOL") + .put(Phone.NUMBER, "11"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_FAX_HOME) + .put(Phone.NUMBER, "12"); + + elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034") + .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034") + .put(StructuredName.PHONETIC_GIVEN_NAME, + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0034"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "MODEM") + .put(Phone.NUMBER, "13"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_PAGER) + .put(Phone.NUMBER, "14"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-FAMILY") + .put(Phone.NUMBER, "15"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-GIRL") + .put(Phone.NUMBER, "16"); + + elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035") + .put(StructuredName.DISPLAY_NAME, "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035") + .put(StructuredName.PHONETIC_GIVEN_NAME, + "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0035"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-BOY") + .put(Phone.NUMBER, "17"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-FRIEND") + .put(Phone.NUMBER, "18"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-PHS") + .put(Phone.NUMBER, "19"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_CUSTOM) + .put(Phone.LABEL, "NEC-RESTAURANT") + .put(Phone.NUMBER, "20"); + } + + public void testIgnoreAgentV21_Parse() { + mVerifier.initForImportTest(V21, R.raw.v21_winmo_65); + ContentValues contentValuesForValue = new ContentValues(); + contentValuesForValue.put("VALUE", "DATE"); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "2.1") + .addExpectedNodeWithOrder("N", Arrays.asList("Example", "", "", "", "")) + .addExpectedNodeWithOrder("FN", "Example") + .addExpectedNodeWithOrder("ANNIVERSARY", "20091010", contentValuesForValue) + .addExpectedNodeWithOrder("AGENT", "") + .addExpectedNodeWithOrder("X-CLASS", "PUBLIC") + .addExpectedNodeWithOrder("X-REDUCTION", "") + .addExpectedNodeWithOrder("X-NO", ""); + } + + public void testIgnoreAgentV21() { + mVerifier.initForImportTest(V21, R.raw.v21_winmo_65); + ContentValuesVerifier verifier = new ContentValuesVerifier(); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "Example") + .put(StructuredName.DISPLAY_NAME, "Example"); + } + + public void testTolerateInvalidCommentLikeLineV21() { + mVerifier.initForImportTest(V21, R.raw.v21_invalid_comment_line); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.GIVEN_NAME, "Conference Call") + .put(StructuredName.DISPLAY_NAME, "Conference Call"); + elem.addExpected(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "This is an (sharp ->#<- sharp) example. " + + "This message must NOT be ignored."); + } + + public void testPagerV30_Parse() { + mVerifier.initForImportTest(V30, R.raw.v30_comma_separated); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNodeWithOrder("VERSION", "3.0") + .addExpectedNodeWithOrder("N", Arrays.asList("F", "G", "M", "", "")) + .addExpectedNodeWithOrder("TEL", "6101231234@pagersample.com", + new TypeSet("WORK", "MSG", "PAGER")); + } + + public void testPagerV30() { + mVerifier.initForImportTest(V30, R.raw.v30_comma_separated); + ContentValuesVerifierElem elem = mVerifier.addContentValuesVerifierElem(); + elem.addExpected(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "F") + .put(StructuredName.MIDDLE_NAME, "M") + .put(StructuredName.GIVEN_NAME, "G") + .put(StructuredName.DISPLAY_NAME, "G M F"); + elem.addExpected(Phone.CONTENT_ITEM_TYPE) + .put(Phone.TYPE, Phone.TYPE_PAGER) + .put(Phone.NUMBER, "6101231234@pagersample.com"); + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java new file mode 100644 index 0000000..eea98c6 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardJapanizationTests.java @@ -0,0 +1,434 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.vcard; + +import android.content.ContentValues; +import android.pim.vcard.VCardConfig; +import android.provider.ContactsContract.CommonDataKinds.Nickname; +import android.provider.ContactsContract.CommonDataKinds.Note; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; + +import com.android.unit_tests.vcard.PropertyNodesVerifierElem.TypeSet; + +import java.util.Arrays; + +public class VCardJapanizationTests extends VCardTestsBase { + private void testNameUtf8Common(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u3075\u308B\u3069") + .put(StructuredName.GIVEN_NAME, "\u3091\u308A\u304B") + .put(StructuredName.MIDDLE_NAME, "B") + .put(StructuredName.PREFIX, "Dr.") + .put(StructuredName.SUFFIX, "Ph.D"); + ContentValues contentValues = + (VCardConfig.isV30(vcardType) ? null : mContentValuesForQPAndUtf8); + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("FN", "Dr. \u3075\u308B\u3069 B \u3091\u308A\u304B Ph.D", + contentValues) + .addExpectedNode("N", "\u3075\u308B\u3069;\u3091\u308A\u304B;B;Dr.;Ph.D", + Arrays.asList( + "\u3075\u308B\u3069", "\u3091\u308A\u304B", "B", "Dr.", "Ph.D"), + null, contentValues, null, null); + } + + public void testNameUtf8V21() { + testNameUtf8Common(VCardConfig.VCARD_TYPE_V21_JAPANESE_UTF8); + } + + public void testNameUtf8V30() { + testNameUtf8Common(VCardConfig.VCARD_TYPE_V30_JAPANESE_UTF8); + } + + public void testNameShiftJis() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_V30_JAPANESE_SJIS); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u3075\u308B\u3069") + .put(StructuredName.GIVEN_NAME, "\u3091\u308A\u304B") + .put(StructuredName.MIDDLE_NAME, "B") + .put(StructuredName.PREFIX, "Dr.") + .put(StructuredName.SUFFIX, "Ph.D"); + + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("FN", "Dr. \u3075\u308B\u3069 B \u3091\u308A\u304B Ph.D", + mContentValuesForSJis) + .addExpectedNode("N", "\u3075\u308B\u3069;\u3091\u308A\u304B;B;Dr.;Ph.D", + Arrays.asList( + "\u3075\u308B\u3069", "\u3091\u308A\u304B", "B", "Dr.", "Ph.D"), + null, mContentValuesForSJis, null, null); + } + + /** + * DoCoMo phones require all name elements should be in "family name" field. + */ + public void testNameDoCoMo() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.FAMILY_NAME, "\u3075\u308B\u3069") + .put(StructuredName.GIVEN_NAME, "\u3091\u308A\u304B") + .put(StructuredName.MIDDLE_NAME, "B") + .put(StructuredName.PREFIX, "Dr.") + .put(StructuredName.SUFFIX, "Ph.D"); + + final String fullName = "Dr. \u3075\u308B\u3069 B \u3091\u308A\u304B Ph.D"; + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("N", fullName + ";;;;", + Arrays.asList(fullName, "", "", "", ""), + null, mContentValuesForSJis, null, null) + .addExpectedNode("FN", fullName, mContentValuesForSJis) + .addExpectedNode("SOUND", ";;;;", new TypeSet("X-IRMC-N")) + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("ADR", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", ""); + } + + private void testPhoneticNameCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.PHONETIC_FAMILY_NAME, "\u3084\u307E\u3060") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "\u30DF\u30C9\u30EB\u30CD\u30FC\u30E0") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\u305F\u308D\u3046"); + + final ContentValues contentValues = + (VCardConfig.usesShiftJis(vcardType) ? + (VCardConfig.isV30(vcardType) ? mContentValuesForSJis : + mContentValuesForQPAndSJis) : + (VCardConfig.isV30(vcardType) ? null : mContentValuesForQPAndUtf8)); + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElemWithEmptyName(); + elem.addExpectedNode("X-PHONETIC-LAST-NAME", "\u3084\u307E\u3060", + contentValues) + .addExpectedNode("X-PHONETIC-MIDDLE-NAME", + "\u30DF\u30C9\u30EB\u30CD\u30FC\u30E0", + contentValues) + .addExpectedNode("X-PHONETIC-FIRST-NAME", "\u305F\u308D\u3046", + contentValues); + if (VCardConfig.isV30(vcardType)) { + elem.addExpectedNode("SORT-STRING", + "\u3084\u307E\u3060 \u30DF\u30C9\u30EB\u30CD\u30FC\u30E0 \u305F\u308D\u3046", + contentValues); + } + ContentValuesBuilder builder = mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE); + builder.put(StructuredName.PHONETIC_FAMILY_NAME, "\u3084\u307E\u3060") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "\u30DF\u30C9\u30EB\u30CD\u30FC\u30E0") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\u305F\u308D\u3046") + .put(StructuredName.DISPLAY_NAME, + "\u3084\u307E\u3060 \u30DF\u30C9\u30EB\u30CD\u30FC\u30E0 " + + "\u305F\u308D\u3046"); + } + + public void testPhoneticNameForJapaneseV21Utf8() { + testPhoneticNameCommon(VCardConfig.VCARD_TYPE_V21_JAPANESE_UTF8); + } + + public void testPhoneticNameForJapaneseV21Sjis() { + testPhoneticNameCommon(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS); + } + + public void testPhoneticNameForJapaneseV30Utf8() { + testPhoneticNameCommon(VCardConfig.VCARD_TYPE_V30_JAPANESE_UTF8); + } + + public void testPhoneticNameForJapaneseV30SJis() { + testPhoneticNameCommon(VCardConfig.VCARD_TYPE_V30_JAPANESE_SJIS); + } + + public void testPhoneticNameForMobileV21_1() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_MOBILE); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.PHONETIC_FAMILY_NAME, "\u3084\u307E\u3060") + .put(StructuredName.PHONETIC_MIDDLE_NAME, "\u30DF\u30C9\u30EB\u30CD\u30FC\u30E0") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\u305F\u308D\u3046"); + + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("SOUND", + "\uFF94\uFF8F\uFF80\uFF9E \uFF90\uFF84\uFF9E\uFF99\uFF88\uFF70\uFF91 " + + "\uFF80\uFF9B\uFF73;;;;", + mContentValuesForSJis, new TypeSet("X-IRMC-N")); + ContentValuesBuilder builder = mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE); + builder.put(StructuredName.PHONETIC_FAMILY_NAME, "\uFF94\uFF8F\uFF80\uFF9E") + .put(StructuredName.PHONETIC_MIDDLE_NAME, + "\uFF90\uFF84\uFF9E\uFF99\uFF88\uFF70\uFF91") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\uFF80\uFF9B\uFF73") + .put(StructuredName.DISPLAY_NAME, + "\uFF94\uFF8F\uFF80\uFF9E \uFF90\uFF84\uFF9E\uFF99\uFF88\uFF70\uFF91 " + + "\uFF80\uFF9B\uFF73"); + } + + public void testPhoneticNameForMobileV21_2() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_V21_JAPANESE_MOBILE); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredName.CONTENT_ITEM_TYPE) + .put(StructuredName.PHONETIC_FAMILY_NAME, "\u3084\u307E\u3060") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\u305F\u308D\u3046"); + + mVerifier.addPropertyNodesVerifierElem() + .addExpectedNode("SOUND", "\uFF94\uFF8F\uFF80\uFF9E \uFF80\uFF9B\uFF73;;;;", + mContentValuesForSJis, new TypeSet("X-IRMC-N")); + ContentValuesBuilder builder = mVerifier.addContentValuesVerifierElem() + .addExpected(StructuredName.CONTENT_ITEM_TYPE); + builder.put(StructuredName.PHONETIC_FAMILY_NAME, "\uFF94\uFF8F\uFF80\uFF9E") + .put(StructuredName.PHONETIC_GIVEN_NAME, "\uFF80\uFF9B\uFF73") + .put(StructuredName.DISPLAY_NAME, "\uFF94\uFF8F\uFF80\uFF9E \uFF80\uFF9B\uFF73"); + } + + private void testPostalAddressWithJapaneseCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "\u79C1\u66F8\u7BB107") + .put(StructuredPostal.STREET, "\u96DB\u898B\u6CA2\u6751") + .put(StructuredPostal.CITY, "\u9E7F\u9AA8\u5E02") + .put(StructuredPostal.REGION, "\u00D7\u00D7\u770C") + .put(StructuredPostal.POSTCODE, "494-1313") + .put(StructuredPostal.COUNTRY, "\u65E5\u672C") + .put(StructuredPostal.FORMATTED_ADDRESS, + "\u3053\u3093\u306A\u3068\u3053\u308D\u3092\u898B" + + "\u308B\u306A\u3093\u3066\u6687\u4EBA\u3067\u3059\u304B\uFF1F") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "\u304A\u3082\u3061\u304B\u3048\u308A"); + + ContentValues contentValues = (VCardConfig.usesShiftJis(vcardType) ? + (VCardConfig.isV30(vcardType) ? mContentValuesForSJis : + mContentValuesForQPAndSJis) : + (VCardConfig.isV30(vcardType) ? mContentValuesForUtf8 : + mContentValuesForQPAndUtf8)); + + PropertyNodesVerifierElem elem = mVerifier.addPropertyNodesVerifierElemWithEmptyName(); + // LABEL must be ignored in vCard 2.1. As for vCard 3.0, the current behavior is + // same as that in vCard 3.0, which can be changed in the future. + elem.addExpectedNode("ADR", Arrays.asList("\u79C1\u66F8\u7BB107", + "", "\u96DB\u898B\u6CA2\u6751", "\u9E7F\u9AA8\u5E02", "\u00D7\u00D7\u770C", + "494-1313", "\u65E5\u672C"), + contentValues); + mVerifier.addContentValuesVerifierElem().addExpected(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "\u79C1\u66F8\u7BB107") + .put(StructuredPostal.STREET, "\u96DB\u898B\u6CA2\u6751") + .put(StructuredPostal.CITY, "\u9E7F\u9AA8\u5E02") + .put(StructuredPostal.REGION, "\u00D7\u00D7\u770C") + .put(StructuredPostal.POSTCODE, "494-1313") + .put(StructuredPostal.COUNTRY, "\u65E5\u672C") + .put(StructuredPostal.FORMATTED_ADDRESS, + "\u65E5\u672C 494-1313 \u00D7\u00D7\u770C \u9E7F\u9AA8\u5E02 " + + "\u96DB\u898B\u6CA2\u6751 " + "\u79C1\u66F8\u7BB107") + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME); + } + public void testPostalAddresswithJapaneseV21() { + testPostalAddressWithJapaneseCommon(VCardConfig.VCARD_TYPE_V21_JAPANESE_SJIS); + } + + /** + * Verifies that only one address field is emitted toward DoCoMo phones. + * Prefered type must (should?) be: HOME > WORK > OTHER > CUSTOM + */ + public void testPostalAdrressForDoCoMo_1() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK) + .put(StructuredPostal.POBOX, "1"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_OTHER) + .put(StructuredPostal.POBOX, "2"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME) + .put(StructuredPostal.POBOX, "3"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "custom") + .put(StructuredPostal.POBOX, "4"); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", + Arrays.asList("3", "", "", "", "", "", ""), new TypeSet("HOME")); + } + + public void testPostalAdrressForDoCoMo_2() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_OTHER) + .put(StructuredPostal.POBOX, "1"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK) + .put(StructuredPostal.POBOX, "2"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "custom") + .put(StructuredPostal.POBOX, "3"); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", + Arrays.asList("2", "", "", "", "", "", ""), new TypeSet("WORK")); + } + + public void testPostalAdrressForDoCoMo_3() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "custom1") + .put(StructuredPostal.POBOX, "1"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_OTHER) + .put(StructuredPostal.POBOX, "2"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_CUSTOM) + .put(StructuredPostal.LABEL, "custom2") + .put(StructuredPostal.POBOX, "3"); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", Arrays.asList("2", "", "", "", "", "", "")); + } + + /** + * Verifies the vCard exporter tolerates null TYPE. + */ + public void testPostalAdrressForDoCoMo_4() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "1"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_OTHER) + .put(StructuredPostal.POBOX, "2"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME) + .put(StructuredPostal.POBOX, "3"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK) + .put(StructuredPostal.POBOX, "4"); + entry.addContentValues(StructuredPostal.CONTENT_ITEM_TYPE) + .put(StructuredPostal.POBOX, "5"); + + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", + Arrays.asList("3", "", "", "", "", "", ""), new TypeSet("HOME")); + } + + private void testJapanesePhoneNumberCommon(int vcardType) { + mVerifier.initForExportTest(vcardType); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "0312341234") + .put(Phone.TYPE, Phone.TYPE_HOME); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "09012341234") + .put(Phone.TYPE, Phone.TYPE_MOBILE); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "03-1234-1234", new TypeSet("HOME")) + .addExpectedNode("TEL", "090-1234-1234", new TypeSet("CELL")); + } + + public void testJapanesePhoneNumberV21_1() { + testJapanesePhoneNumberCommon(VCardConfig.VCARD_TYPE_V21_JAPANESE_UTF8); + } + + public void testJapanesePhoneNumberV30() { + testJapanesePhoneNumberCommon(VCardConfig.VCARD_TYPE_V30_JAPANESE_UTF8); + } + + public void testJapanesePhoneNumberDoCoMo() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "0312341234") + .put(Phone.TYPE, Phone.TYPE_HOME); + entry.addContentValues(Phone.CONTENT_ITEM_TYPE) + .put(Phone.NUMBER, "09012341234") + .put(Phone.TYPE, Phone.TYPE_MOBILE); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", "", new TypeSet("HOME")) + .addExpectedNode("TEL", "03-1234-1234", new TypeSet("HOME")) + .addExpectedNode("TEL", "090-1234-1234", new TypeSet("CELL")); + } + + public void testNoteDoCoMo() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_DOCOMO); + ContactEntry entry = mVerifier.addInputEntry(); + entry.addContentValues(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "note1"); + entry.addContentValues(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "note2"); + entry.addContentValues(Note.CONTENT_ITEM_TYPE) + .put(Note.NOTE, "note3"); + + // More than one note fields must be aggregated into one note. + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("TEL", "", new TypeSet("HOME")) + .addExpectedNode("EMAIL", "", new TypeSet("HOME")) + .addExpectedNode("X-CLASS", "PUBLIC") + .addExpectedNode("X-REDUCTION", "") + .addExpectedNode("X-NO", "") + .addExpectedNode("X-DCM-HMN-MODE", "") + .addExpectedNode("ADR", "", new TypeSet("HOME")) + .addExpectedNode("NOTE", "note1\nnote2\nnote3", mContentValuesForQP); + } + + public void testAndroidCustomV21() { + mVerifier.initForExportTest(VCardConfig.VCARD_TYPE_V21_GENERIC_UTF8); + mVerifier.addInputEntry().addContentValues(Nickname.CONTENT_ITEM_TYPE) + .put(Nickname.NAME, "\u304D\u3083\u30FC\u30A8\u30C3\u30C1\u30FC"); + mVerifier.addPropertyNodesVerifierElemWithEmptyName() + .addExpectedNode("X-ANDROID-CUSTOM", + Arrays.asList(Nickname.CONTENT_ITEM_TYPE, + "\u304D\u3083\u30FC\u30A8\u30C3\u30C1\u30FC", + "", "", "", "", "", "", "", "", "", "", "", "", "", ""), + mContentValuesForQPAndUtf8); + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTests.java deleted file mode 100644 index 7589ba8..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTests.java +++ /dev/null @@ -1,923 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.unit_tests.vcard; - -import android.content.ContentValues; -import android.pim.vcard.ContactStruct; -import android.pim.vcard.EntryHandler; -import android.pim.vcard.VCardParser_V21; -import android.pim.vcard.VCardParser_V30; -import android.pim.vcard.exception.VCardException; -import android.test.AndroidTestCase; - -import com.android.unit_tests.R; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -public class VCardTests extends AndroidTestCase { - - // TODO: Use EntityIterator, which is added in Eclair. - private static class EntryHolder implements EntryHandler { - public List<ContactStruct> contacts = new ArrayList<ContactStruct>(); - public void onParsingStart() { - } - public void onEntryCreated(ContactStruct contactStruct) { - contacts.add(contactStruct); - } - public void onParsingEnd() { - } - } - /* - static void verify(ContactStruct expected, ContactStruct actual) { - if (!equalsString(expected.getName(), actual.getName())) { - fail(String.format("Names do not equal: \"%s\" != \"%s\"", - expected.getName(), actual.getName())); - } - if (!equalsString( - expected.getPhoneticName(), actual.getPhoneticName())) { - fail(String.format("Phonetic names do not equal: \"%s\" != \"%s\"", - expected.getPhoneticName(), actual.getPhoneticName())); - } - { - final byte[] expectedPhotoBytes = expected.getPhotoBytes(); - final byte[] actualPhotoBytes = actual.getPhotoBytes(); - if (!((expectedPhotoBytes == null && actualPhotoBytes == null) || - Arrays.equals(expectedPhotoBytes, actualPhotoBytes))) { - fail("photoBytes is not equal."); - } - } - verifyInternal(expected.getNotes(), actual.getNotes(), "notes"); - verifyInternal(expected.getPhoneList(), actual.getPhoneList(), "phones"); - verifyInternal(expected.getContactMethodList(), actual.getContactMethodList(), - "contact lists"); - verifyInternal(expected.getOrganizationList(), actual.getOrganizationList(), - "organizations"); - { - final Map<String, List<String>> expectedMap = - expected.getExtensionMap(); - final Map<String, List<String>> actualMap = - actual.getExtensionMap(); - if (verifySize((expectedMap == null ? 0 : expectedMap.size()), - (actualMap == null ? 0 : actualMap.size()), "extensions") > 0) { - for (String key : expectedMap.keySet()) { - if (!actualMap.containsKey(key)) { - fail(String.format( - "Actual does not have %s extension while expected has", - key)); - } - final List<String> expectedList = expectedMap.get(key); - final List<String> actualList = actualMap.get(key); - verifyInternal(expectedList, actualList, - String.format("extension \"%s\"", key)); - } - } - } - } - - private static boolean equalsString(String a, String b) { - if (a == null || a.length() == 0) { - return b == null || b.length() == 0; - } else { - return a.equals(b); - } - } - - private static int verifySize(int expectedSize, int actualSize, String name) { - if (expectedSize != actualSize) { - fail(String.format("Size of %s is different: %d != %d", - name, expectedSize, actualSize)); - } - return expectedSize; - } - - private static <T> void verifyInternal(final List<T> expected, final List<T> actual, - String name) { - if(verifySize((expected == null ? 0 : expected.size()), - (actual == null ? 0 : actual.size()), name) > 0) { - int size = expected.size(); - for (int i = 0; i < size; i++) { - final T expectedObj = expected.get(i); - final T actualObj = actual.get(i); - if (!expected.equals(actual)) { - fail(String.format("The %i %s are different: %s != %s", - i, name, expectedObj, actualObj)); - } - } - } - }*/ - - private class PropertyNodesVerifier { - private HashMap<String, ArrayList<PropertyNode>> mPropertyNodeMap; - public PropertyNodesVerifier(PropertyNode... nodes) { - mPropertyNodeMap = new HashMap<String, ArrayList<PropertyNode>>(); - for (PropertyNode propertyNode : nodes) { - String propName = propertyNode.propName; - ArrayList<PropertyNode> expectedNodes = - mPropertyNodeMap.get(propName); - if (expectedNodes == null) { - expectedNodes = new ArrayList<PropertyNode>(); - mPropertyNodeMap.put(propName, expectedNodes); - } - expectedNodes.add(propertyNode); - } - } - - public void verify(VNode vnode) { - for (PropertyNode propertyNode : vnode.propList) { - String propName = propertyNode.propName; - ArrayList<PropertyNode> nodes = mPropertyNodeMap.get(propName); - if (nodes == null) { - fail("Unexpected propName \"" + propName + "\" exists."); - } - boolean successful = false; - int size = nodes.size(); - for (int i = 0; i < size; i++) { - PropertyNode expectedNode = nodes.get(i); - if (expectedNode.propName.equals(propName)) { - if (expectedNode.equals(propertyNode)) { - successful = true; - nodes.remove(i); - if (nodes.size() == 0) { - mPropertyNodeMap.remove(propName); - } - break; - } else { - fail("Property \"" + propName + "\" has wrong value.\n" - + "expected: " + expectedNode.toString() - + "\n actual: " + propertyNode.toString()); - } - } - } - if (!successful) { - fail("Unexpected property \"" + propName + "\" exists."); - } - } - if (mPropertyNodeMap.size() != 0) { - ArrayList<String> expectedProps = new ArrayList<String>(); - for (ArrayList<PropertyNode> nodes : mPropertyNodeMap.values()) { - for (PropertyNode node : nodes) { - expectedProps.add(node.propName); - } - } - fail("expected props " + Arrays.toString(expectedProps.toArray()) + - " was not found"); - } - } - } - - /* - public void testV21SimpleCase1_1() throws IOException, VCardException { - VCardParser parser = new VCardParser_V21(); - VCardDataBuilder builder = new VCardDataBuilder(VCardConfig.NAME_ORDER_TYPE_ENGLISH); - EntryHolder holder = new EntryHolder(); - builder.addEntryHandler(holder); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_simple_1); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, holder.contacts.size()); - verify(new ContactStruct("Roid Ando", null, - null, null, null, null, null, null), - holder.contacts.get(0)); - } - - public void testV21SimpleCase1_2() throws IOException, VCardException { - VCardParser parser = new VCardParser_V21(); - VCardDataBuilder builder = new VCardDataBuilder(VCardConfig.NAME_ORDER_TYPE_JAPANESE); - EntryHolder holder = new EntryHolder(); - builder.addEntryHandler(holder); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_simple_1); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, holder.contacts.size()); - verify(new ContactStruct("Ando Roid", null, - null, null, null, null, null, null), - holder.contacts.get(0)); - } - - public void testV21SimpleCase2() throws IOException, VCardException { - VCardParser parser = new VCardParser_V21(); - VCardDataBuilder builder = new VCardDataBuilder(VCardConfig.NAME_ORDER_TYPE_ENGLISH); - EntryHolder holder = new EntryHolder(); - builder.addEntryHandler(holder); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_simple_2); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, holder.contacts.size()); - verify(new ContactStruct("Ando Roid", null, - null, null, null, null, null, null), - holder.contacts.get(0)); - } - - public void testV21SimpleCase3() throws IOException, VCardException { - VCardParser parser = new VCardParser_V21(); - VCardDataBuilder builder1 = new VCardDataBuilder(VCardConfig.NAME_ORDER_TYPE_ENGLISH); - EntryHolder holder = new EntryHolder(); - builder1.addEntryHandler(holder); - VNodeBuilder builder2 = new VNodeBuilder(); - VCardBuilderCollection collection = - new VCardBuilderCollection( - new ArrayList<VCardBuilder>(Arrays.asList(builder1, builder2))); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_simple_3); - assertEquals(true, parser.parse(is,"ISO-8859-1", collection)); - is.close(); - - assertEquals(1, builder2.vNodeList.size()); - VNode vnode = builder2.vNodeList.get(0); - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("N", "Ando;Roid;", - Arrays.asList("Ando", "Roid", ""), - null, null, null, null), - new PropertyNode("FN", "Ando Roid", - null, null, null, null, null)); - verifier.verify(vnode); - - // FN is prefered. - assertEquals(1, holder.contacts.size()); - ContactStruct actual = holder.contacts.get(0); - verify(new ContactStruct("Ando Roid", null, - null, null, null, null, null, null), - actual); - }*/ - - public void testV21BackslashCase() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V21(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_backslash); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, builder.vNodeList.size()); - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", ";A;B\\;C\\;;D;:E;\\\\;", - Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", ""), - null, null, null, null), - new PropertyNode("FN", "A;B\\C\\;D:E\\\\", - null, null, null, null, null)); - verifier.verify(builder.vNodeList.get(0)); - } - - public void testV21ComplicatedCase() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V21(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_complicated); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, builder.vNodeList.size()); - ContentValues contentValuesForQP = new ContentValues(); - contentValuesForQP.put("ENCODING", "QUOTED-PRINTABLE"); - ContentValues contentValuesForPhoto = new ContentValues(); - contentValuesForPhoto.put("ENCODING", "BASE64"); - // Push data into int array at first since values like 0x80 are - // interpreted as int by the compiler and casting all of them is - // cumbersome... - int[] photoIntArray = { - 0xff, 0xd8, 0xff, 0xe1, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x66, 0x00, - 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0d, - 0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0xaa, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0xba, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x00, 0x00, 0xc2, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x28, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x32, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xe6, 0x02, 0x13, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x82, - 0x98, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xfa, - 0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, - 0x84, 0xc4, 0xa5, 0x00, 0x07, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, - 0x01, 0x08, 0x00, 0x00, 0x04, 0x1e, 0x32, 0x30, 0x30, 0x38, 0x31, - 0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31, 0x00, 0x00, - 0x44, 0x6f, 0x43, 0x6f, 0x4d, 0x6f, 0x00, 0x00, 0x44, 0x39, 0x30, - 0x35, 0x69, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x44, 0x39, 0x30, - 0x35, 0x69, 0x20, 0x56, 0x65, 0x72, 0x31, 0x2e, 0x30, 0x30, 0x00, - 0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, - 0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x49, 0x4d, 0x00, 0x30, 0x33, - 0x30, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x14, 0x00, - 0x14, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x34, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x09, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x0f, 0x0b, 0x00, - 0x00, 0x27, 0x10, 0x00, 0x00, 0x05, 0x97, 0x00, 0x00, 0x27, 0x10, - 0x00, 0x00, 0x08, 0xb0, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1c, - 0x01, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x02, 0x5e, 0x00, 0x00, - 0x27, 0x10, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x27, 0x10, 0x00, - 0x00, 0x03, 0xcb, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x1b, 0xe5, - 0x00, 0x00, 0x27, 0x10, 0x00, 0x28, 0x82, 0x9a, 0x00, 0x05, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x6a, 0x82, 0x9d, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x72, 0x88, 0x22, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x90, 0x00, - 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90, - 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03, 0x7a, - 0x90, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x03, - 0x8e, 0x91, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, - 0x03, 0x00, 0x91, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x03, 0xa2, 0x92, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x03, 0xaa, 0x92, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x03, 0xb2, 0x92, 0x04, 0x00, 0x0a, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x03, 0xba, 0x92, 0x05, 0x00, 0x05, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xc2, 0x92, 0x07, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x92, 0x08, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, - 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xca, - 0x92, 0x7c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x92, 0x86, 0x00, 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, - 0x03, 0xd2, 0xa0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x30, - 0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x60, 0x00, 0x00, 0xa0, 0x03, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0xa2, 0x0e, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xe8, 0xa2, 0x0f, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xf0, 0xa2, 0x10, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0xa2, - 0x17, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, - 0xa3, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, - 0x00, 0xa3, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x04, 0x00, 0x05, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x03, 0xf8, 0xa4, 0x05, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x1d, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x07, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, - 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0xa4, 0x0a, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0xa4, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, - 0x00, 0x27, 0x10, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64, - 0x32, 0x30, 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, - 0x31, 0x33, 0x3a, 0x35, 0x35, 0x3a, 0x33, 0x31, 0x00, 0x32, 0x30, - 0x30, 0x38, 0x3a, 0x31, 0x30, 0x3a, 0x32, 0x39, 0x20, 0x31, 0x33, - 0x3a, 0x35, 0x35, 0x3a, 0x34, 0x37, 0x00, 0x00, 0x00, 0x29, 0x88, - 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0xb2, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x25, 0x00, - 0x00, 0x00, 0x0a, 0x00, 0x00, 0x0e, 0x92, 0x00, 0x00, 0x03, 0xe8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x30, 0x30, - 0x38, 0x31, 0x30, 0x32, 0x39, 0x31, 0x33, 0x35, 0x35, 0x33, 0x31, - 0x00, 0x00, 0x20, 0x2a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x2a, - 0xe2, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x52, 0x39, 0x38, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x01, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, - 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x04, 0x6c, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x04, 0x74, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x04, 0x7c, 0x02, 0x02, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x8b, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, - 0x00, 0x20, 0x16, 0x18, 0x1c, 0x18, 0x14, 0x20, 0x1c, 0x1a, 0x1c, - 0x24, 0x22, 0x20, 0x26, 0x30, 0x50, 0x34, 0x30, 0x2c, 0x2c, 0x30, - 0x62, 0x46, 0x4a, 0x3a, 0x50, 0x74, 0x66, 0x7a, 0x78, 0x72, 0x66, - 0x70, 0x6e, 0x80, 0x90, 0xb8, 0x9c, 0x80, 0x88, 0xae, 0x8a, 0x6e, - 0x70, 0xa0, 0xda, 0xa2, 0xae, 0xbe, 0xc4, 0xce, 0xd0, 0xce, 0x7c, - 0x9a, 0xe2, 0xf2, 0xe0, 0xc8, 0xf0, 0xb8, 0xca, 0xce, 0xc6, 0x01, - 0x22, 0x24, 0x24, 0x30, 0x2a, 0x30, 0x5e, 0x34, 0x34, 0x5e, 0xc6, - 0x84, 0x70, 0x84, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xff, 0xc0, - 0x00, 0x11, 0x08, 0x00, 0x78, 0x00, 0xa0, 0x03, 0x01, 0x21, 0x00, - 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00, - 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, - 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, - 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, - 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, - 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, - 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, - 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, - 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00, - 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, - 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, - 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, - 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, - 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, - 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, - 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, - 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, - 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, - 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, - 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, - 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, - 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, - 0x14, 0x54, 0xaa, 0x2a, 0x46, 0x48, 0xa2, 0xa4, 0x55, 0xa6, 0x04, - 0x8a, 0x29, 0xe0, 0x53, 0x10, 0xe0, 0x29, 0xc0, 0x50, 0x03, 0xb1, - 0x46, 0x29, 0x80, 0x84, 0x52, 0x11, 0x40, 0x0d, 0x22, 0x9a, 0x45, - 0x20, 0x23, 0x61, 0x51, 0x30, 0xa0, 0x08, 0xc8, 0xa8, 0xd8, 0x52, - 0x02, 0x26, 0x15, 0x0b, 0x0a, 0x00, 0xb4, 0xa2, 0xa5, 0x5a, 0x00, - 0x91, 0x45, 0x4a, 0xa2, 0x81, 0x92, 0x01, 0x4e, 0x02, 0x98, 0x87, - 0x0a, 0x70, 0xa0, 0x07, 0x62, 0x8c, 0x50, 0x21, 0x0d, 0x25, 0x00, - 0x34, 0x8a, 0x61, 0x14, 0x0c, 0x63, 0x0a, 0x89, 0x85, 0x00, 0x46, - 0xd5, 0x1b, 0x52, 0x02, 0x16, 0xa8, 0x98, 0x50, 0x05, 0x94, 0xa9, - 0x16, 0x80, 0x25, 0x5a, 0x95, 0x68, 0x18, 0xf1, 0x4f, 0x14, 0xc4, - 0x3b, 0xb5, 0x22, 0xb6, 0x38, 0x34, 0x00, 0xe3, 0x22, 0x8e, 0xf4, - 0x79, 0x8a, 0x7b, 0xd1, 0x71, 0x03, 0x30, 0xc7, 0x14, 0x83, 0xa5, - 0x00, 0x06, 0x98, 0x68, 0x01, 0x8d, 0x51, 0x35, 0x03, 0x22, 0x6a, - 0x8d, 0xa9, 0x01, 0x13, 0x54, 0x4d, 0x40, 0x13, 0xa5, 0x4a, 0x28, - 0x02, 0x45, 0x35, 0x2a, 0x9a, 0x00, 0x78, 0x34, 0xf0, 0x69, 0x80, - 0x34, 0x81, 0x45, 0x40, 0xce, 0x58, 0xe6, 0xa2, 0x4c, 0x06, 0xe4, - 0xfa, 0xd1, 0x93, 0x50, 0x21, 0xca, 0xe4, 0x55, 0x84, 0x90, 0x30, - 0xab, 0x8b, 0x18, 0xa6, 0x9a, 0x6a, 0xc4, 0x31, 0xaa, 0x26, 0xa0, - 0x64, 0x4d, 0x51, 0xb5, 0x20, 0x23, 0x6a, 0x89, 0xa8, 0x02, 0x44, - 0x35, 0x2a, 0x9a, 0x00, 0x95, 0x4d, 0x48, 0xa6, 0x80, 0x24, 0x53, - 0x4e, 0xce, 0x05, 0x30, 0x2b, 0x3b, 0xee, 0x6a, 0x91, 0x5d, 0x76, - 0x63, 0xbd, 0x65, 0x7d, 0x40, 0x66, 0x68, 0xa9, 0x02, 0x45, 0x2b, - 0xb3, 0x9e, 0xb4, 0xc5, 0x6d, 0xad, 0x9a, 0xa0, 0x2c, 0x06, 0xc8, - 0xcd, 0x04, 0xd6, 0xa2, 0x23, 0x63, 0x51, 0xb1, 0xa0, 0x64, 0x4d, - 0x51, 0x93, 0x48, 0x08, 0xda, 0xa2, 0x6a, 0x00, 0x72, 0x1a, 0x99, - 0x4d, 0x00, 0x48, 0xa6, 0xa4, 0x53, 0x4c, 0x07, 0x86, 0x03, 0xbd, - 0x2b, 0x9c, 0xa7, 0x14, 0x98, 0x10, 0x85, 0x34, 0xe0, 0xa6, 0xb3, - 0xb0, 0x0b, 0xb5, 0xa8, 0x0a, 0xd4, 0x58, 0x42, 0xed, 0x3e, 0x94, - 0xd2, 0xa6, 0x8b, 0x01, 0x34, 0x44, 0xed, 0xe6, 0x9c, 0x4d, 0x6a, - 0x80, 0x8d, 0x8d, 0x46, 0xc6, 0x80, 0x23, 0x63, 0x51, 0x9a, 0x06, - 0x46, 0xd5, 0x13, 0x52, 0x01, 0x54, 0xd4, 0xaa, 0x68, 0x02, 0x40, - 0x6a, 0x40, 0x78, 0xa0, 0x08, 0x59, 0xce, 0xee, 0xb5, 0x2a, 0x39, - 0xd9, 0x59, 0xa7, 0xa8, 0x00, 0x73, 0xeb, 0x4e, 0x0e, 0x7d, 0x69, - 0x5c, 0x05, 0xf3, 0x0f, 0xad, 0x1e, 0x61, 0xf5, 0xa7, 0x71, 0x0b, - 0xe6, 0x35, 0x21, 0x90, 0xd3, 0xb8, 0x0e, 0x32, 0x10, 0x95, 0x10, - 0x91, 0xb3, 0xd6, 0x9b, 0x60, 0x4b, 0x9c, 0x8a, 0x63, 0x1a, 0xb0, - 0x18, 0x4d, 0x46, 0xc6, 0x80, 0x22, 0x6a, 0x61, 0xa4, 0x31, 0xaa, - 0x6a, 0x55, 0x34, 0x01, 0x2a, 0x9a, 0x7e, 0x78, 0xa0, 0x08, 0x09, - 0xf9, 0xaa, 0x58, 0xcf, 0xca, 0x6b, 0x3e, 0xa0, 0x00, 0xd3, 0x81, - 0xa9, 0x01, 0x73, 0x46, 0x69, 0x80, 0xb9, 0xa4, 0xcd, 0x00, 0x2b, - 0x1f, 0x92, 0xa3, 0x07, 0x9a, 0x6f, 0x70, 0x26, 0xcf, 0x14, 0xd2, - 0x6b, 0x51, 0x0c, 0x63, 0x51, 0xb1, 0xa0, 0x08, 0xda, 0x98, 0x69, - 0x0c, 0x8d, 0x4d, 0x4a, 0xa6, 0x80, 0x24, 0x53, 0x52, 0x03, 0xc5, - 0x02, 0x21, 0x27, 0xe6, 0xa9, 0x23, 0x3f, 0x29, 0xac, 0xfa, 0x8c, - 0x01, 0xe6, 0x9c, 0x0d, 0x48, 0x0a, 0x0d, 0x2e, 0x68, 0x01, 0x73, - 0x49, 0x9a, 0x60, 0x2b, 0x1f, 0x92, 0x98, 0x3a, 0xd3, 0x7b, 0x81, - 0x36, 0x78, 0xa6, 0x93, 0x5a, 0x88, 0x8c, 0x9a, 0x63, 0x1a, 0x00, - 0x8c, 0xd3, 0x0d, 0x21, 0x91, 0x29, 0xa9, 0x14, 0xd0, 0x04, 0x8a, - 0x69, 0xe0, 0xd3, 0x11, 0x1b, 0x1e, 0x6a, 0x48, 0xcf, 0xca, 0x6b, - 0x3e, 0xa3, 0x10, 0x1a, 0x70, 0x35, 0x20, 0x38, 0x1a, 0x5c, 0xd2, - 0x01, 0x73, 0x49, 0x9a, 0x60, 0x39, 0x8f, 0xca, 0x29, 0x8b, 0xf7, - 0xaa, 0xba, 0x88, 0x96, 0x9a, 0x6b, 0x40, 0x18, 0xc6, 0xa3, 0x26, - 0x80, 0x18, 0x69, 0xa6, 0x90, 0xc8, 0x14, 0xd4, 0x8a, 0x69, 0x80, - 0xf0, 0x6a, 0x40, 0x68, 0x10, 0xbb, 0x41, 0xa7, 0xe3, 0x0b, 0xc5, - 0x2b, 0x01, 0x10, 0xa7, 0x03, 0x59, 0x0c, 0x76, 0x69, 0x73, 0x40, - 0x0b, 0x9a, 0x28, 0x11, 0x28, 0x19, 0x5e, 0x69, 0x02, 0x81, 0x5a, - 0xd8, 0x00, 0xd3, 0x4d, 0x50, 0x0c, 0x6a, 0x8c, 0xd2, 0x01, 0xa6, - 0x98, 0x69, 0x0c, 0xae, 0xa6, 0xa4, 0x06, 0x80, 0x1e, 0xa6, 0x9e, - 0x0d, 0x31, 0x12, 0x03, 0x4f, 0x06, 0x80, 0x13, 0x60, 0x34, 0xd3, - 0xc1, 0xa8, 0x92, 0x01, 0xf1, 0x8d, 0xdd, 0x69, 0xcc, 0xa1, 0x69, - 0x5b, 0x4b, 0x80, 0x83, 0x93, 0x52, 0x04, 0x14, 0xe2, 0xae, 0x03, - 0xa9, 0x0d, 0x68, 0x03, 0x4d, 0x34, 0xd0, 0x03, 0x0d, 0x30, 0xd2, - 0x01, 0x86, 0x9a, 0x68, 0x19, 0x58, 0x1a, 0x78, 0xa4, 0x04, 0x8a, - 0x69, 0xe0, 0xd3, 0x10, 0xe0, 0x69, 0xe0, 0xd0, 0x03, 0xc1, 0xa8, - 0xdb, 0xad, 0x4c, 0x81, 0x12, 0x45, 0xd6, 0x9d, 0x25, 0x1d, 0x00, - 0x6a, 0xf5, 0xa9, 0xe8, 0x80, 0x31, 0x29, 0x0d, 0x58, 0x08, 0x69, - 0x86, 0x80, 0x1a, 0x69, 0x86, 0x90, 0x0c, 0x34, 0xd3, 0x48, 0x65, - 0x51, 0x4f, 0x06, 0x98, 0x0f, 0x14, 0xf0, 0x68, 0x10, 0xf0, 0x69, - 0xe0, 0xd0, 0x03, 0x81, 0xa5, 0x2b, 0x9a, 0x1a, 0xb8, 0x87, 0xa8, - 0xdb, 0x4a, 0x46, 0x68, 0xb6, 0x80, 0x2a, 0xa8, 0x14, 0xea, 0x12, - 0xb0, 0x05, 0x21, 0xa6, 0x02, 0x1a, 0x61, 0xa0, 0x06, 0x9a, 0x61, - 0xa4, 0x31, 0x86, 0x9a, 0x69, 0x0c, 0xa8, 0x0d, 0x3c, 0x53, 0x01, - 0xe2, 0x9e, 0x28, 0x10, 0xf1, 0x4e, 0x06, 0x98, 0x0f, 0x06, 0x9e, - 0x0d, 0x02, 0x1c, 0x29, 0xc2, 0x80, 0x16, 0x96, 0x80, 0x0a, 0x4a, - 0x00, 0x43, 0x4d, 0x34, 0x0c, 0x61, 0xa6, 0x1a, 0x40, 0x34, 0xd3, - 0x4d, 0x21, 0x80, 0xff, 0xd9, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0a, - 0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08, 0x08, 0x08, 0x0b, 0x0a, - 0x0a, 0x0b, 0x0e, 0x18, 0x10, 0x0e, 0x0d, 0x0d, 0x0e, 0x1d, 0x15, - 0x16, 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24, 0x22, 0x1f, 0x22, 0x21, - 0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29, 0x34, 0x29, 0x21, 0x22, 0x30, - 0x41, 0x31, 0x34, 0x39, 0x3b, 0x3e, 0x3e, 0x3e, 0x25, 0x2e, 0x44, - 0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e, 0x3b, 0x01, 0x0a, 0x0b, - 0x0b, 0x0e, 0x0d, 0x0e, 0x1c, 0x10, 0x10, 0x1c, 0x3b, 0x28, 0x22, - 0x28, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0xff, 0xc0, 0x00, 0x11, - 0x08, 0x00, 0x48, 0x00, 0x60, 0x03, 0x01, 0x21, 0x00, 0x02, 0x11, - 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, - 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, - 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, - 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, - 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, - 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, - 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, - 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, - 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, - 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, - 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, - 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, - 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, - 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x01, 0x00, 0x03, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, - 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, - 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, - 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, - 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, - 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, - 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, - 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, - 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, - 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, - 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, - 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x9e, 0xd2, - 0x2e, 0x07, 0x15, 0xaf, 0x6d, 0x08, 0xe2, 0xb3, 0x45, 0x1a, 0xf6, - 0xd0, 0x00, 0x01, 0xc5, 0x68, 0x45, 0x17, 0x4a, 0xb4, 0x22, 0xe4, - 0x70, 0x8c, 0x74, 0xa9, 0x3c, 0xa1, 0x8e, 0x95, 0x48, 0x96, 0x31, - 0xe2, 0x18, 0xe9, 0x55, 0xa5, 0x8c, 0x7a, 0x50, 0x05, 0x0b, 0x88, - 0x86, 0x0f, 0x15, 0x8f, 0x75, 0x1f, 0x26, 0x93, 0x19, 0x91, 0x77, - 0x18, 0xc1, 0xac, 0x4b, 0xc8, 0xfa, 0xd6, 0x63, 0x37, 0x6d, 0x31, - 0xb4, 0x73, 0x5b, 0x36, 0xa0, 0x1c, 0x50, 0x80, 0xd7, 0x83, 0xa0, - 0xab, 0xd1, 0x62, 0xad, 0x09, 0x8f, 0x17, 0x29, 0x03, 0xb2, 0xcc, - 0xe0, 0x77, 0x14, 0xa3, 0x56, 0xb3, 0x27, 0x1e, 0x67, 0xe9, 0x52, - 0xea, 0xc6, 0x3a, 0x36, 0x48, 0xef, 0x3d, 0x27, 0x70, 0x22, 0x60, - 0x47, 0x52, 0x69, 0xb2, 0xe2, 0xad, 0x3b, 0xea, 0x80, 0xa3, 0x38, - 0xe0, 0xd6, 0x3d, 0xd8, 0x1c, 0xd0, 0xca, 0x46, 0x3d, 0xd0, 0x18, - 0x35, 0x89, 0x78, 0xa3, 0x9a, 0xcd, 0x8c, 0xd2, 0xb3, 0x93, 0x2a, - 0x2b, 0x66, 0xd5, 0xf1, 0x8a, 0x10, 0x1a, 0xd6, 0xf2, 0x03, 0x8a, - 0x9e, 0xe6, 0xf4, 0x5a, 0xdb, 0xef, 0xfe, 0x23, 0xc0, 0xa7, 0x27, - 0xcb, 0x16, 0xc4, 0xcc, 0xdd, 0xe2, 0x78, 0x9a, 0x69, 0x66, 0xcc, - 0x99, 0xe1, 0x4d, 0x47, 0xba, 0xbc, 0xd9, 0x6a, 0xee, 0x26, 0x59, - 0x59, 0x4d, 0xac, 0x69, 0x34, 0x52, 0xe5, 0x8f, 0x55, 0xad, 0x58, - 0xae, 0x85, 0xc4, 0x22, 0x41, 0xdf, 0xad, 0x76, 0x61, 0xe5, 0x6f, - 0x74, 0x45, 0x69, 0xdc, 0x00, 0x79, 0xac, 0x8b, 0xa6, 0xc9, 0x35, - 0xd4, 0x34, 0x64, 0xdc, 0x37, 0x06, 0xb1, 0xae, 0x88, 0xc1, 0xac, - 0xd8, 0xc9, 0x2c, 0xa6, 0xe0, 0x73, 0x5b, 0x36, 0xf3, 0x74, 0xe6, - 0x84, 0x05, 0xe3, 0xa9, 0x47, 0x6a, 0x14, 0xb6, 0x49, 0x3d, 0x85, - 0x3a, 0xee, 0xee, 0x2b, 0xa8, 0xe2, 0x6f, 0x30, 0x81, 0xe9, 0x8a, - 0xca, 0xa4, 0xe2, 0xd3, 0x8b, 0x01, 0xb1, 0xf9, 0x04, 0x7f, 0xaf, - 0x23, 0xf0, 0xa9, 0x54, 0x41, 0x9c, 0xfd, 0xa3, 0xf4, 0xae, 0x65, - 0x18, 0xf7, 0x25, 0x8a, 0xe2, 0x02, 0x38, 0xb8, 0xfd, 0x2a, 0x7b, - 0x5b, 0xa8, 0x6d, 0x6d, 0x5d, 0x9a, 0x5d, 0xcb, 0xbb, 0xd2, 0xb6, - 0xa6, 0xa3, 0x19, 0x5e, 0xe2, 0x03, 0x7b, 0x1d, 0xc2, 0x17, 0x8d, - 0xb8, 0xac, 0xfb, 0x89, 0x39, 0x35, 0xd6, 0x9a, 0x6a, 0xe8, 0x66, - 0x55, 0xcb, 0xf5, 0xac, 0x7b, 0x96, 0xeb, 0x50, 0xc6, 0x88, 0x6d, - 0x66, 0xe9, 0xcd, 0x6c, 0xdb, 0x4f, 0xd3, 0x9a, 0x00, 0x2f, 0xe6, - 0xf9, 0xa3, 0xe7, 0xb5, 0x4a, 0x93, 0x7f, 0xa2, 0xc6, 0x73, 0xdc, - 0xd7, 0x15, 0x55, 0xef, 0x48, 0x7d, 0x09, 0x52, 0x6e, 0x3a, 0xd4, - 0xab, 0x2f, 0xbd, 0x61, 0x16, 0x0c, 0x73, 0x49, 0xc5, 0x24, 0x92, - 0x7f, 0xa2, 0x63, 0xfd, 0xaa, 0xd6, 0x2f, 0x71, 0x0e, 0xb1, 0x93, - 0xf7, 0x2d, 0xf5, 0xa4, 0x9e, 0x4e, 0xb5, 0xdd, 0x4b, 0xf8, 0x68, - 0x4c, 0xcb, 0xb9, 0x93, 0xad, 0x65, 0xce, 0xd9, 0x26, 0xa9, 0x8d, - 0x19, 0xf6, 0xf2, 0xf4, 0xe6, 0xb5, 0xad, 0xe7, 0xc6, 0x39, 0xa0, - 0x18, 0xeb, 0xc9, 0x77, 0x6c, 0x35, 0x2a, 0x4b, 0xfe, 0x8a, 0x9c, - 0xff, 0x00, 0x11, 0xae, 0x3a, 0x8b, 0xde, 0x61, 0xd0, 0x9e, 0x39, - 0xb8, 0xeb, 0x53, 0xac, 0xb9, 0xae, 0x5b, 0x00, 0xf3, 0x27, 0x14, - 0x92, 0xc9, 0xfe, 0x8a, 0x3f, 0xde, 0x35, 0xac, 0x3a, 0x88, 0x92, - 0xcd, 0xb1, 0x6e, 0x7d, 0xcd, 0x32, 0x67, 0xeb, 0xcd, 0x7a, 0x14, - 0xfe, 0x04, 0x26, 0x66, 0xce, 0xf9, 0x26, 0xb3, 0xe6, 0x6e, 0xb4, - 0xd9, 0x48, 0xc8, 0x82, 0x4e, 0x07, 0x35, 0xa7, 0x6f, 0x2f, 0x02, - 0x9a, 0x06, 0x5f, 0x8c, 0xa4, 0x83, 0x0e, 0x32, 0x2a, 0x69, 0xe3, - 0xdd, 0x12, 0x08, 0x97, 0x85, 0xec, 0x2a, 0x2a, 0x42, 0xf1, 0x76, - 0x26, 0xe4, 0x6a, 0x59, 0x0e, 0x18, 0x10, 0x6a, 0xd2, 0x89, 0x02, - 0x6e, 0x2a, 0x71, 0xeb, 0x5c, 0x1c, 0x8c, 0xa6, 0x48, 0xbb, 0xdc, - 0x61, 0x41, 0x35, 0x72, 0x28, 0x87, 0xd9, 0xf6, 0x4a, 0xb9, 0xe7, - 0x38, 0xae, 0x8c, 0x3d, 0x36, 0xdd, 0xde, 0xc4, 0xb0, 0x21, 0x51, - 0x76, 0xa8, 0xc0, 0xaa, 0x93, 0x31, 0xe6, 0xbb, 0x2d, 0x65, 0x61, - 0x19, 0xd3, 0x1e, 0xb5, 0x46, 0x5a, 0x96, 0x5a, 0x30, 0xa0, 0x7e, - 0x05, 0x69, 0x5b, 0xc9, 0xc6, 0x28, 0x40, 0xcd, 0x08, 0x64, 0x3c, - 0x73, 0x57, 0xe1, 0x94, 0xf1, 0xcd, 0x5a, 0x21, 0x8c, 0xb9, 0x63, - 0xe7, 0x67, 0x1d, 0xab, 0x40, 0xb1, 0xfb, 0x00, 0x1d, 0xf0, 0x2b, - 0x99, 0x2d, 0x66, 0x3e, 0x88, 0x75, 0x81, 0x3f, 0x31, 0xf6, 0xab, - 0x64, 0xd6, 0xb4, 0x17, 0xee, 0xd0, 0x9e, 0xe4, 0x32, 0x1a, 0xa7, - 0x31, 0xad, 0x18, 0x14, 0x26, 0xef, 0x54, 0xa5, 0xa8, 0x65, 0xa3, - 0x9c, 0x81, 0xfa, 0x56, 0x8c, 0x2d, 0xce, 0x68, 0x40, 0xcb, 0xf1, - 0x37, 0xbd, 0x5e, 0x85, 0xea, 0xd1, 0x0c, 0xbb, 0x19, 0x56, 0x23, - 0x20, 0x1f, 0xad, 0x5c, 0x42, 0x08, 0x03, 0xb5, 0x55, 0x91, 0x04, - 0xc9, 0x80, 0x38, 0x00, 0x0a, 0x71, 0x34, 0x6c, 0x32, 0x27, 0xe9, - 0x55, 0x25, 0x15, 0x2c, 0x68, 0xa3, 0x30, 0xeb, 0x54, 0xa5, 0x15, - 0x0c, 0xd1, 0x00, 0xff, 0xd9}; - int length = photoIntArray.length; - byte[] photoByteArray = new byte[length]; - for (int i = 0; i < length; i++) { - photoByteArray[i] = (byte)photoIntArray[i]; - } - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "Gump;Forrest;Hoge;Pos;Tao", - Arrays.asList("Gump", "Forrest", - "Hoge", "Pos", "Tao"), - null, null, null, null), - new PropertyNode("FN", "Joe Due", - null, null, null, null, null), - new PropertyNode("ORG", - "Gump Shrimp Co.;Sales Dept.;Manager;Fish keeper", - Arrays.asList("Gump Shrimp Co.", - "Sales Dept.;Manager", - "Fish keeper"), - null, null, null, null), - new PropertyNode("ROLE", "Fish Cake Keeper!", - null, null, null, null, null), - new PropertyNode("TITLE", "Shrimp Man", - null, null, null, null, null), - new PropertyNode("X-CLASS", "PUBLIC", - null, null, null, null, null), - new PropertyNode("TEL", "(111) 555-1212", - null, null, null, - new HashSet<String>(Arrays.asList("WORK", "VOICE")), null), - new PropertyNode("TEL", "(404) 555-1212", - null, null, null, - new HashSet<String>(Arrays.asList("HOME", "VOICE")), null), - new PropertyNode("TEL", "0311111111", - null, null, null, - new HashSet<String>(Arrays.asList("CELL")), null), - new PropertyNode("TEL", "0322222222", - null, null, null, - new HashSet<String>(Arrays.asList("VIDEO")), null), - new PropertyNode("TEL", "0333333333", - null, null, null, - new HashSet<String>(Arrays.asList("VOICE")), null), - new PropertyNode("ADR", - ";;100 Waters Edge;Baytown;LA;30314;United States of America", - Arrays.asList("", "", "100 Waters Edge", "Baytown", - "LA", "30314", "United States of America"), - null, null, - new HashSet<String>(Arrays.asList("WORK")), null), - new PropertyNode("LABEL", - "100 Waters Edge\r\nBaytown, LA 30314\r\nUnited States of America", - null, null, contentValuesForQP, - new HashSet<String>(Arrays.asList("WORK")), null), - new PropertyNode("ADR", - ";;42 Plantation St.;Baytown;LA;30314;United States of America", - Arrays.asList("", "", "42 Plantation St.", "Baytown", - "LA", "30314", "United States of America"), null, null, - new HashSet<String>(Arrays.asList("HOME")), null), - new PropertyNode("LABEL", - "42 Plantation St.\r\nBaytown, LA 30314\r\nUnited States of America", - null, null, contentValuesForQP, - new HashSet<String>(Arrays.asList("HOME")), null), - new PropertyNode("EMAIL", "forrestgump@walladalla.com", - null, null, null, - new HashSet<String>(Arrays.asList("PREF", "INTERNET")), null), - new PropertyNode("EMAIL", "cell@example.com", - null, null, null, - new HashSet<String>(Arrays.asList("CELL")), null), - new PropertyNode("NOTE", "The following note is the example from RFC 2045.", - null, null, null, null, null), - new PropertyNode("NOTE", - "Now's the time for all folk to come to the aid of their country.", - null, null, contentValuesForQP, null, null), - new PropertyNode("PHOTO", null, - null, photoByteArray, contentValuesForPhoto, - new HashSet<String>(Arrays.asList("JPEG")), null), - new PropertyNode("X-ATTRIBUTE", "Some String", - null, null, null, null, null), - new PropertyNode("BDAY", "19800101", - null, null, null, null, null), - new PropertyNode("GEO", "35.6563854,139.6994233", - null, null, null, null, null), - new PropertyNode("URL", "http://www.example.com/", - null, null, null, null, null), - new PropertyNode("REV", "20080424T195243Z", - null, null, null, null, null)); - verifier.verify(builder.vNodeList.get(0)); - } - - public void testV21Japanese1() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V21(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_japanese_1); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, builder.vNodeList.size()); - ContentValues contentValuesForShiftJis = new ContentValues(); - contentValuesForShiftJis.put("CHARSET", "SHIFT_JIS"); - ContentValues contentValuesForQP = new ContentValues(); - contentValuesForQP.put("ENCODING", "QUOTED-PRINTABLE"); - contentValuesForQP.put("CHARSET", "SHIFT_JIS"); - // Though Japanese careers append ";;;;" at the end of the value of "SOUND", - // vCard 2.1/3.0 specification does not allow multiple values. - // Do not need to handle it as multiple values. - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "\u5B89\u85E4\u30ED\u30A4\u30C9;;;;", - Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9", "", "", "", ""), - null, contentValuesForShiftJis, null, null), - new PropertyNode("SOUND", - "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E;;;;", - null, null, contentValuesForShiftJis, - new HashSet<String>(Arrays.asList("X-IRMC-N")), null), - new PropertyNode("TEL", "0300000000", - null, null, null, - new HashSet<String>(Arrays.asList("VOICE", "PREF")), null)); - verifier.verify(builder.vNodeList.get(0)); - } - - public void testV21Japanese2() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V21(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_japanese_2); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, builder.vNodeList.size()); - ContentValues contentValuesForShiftJis = new ContentValues(); - contentValuesForShiftJis.put("CHARSET", "SHIFT_JIS"); - ContentValues contentValuesForQP = new ContentValues(); - contentValuesForQP.put("ENCODING", "QUOTED-PRINTABLE"); - contentValuesForQP.put("CHARSET", "SHIFT_JIS"); - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "\u5B89\u85E4;\u30ED\u30A4\u30C9\u0031;;;", - Arrays.asList("\u5B89\u85E4", "\u30ED\u30A4\u30C9\u0031", - "", "", ""), - null, contentValuesForShiftJis, null, null), - new PropertyNode("FN", - "\u5B89\u85E4\u0020\u30ED\u30A4\u30C9\u0020\u0031", - null, null, contentValuesForShiftJis, null, null), - new PropertyNode("SOUND", - ("\uFF71\uFF9D\uFF84\uFF9E\uFF73" + - ";\uFF9B\uFF72\uFF84\uFF9E\u0031;;;"), - null, null, contentValuesForShiftJis, - new HashSet<String>(Arrays.asList("X-IRMC-N")), null), - new PropertyNode("ADR", - (";\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + - "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + - "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC\u0036" + - "\u968E;;;;150-8512;"), - Arrays.asList("", - "\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\u685C" + - "\u4E18\u753A\u0032\u0036\u002D\u0031\u30BB" + - "\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC" + - "\u0036\u968E", "", "", "", "150-8512", ""), - null, contentValuesForQP, - new HashSet<String>(Arrays.asList("HOME")), null), - new PropertyNode("NOTE", "\u30E1\u30E2", - null, null, contentValuesForQP, null, null)); - verifier.verify(builder.vNodeList.get(0)); - } - - public void testV21MultipleEntryCase() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V21(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v21_multiple_entry); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(3, builder.vNodeList.size()); - ContentValues contentValuesForShiftJis = new ContentValues(); - contentValuesForShiftJis.put("CHARSET", "SHIFT_JIS"); - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0033;;;;", - Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0033", "", "", "", ""), - null, contentValuesForShiftJis, null, null), - new PropertyNode("SOUND", - "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0033;;;;", - null, null, contentValuesForShiftJis, - new HashSet<String>(Arrays.asList("X-IRMC-N")), null), - new PropertyNode("TEL", "9", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-SECRET")), null), - new PropertyNode("TEL", "10", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-HOTEL")), null), - new PropertyNode("TEL", "11", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-SCHOOL")), null), - new PropertyNode("TEL", "12", - null, null, null, - new HashSet<String>(Arrays.asList("FAX", "HOME")), null)); - verifier.verify(builder.vNodeList.get(0)); - - verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0034;;;;", - Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0034", "", "", "", ""), - null, contentValuesForShiftJis, null, null), - new PropertyNode("SOUND", - "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0034;;;;", - null, null, contentValuesForShiftJis, - new HashSet<String>(Arrays.asList("X-IRMC-N")), null), - new PropertyNode("TEL", "13", - null, null, null, - new HashSet<String>(Arrays.asList("MODEM")), null), - new PropertyNode("TEL", "14", - null, null, null, - new HashSet<String>(Arrays.asList("PAGER")), null), - new PropertyNode("TEL", "15", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-FAMILY")), null), - new PropertyNode("TEL", "16", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-GIRL")), null)); - verifier.verify(builder.vNodeList.get(1)); - verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "2.1", - null, null, null, null, null), - new PropertyNode("N", "\u5B89\u85E4\u30ED\u30A4\u30C9\u0035;;;;", - Arrays.asList("\u5B89\u85E4\u30ED\u30A4\u30C9\u0035", "", "", "", ""), - null, contentValuesForShiftJis, null, null), - new PropertyNode("SOUND", - "\uFF71\uFF9D\uFF84\uFF9E\uFF73\uFF9B\uFF72\uFF84\uFF9E\u0035;;;;", - null, null, contentValuesForShiftJis, - new HashSet<String>(Arrays.asList("X-IRMC-N")), null), - new PropertyNode("TEL", "17", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-BOY")), null), - new PropertyNode("TEL", "18", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-FRIEND")), null), - new PropertyNode("TEL", "19", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-PHS")), null), - new PropertyNode("TEL", "20", - null, null, null, - new HashSet<String>(Arrays.asList("X-NEC-RESTAURANT")), null)); - verifier.verify(builder.vNodeList.get(2)); - } - - public void testV30SimpleCase() throws IOException, VCardException { - VCardParser_V21 parser = new VCardParser_V30(); - VNodeBuilder builder = new VNodeBuilder(); - InputStream is = getContext().getResources().openRawResource(R.raw.v30_simple); - assertEquals(true, parser.parse(is,"ISO-8859-1", builder)); - is.close(); - assertEquals(1, builder.vNodeList.size()); - PropertyNodesVerifier verifier = new PropertyNodesVerifier( - new PropertyNode("VERSION", "3.0", - null, null, null, null, null), - new PropertyNode("FN", "And Roid", - null, null, null, null, null), - new PropertyNode("N", "And;Roid;;;", - Arrays.asList("And", "Roid", "", "", ""), - null, null, null, null), - new PropertyNode("ORG", "Open;Handset; Alliance", - Arrays.asList("Open", "Handset", " Alliance"), - null, null, null, null), - new PropertyNode("SORT-STRING", "android", null, null, null, null, null), - new PropertyNode("TEL", "0300000000", - null, null, null, - new HashSet<String>(Arrays.asList("PREF", "VOICE")), null), - new PropertyNode("CLASS", "PUBLIC", null, null, null, null, null), - new PropertyNode("X-GNO", "0", null, null, null, null, null), - new PropertyNode("X-GN", "group0", null, null, null, null, null), - new PropertyNode("X-REDUCTION", "0", - null, null, null, null, null), - new PropertyNode("REV", "20081031T065854Z", - null, null, null, null, null)); - verifier.verify(builder.vNodeList.get(0)); - } -} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTestsBase.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTestsBase.java new file mode 100644 index 0000000..2382b42 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardTestsBase.java @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.vcard; + +import android.content.ContentProvider; +import android.content.ContentProviderOperation; +import android.content.ContentProviderResult; +import android.content.ContentValues; +import android.content.EntityIterator; +import android.content.res.AssetFileDescriptor; +import android.database.Cursor; +import android.database.CursorWindow; +import android.database.IBulkCursor; +import android.database.IContentObserver; +import android.net.Uri; +import android.os.IBinder; +import android.os.ParcelFileDescriptor; +import android.os.RemoteException; +import android.pim.vcard.VCardConfig; +import android.test.AndroidTestCase; +import android.util.Log; + +import java.util.ArrayList; + +/** + * Almost a dead copy of android.test.mock.MockContentProvider, but different in that this + * class extends ContentProvider, not implementing IContentProvider, + * so that MockContentResolver is able to accept this class :( + */ +class MockContentProvider extends ContentProvider { + @Override + public boolean onCreate() { + return true; + } + + @Override + public int bulkInsert(Uri url, ContentValues[] initialValues) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @SuppressWarnings("unused") + public IBulkCursor bulkQuery(Uri url, String[] projection, String selection, + String[] selectionArgs, String sortOrder, IContentObserver observer, + CursorWindow window) throws RemoteException { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + @SuppressWarnings("unused") + public int delete(Uri url, String selection, String[] selectionArgs) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public String getType(Uri url) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public Uri insert(Uri url, ContentValues initialValues) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public ParcelFileDescriptor openFile(Uri url, String mode) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public AssetFileDescriptor openAssetFile(Uri uri, String mode) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, + String sortOrder) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + @Override + public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) { + throw new UnsupportedOperationException("unimplemented mock method"); + } + + public IBinder asBinder() { + throw new UnsupportedOperationException("unimplemented mock method"); + } +} + +/** + * BaseClass for vCard unit tests with utility classes. + * Please do not add each unit test here. + */ +/* package */ class VCardTestsBase extends AndroidTestCase { + public static final int V21 = VCardConfig.VCARD_TYPE_V21_GENERIC_UTF8; + public static final int V30 = VCardConfig.VCARD_TYPE_V30_GENERIC_UTF8; + + // Do not modify these during tests. + protected final ContentValues mContentValuesForQP; + protected final ContentValues mContentValuesForSJis; + protected final ContentValues mContentValuesForUtf8; + protected final ContentValues mContentValuesForQPAndSJis; + protected final ContentValues mContentValuesForQPAndUtf8; + protected final ContentValues mContentValuesForBase64V21; + protected final ContentValues mContentValuesForBase64V30; + + protected VCardVerifier mVerifier; + private boolean mSkipVerification; + + public VCardTestsBase() { + super(); + mContentValuesForQP = new ContentValues(); + mContentValuesForQP.put("ENCODING", "QUOTED-PRINTABLE"); + mContentValuesForSJis = new ContentValues(); + mContentValuesForSJis.put("CHARSET", "SHIFT_JIS"); + mContentValuesForUtf8 = new ContentValues(); + mContentValuesForUtf8.put("CHARSET", "UTF-8"); + mContentValuesForQPAndSJis = new ContentValues(); + mContentValuesForQPAndSJis.put("ENCODING", "QUOTED-PRINTABLE"); + mContentValuesForQPAndSJis.put("CHARSET", "SHIFT_JIS"); + mContentValuesForQPAndUtf8 = new ContentValues(); + mContentValuesForQPAndUtf8.put("ENCODING", "QUOTED-PRINTABLE"); + mContentValuesForQPAndUtf8.put("CHARSET", "UTF-8"); + mContentValuesForBase64V21 = new ContentValues(); + mContentValuesForBase64V21.put("ENCODING", "BASE64"); + mContentValuesForBase64V30 = new ContentValues(); + mContentValuesForBase64V30.put("ENCODING", "b"); + } + + @Override + public void testAndroidTestCaseSetupProperly() { + super.testAndroidTestCaseSetupProperly(); + mSkipVerification = true; + } + + @Override + public void setUp() throws Exception{ + super.setUp(); + mVerifier = new VCardVerifier(this); + mSkipVerification = false; + } + + @Override + public void tearDown() throws Exception { + super.tearDown(); + if (!mSkipVerification) { + mVerifier.verify(); + } + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java new file mode 100644 index 0000000..9f173af --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardUtilsTests.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.unit_tests.vcard; + +import android.pim.vcard.VCardUtils; + +import junit.framework.TestCase; + +import java.util.List; + +public class VCardUtilsTests extends TestCase { + public void testContainsOnlyPrintableAscii() { + assertTrue(VCardUtils.containsOnlyPrintableAscii((String)null)); + assertTrue(VCardUtils.containsOnlyPrintableAscii((String[])null)); + assertTrue(VCardUtils.containsOnlyPrintableAscii((List<String>)null)); + assertTrue(VCardUtils.containsOnlyPrintableAscii("")); + assertTrue(VCardUtils.containsOnlyPrintableAscii("abcdefghijklmnopqrstuvwxyz")); + assertTrue(VCardUtils.containsOnlyPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); + StringBuilder builder = new StringBuilder(); + for (int i = 0x20; i < 0x7F; i++) { + builder.append((char)i); + } + assertTrue(VCardUtils.containsOnlyPrintableAscii(builder.toString())); + assertTrue(VCardUtils.containsOnlyPrintableAscii("\r\n")); + assertFalse(VCardUtils.containsOnlyPrintableAscii("\u0019")); + assertFalse(VCardUtils.containsOnlyPrintableAscii("\u007F")); + } + + public void testContainsOnlyNonCrLfPrintableAscii() { + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii((String)null)); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii((String[])null)); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii((List<String>)null)); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("")); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("abcdefghijklmnopqrstuvwxyz")); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); + StringBuilder builder = new StringBuilder(); + for (int i = 0x20; i < 0x7F; i++) { + builder.append((char)i); + } + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii(builder.toString())); + assertFalse(VCardUtils.containsOnlyNonCrLfPrintableAscii("\u0019")); + assertFalse(VCardUtils.containsOnlyNonCrLfPrintableAscii("\u007F")); + assertFalse(VCardUtils.containsOnlyNonCrLfPrintableAscii("\r")); + assertFalse(VCardUtils.containsOnlyNonCrLfPrintableAscii("\n")); + } + + public void testContainsOnlyAlphaDigitHyphen() { + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen((String)null)); + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen((String[])null)); + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen((List<String>)null)); + assertTrue(VCardUtils.containsOnlyAlphaDigitHyphen("")); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("abcdefghijklmnopqrstuvwxyz")); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); + assertTrue(VCardUtils.containsOnlyNonCrLfPrintableAscii("0123456789-")); + for (int i = 0; i < 0x30; i++) { + if (i == 0x2D) { // - + continue; + } + assertFalse(VCardUtils.containsOnlyAlphaDigitHyphen(String.valueOf((char)i))); + } + for (int i = 0x3A; i < 0x41; i++) { + assertFalse(VCardUtils.containsOnlyAlphaDigitHyphen(String.valueOf((char)i))); + } + for (int i = 0x5B; i < 0x61; i++) { + assertFalse(VCardUtils.containsOnlyAlphaDigitHyphen(String.valueOf((char)i))); + } + for (int i = 0x7B; i < 0x100; i++) { + assertFalse(VCardUtils.containsOnlyAlphaDigitHyphen(String.valueOf((char)i))); + } + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardVerifier.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardVerifier.java new file mode 100644 index 0000000..4b97750 --- /dev/null +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VCardVerifier.java @@ -0,0 +1,306 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.android.unit_tests.vcard; + +import android.content.ContentProvider; +import android.content.ContentResolver; +import android.content.Context; +import android.content.EntityIterator; +import android.net.Uri; +import android.pim.vcard.VCardComposer; +import android.pim.vcard.VCardConfig; +import android.pim.vcard.VCardEntryConstructor; +import android.pim.vcard.VCardInterpreter; +import android.pim.vcard.VCardInterpreterCollection; +import android.pim.vcard.VCardParser; +import android.pim.vcard.VCardParser_V21; +import android.pim.vcard.VCardParser_V30; +import android.pim.vcard.exception.VCardException; +import android.test.AndroidTestCase; +import android.test.mock.MockContext; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.Arrays; + +/* package */ class CustomMockContext extends MockContext { + final ContentResolver mResolver; + public CustomMockContext(ContentResolver resolver) { + mResolver = resolver; + } + + @Override + public ContentResolver getContentResolver() { + return mResolver; + } +} + +/* package */ class VCardVerifier { + private class VCardVerifierInternal implements VCardComposer.OneEntryHandler { + public boolean onInit(Context context) { + return true; + } + public boolean onEntryCreated(String vcard) { + verifyOneVCard(vcard); + return true; + } + public void onTerminate() { + } + } + + private final AndroidTestCase mTestCase; + private final VCardVerifierInternal mVCardVerifierInternal; + private int mVCardType; + private boolean mIsV30; + private boolean mIsDoCoMo; + + // Only one of them must be non-empty. + private ExportTestResolver mExportTestResolver; + private InputStream mInputStream; + + // To allow duplication, use list instead of set. + // When null, we don't need to do the verification. + private PropertyNodesVerifier mPropertyNodesVerifier; + private LineVerifier mLineVerifier; + private ContentValuesVerifier mContentValuesVerifier; + private boolean mInitialized; + private boolean mVerified = false; + + public VCardVerifier(AndroidTestCase androidTestCase) { + mTestCase = androidTestCase; + mVCardVerifierInternal = new VCardVerifierInternal(); + mExportTestResolver = null; + mInputStream = null; + mInitialized = false; + mVerified = false; + } + + public void initForExportTest(int vcardType) { + if (mInitialized) { + mTestCase.fail("Already initialized"); + } + mExportTestResolver = new ExportTestResolver(mTestCase); + mVCardType = vcardType; + mIsV30 = VCardConfig.isV30(vcardType); + mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); + mInitialized = true; + } + + public void initForImportTest(int vcardType, int resId) { + if (mInitialized) { + mTestCase.fail("Already initialized"); + } + mVCardType = vcardType; + mIsV30 = VCardConfig.isV30(vcardType); + mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); + setInputResourceId(resId); + mInitialized = true; + } + + private void setInputResourceId(int resId) { + InputStream inputStream = mTestCase.getContext().getResources().openRawResource(resId); + if (inputStream == null) { + mTestCase.fail("Wrong resId: " + resId); + } + setInputStream(inputStream); + } + + private void setInputStream(InputStream inputStream) { + if (mExportTestResolver != null) { + mTestCase.fail("addInputEntry() is called."); + } else if (mInputStream != null) { + mTestCase.fail("InputStream is already set"); + } + mInputStream = inputStream; + } + + public ContactEntry addInputEntry() { + if (!mInitialized) { + mTestCase.fail("Not initialized"); + } + if (mInputStream != null) { + mTestCase.fail("setInputStream is called"); + } + return mExportTestResolver.addInputContactEntry(); + } + + public PropertyNodesVerifierElem addPropertyNodesVerifierElem() { + if (!mInitialized) { + mTestCase.fail("Not initialized"); + } + if (mPropertyNodesVerifier == null) { + mPropertyNodesVerifier = new PropertyNodesVerifier(mTestCase); + } + PropertyNodesVerifierElem elem = + mPropertyNodesVerifier.addPropertyNodesVerifierElem(); + elem.addExpectedNodeWithOrder("VERSION", (mIsV30 ? "3.0" : "2.1")); + + return elem; + } + + public PropertyNodesVerifierElem addPropertyNodesVerifierElemWithEmptyName() { + if (!mInitialized) { + mTestCase.fail("Not initialized"); + } + PropertyNodesVerifierElem elem = addPropertyNodesVerifierElem(); + if (mIsV30) { + elem.addExpectedNodeWithOrder("N", "").addExpectedNodeWithOrder("FN", ""); + } else if (mIsDoCoMo) { + elem.addExpectedNodeWithOrder("N", ""); + } + return elem; + } + + public LineVerifierElem addLineVerifierElem() { + if (!mInitialized) { + mTestCase.fail("Not initialized"); + } + if (mLineVerifier == null) { + mLineVerifier = new LineVerifier(mTestCase, mVCardType); + } + return mLineVerifier.addLineVerifierElem(); + } + + public ContentValuesVerifierElem addContentValuesVerifierElem() { + if (!mInitialized) { + mTestCase.fail("Not initialized"); + } + if (mContentValuesVerifier == null) { + mContentValuesVerifier = new ContentValuesVerifier(); + } + + return mContentValuesVerifier.addElem(mTestCase); + } + + private void verifyOneVCard(final String vcard) { + // Log.d("@@@", vcard); + final VCardInterpreter builder; + if (mContentValuesVerifier != null) { + final VNodeBuilder vnodeBuilder = mPropertyNodesVerifier; + final VCardEntryConstructor vcardDataBuilder = + new VCardEntryConstructor(mVCardType); + vcardDataBuilder.addEntryHandler(mContentValuesVerifier); + if (mPropertyNodesVerifier != null) { + builder = new VCardInterpreterCollection(Arrays.asList( + mPropertyNodesVerifier, vcardDataBuilder)); + } else { + builder = vnodeBuilder; + } + } else { + if (mPropertyNodesVerifier != null) { + builder = mPropertyNodesVerifier; + } else { + return; + } + } + + final VCardParser parser = + (mIsV30 ? new VCardParser_V30(true) : new VCardParser_V21()); + InputStream is = null; + try { + String charset = + (VCardConfig.usesShiftJis(mVCardType) ? "SHIFT_JIS" : "UTF-8"); + is = new ByteArrayInputStream(vcard.getBytes(charset)); + mTestCase.assertEquals(true, parser.parse(is, null, builder)); + } catch (IOException e) { + mTestCase.fail("Unexpected IOException: " + e.getMessage()); + } catch (VCardException e) { + mTestCase.fail("Unexpected VCardException: " + e.getMessage()); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + } + } + + public void verify() { + if (!mInitialized) { + mTestCase.fail("Not initialized."); + } + if (mVerified) { + mTestCase.fail("verify() was called twice."); + } + if (mInputStream != null) { + try { + verifyForImportTest(); + } catch (IOException e) { + mTestCase.fail("IOException was thrown: " + e.getMessage()); + } catch (VCardException e) { + mTestCase.fail("VCardException was thrown: " + e.getMessage()); + } + } else if (mExportTestResolver != null){ + verifyForExportTest(); + } else { + mTestCase.fail("No input is determined"); + } + mVerified = true; + } + + private void verifyForImportTest() throws IOException, VCardException { + if (mLineVerifier != null) { + mTestCase.fail("Not supported now."); + } + if (mContentValuesVerifier != null) { + mContentValuesVerifier.verify(mInputStream, mVCardType); + } + } + + public static EntityIterator mockGetEntityIteratorMethod( + final ContentResolver resolver, + final Uri uri, final String selection, + final String[] selectionArgs, final String sortOrder) { + final ContentProvider provider = + resolver.acquireContentProviderClient(uri).getLocalContentProvider(); + return ((ExportTestProvider)provider).queryEntities( + uri, selection, selectionArgs, sortOrder); + } + + private Method getMockGetEntityIteratorMethod() + throws SecurityException, NoSuchMethodException { + return this.getClass().getMethod("mockGetEntityIteratorMethod", + ContentResolver.class, Uri.class, String.class, String[].class, String.class); + } + + private void verifyForExportTest() { + final VCardComposer composer = + new VCardComposer(new CustomMockContext(mExportTestResolver), mVCardType); + composer.addHandler(mLineVerifier); + composer.addHandler(mVCardVerifierInternal); + if (!composer.init(VCardComposer.CONTACTS_TEST_CONTENT_URI, null, null, null)) { + mTestCase.fail("init() failed. Reason: " + composer.getErrorReason()); + } + mTestCase.assertFalse(composer.isAfterLast()); + try { + while (!composer.isAfterLast()) { + try { + final Method mockGetEntityIteratorMethod = getMockGetEntityIteratorMethod(); + mTestCase.assertTrue( + composer.createOneEntry(getMockGetEntityIteratorMethod())); + } catch (Exception e) { + e.printStackTrace(); + mTestCase.fail(); + } + } + } finally { + composer.terminate(); + } + } +} diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VNode.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VNode.java index 3eb827b..7587320 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VNode.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VNode.java @@ -18,7 +18,7 @@ package com.android.unit_tests.vcard; import java.util.ArrayList; /** - * @hide old class. Just for testing + * Previously used in main vCard handling code but now exists only for testing. */ public class VNode { public String VName; diff --git a/tests/AndroidTests/src/com/android/unit_tests/vcard/VNodeBuilder.java b/tests/AndroidTests/src/com/android/unit_tests/vcard/VNodeBuilder.java index 6d69223..971fe0d 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/vcard/VNodeBuilder.java +++ b/tests/AndroidTests/src/com/android/unit_tests/vcard/VNodeBuilder.java @@ -16,7 +16,7 @@ package com.android.unit_tests.vcard; import android.content.ContentValues; -import android.pim.vcard.VCardBuilder; +import android.pim.vcard.VCardInterpreter; import android.pim.vcard.VCardConfig; import android.util.CharsetUtils; import android.util.Log; @@ -36,10 +36,11 @@ import java.util.List; * Maybe several vcard instance, so use vNodeList to store. * VNode: standy by a vcard instance. * PropertyNode: standy by a property line of a card. - * @hide old class, just for testing use + * + * Previously used in main vCard handling code but now exists only for testing. */ -public class VNodeBuilder implements VCardBuilder { - static private String LOG_TAG = "VDATABuilder"; +public class VNodeBuilder implements VCardInterpreter { + static private String LOG_TAG = "VNodeBuilder"; /** * If there's no other information available, this class uses this charset for encoding @@ -114,11 +115,10 @@ public class VNodeBuilder implements VCardBuilder { // I leave this code as is since I'm not familiar with vcalendar specification. // But I believe we should refactor this code in the future. // Until this, the last entry has to be removed when some error occurs. - public void startRecord(String type) { - + public void startEntry() { VNode vnode = new VNode(); vnode.parseStatus = 1; - vnode.VName = type; + vnode.VName = "VCARD"; // I feel this should be done in endRecord(), but it cannot be done because of // the reason above. vNodeList.add(vnode); @@ -126,7 +126,7 @@ public class VNodeBuilder implements VCardBuilder { mCurrentVNode = vNodeList.get(mNodeListPos); } - public void endRecord() { + public void endEntry() { VNode endNode = vNodeList.get(mNodeListPos); endNode.parseStatus = 0; while(mNodeListPos > 0){ @@ -189,6 +189,7 @@ public class VNodeBuilder implements VCardBuilder { private String handleOneValue(String value, String targetCharset, String encoding) { if (encoding != null) { + encoding = encoding.toUpperCase(); if (encoding.equals("BASE64") || encoding.equals("B")) { // Assume BASE64 is used only when the number of values is 1. mCurrentPropNode.propValue_bytes = diff --git a/tests/BatteryWaster/res/layout/battery_waster.xml b/tests/BatteryWaster/res/layout/battery_waster.xml index b6eab03..e1cb6bf 100644 --- a/tests/BatteryWaster/res/layout/battery_waster.xml +++ b/tests/BatteryWaster/res/layout/battery_waster.xml @@ -15,13 +15,13 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical" > <CheckBox android:id="@+id/checkbox" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="25dp" android:layout_marginTop="25dp" @@ -31,12 +31,12 @@ /> <ScrollView android:id="@+id/scroll" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" > <TextView android:id="@+id/log" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="25dp" android:textSize="12sp" diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java index 77e390b..e750ac8 100644 --- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java +++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java @@ -65,8 +65,8 @@ public class PowerTestActivity extends Activity { webView.setWebChromeClient(chromeClient); contentView.addView(webView, new LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT, 0.0f)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 0.0f)); handler = new Handler() { @Override diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp index 706c27e..2eff394 100644 --- a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp +++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp @@ -46,7 +46,7 @@ EventPlugin::~EventPlugin() { } void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) { - gLogI.log(inst(), kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)", + gLogI.log(kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)", inst(), bitmap.width, bitmap.height); // get the plugin's dimensions according to the DOM @@ -60,7 +60,7 @@ void EventPlugin::drawPlugin(const ANPBitmap& bitmap, const ANPRectI& clip) { // check to make sure the zoom level is uniform if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH) - gLogI.log(inst(), kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)", + gLogI.log(kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)", inst(), zoomFactorW, zoomFactorH); // scale the variables based on the zoom level @@ -109,7 +109,7 @@ void EventPlugin::printToDiv(const char* text, int length) { browser->getvalue(inst(), NPNVWindowNPObject, &windowObject); if (!windowObject) - gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to retrieve DOM Window", inst()); + gLogI.log(kError_ANPLogType, " ------ %p Unable to retrieve DOM Window", inst()); // create a string (JS code) that is stored in memory allocated by the browser const char* jsBegin = "var outputDiv = document.getElementById('eventOutput'); outputDiv.innerHTML += ' "; @@ -126,13 +126,13 @@ void EventPlugin::printToDiv(const char* text, int length) { memcpy(middleMem, text, length); memcpy(endMem, jsEnd, strlen(jsEnd)); - gLogI.log(inst(), kError_ANPLogType, "text: %.*s\n", totalLength, (char*)beginMem); + gLogI.log(kDebug_ANPLogType, "text: %.*s\n", totalLength, (char*)beginMem); // execute the javascript in the plugin's DOM object NPString script = { (char*)beginMem, totalLength }; NPVariant scriptVariant; if (!browser->evaluate(inst(), windowObject, &script, &scriptVariant)) - gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to eval the JS.", inst()); + gLogI.log(kError_ANPLogType, " ------ %p Unable to eval the JS.", inst()); // free the memory allocated within the browser browser->memfree(beginMem); @@ -170,10 +170,10 @@ int16 EventPlugin::handleEvent(const ANPEvent* evt) { } return 1; case kTouch_ANPEventType: - gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request touch events", inst()); + gLogI.log(kError_ANPLogType, " ------ %p the plugin did not request touch events", inst()); break; case kKey_ANPEventType: - gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request key events", inst()); + gLogI.log(kError_ANPLogType, " ------ %p the plugin did not request key events", inst()); break; default: break; diff --git a/tests/BrowserTestPlugin/jni/main.cpp b/tests/BrowserTestPlugin/jni/main.cpp index e3ad4a7..87ddbc4 100644 --- a/tests/BrowserTestPlugin/jni/main.cpp +++ b/tests/BrowserTestPlugin/jni/main.cpp @@ -53,7 +53,7 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); extern "C" { -EXPORT NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context); +EXPORT NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env); EXPORT NPError NP_GetValue(NPP instance, NPPVariable variable, void *value); EXPORT const char* NP_GetMIMEDescription(void); EXPORT void NP_Shutdown(void); @@ -65,13 +65,12 @@ ANPCanvasInterfaceV0 gCanvasI; ANPLogInterfaceV0 gLogI; ANPPaintInterfaceV0 gPaintI; ANPPathInterfaceV0 gPathI; -ANPSystemInterfaceV0 gSystemI; ANPTypefaceInterfaceV0 gTypefaceI; ANPWindowInterfaceV0 gWindowI; #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) -NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context) +NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env) { // Make sure we have a function table equal or larger than we are built against. if (browserFuncs->size < sizeof(NPNetscapeFuncs)) { @@ -135,7 +134,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, { - gLogI.log(instance, kDebug_ANPLogType, "creating plugin"); + gLogI.log(kDebug_ANPLogType, "creating plugin"); PluginObject *obj = NULL; @@ -156,7 +155,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue, reinterpret_cast<void*>(model)); if (err) { - gLogI.log(instance, kError_ANPLogType, "request model %d err %d", model, err); + gLogI.log(kError_ANPLogType, "request model %d err %d", model, err); return err; } @@ -169,7 +168,10 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, NPError NPP_Destroy(NPP instance, NPSavedData** save) { PluginObject *obj = (PluginObject*) instance->pdata; - delete obj->subPlugin; + if (obj) { + delete obj->subPlugin; + browser->releaseobject(&obj->header); + } return NPERR_NO_ERROR; } @@ -221,7 +223,7 @@ int16 NPP_HandleEvent(NPP instance, void* event) const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event); if(!obj->subPlugin) { - gLogI.log(instance, kError_ANPLogType, "the sub-plugin is null."); + gLogI.log(kError_ANPLogType, "the sub-plugin is null."); return 0; // unknown or unhandled event } else { diff --git a/tests/CoreTests/android/core/CoreTests.java b/tests/CoreTests/android/core/CoreTests.java index e4f835c..442fe0f 100644 --- a/tests/CoreTests/android/core/CoreTests.java +++ b/tests/CoreTests/android/core/CoreTests.java @@ -59,7 +59,6 @@ public class CoreTests extends TestSuite { suite.addTestSuite(LocationManagerProximityTest.class); suite.addTestSuite(AndroidTestRunnerTest.class); suite.addTestSuite(InstrumentationTestRunnerTest.class); - suite.addTestSuite(CookieTest.class); return suite; } diff --git a/tests/CoreTests/android/core/DatabaseSessionCache.java b/tests/CoreTests/android/core/DatabaseSessionCache.java index c344d9c..040a13e 100644 --- a/tests/CoreTests/android/core/DatabaseSessionCache.java +++ b/tests/CoreTests/android/core/DatabaseSessionCache.java @@ -136,8 +136,8 @@ public class DatabaseSessionCache implements SSLClientSessionCache { } // public static boolean enabled(Context androidContext) { -// String sslCache = Settings.Gservices.getString(androidContext.getContentResolver(), -// Settings.Gservices.SSL_SESSION_CACHE); +// String sslCache = Settings.Secure.getString(androidContext.getContentResolver(), +// Settings.Secure.SSL_SESSION_CACHE); // // if (Log.isLoggable(TAG, Log.DEBUG)) { // Log.d(TAG, "enabled " + sslCache + " " + androidContext.getPackageName()); @@ -309,4 +309,4 @@ public class DatabaseSessionCache implements SSLClientSessionCache { } -}
\ No newline at end of file +} diff --git a/tests/CoreTests/android/core/MathTest.java b/tests/CoreTests/android/core/MathTest.java index 64c8c1e..50009db 100644 --- a/tests/CoreTests/android/core/MathTest.java +++ b/tests/CoreTests/android/core/MathTest.java @@ -687,8 +687,7 @@ public class MathTest extends TestCase { /** * @tests java.lang.Math#tanh(double) */ - // TODO: Known failure, temporarily remove from SmallSuite - // @SmallTest + @SmallTest public void testTanhD() { // Test for special situations assertTrue("Should return NaN", Double.isNaN(Math.tanh(Double.NaN))); diff --git a/tests/CoreTests/android/core/RegexTest.java b/tests/CoreTests/android/core/RegexTest.java index a7f79e8..743afc1 100644 --- a/tests/CoreTests/android/core/RegexTest.java +++ b/tests/CoreTests/android/core/RegexTest.java @@ -17,7 +17,6 @@ package android.core; import android.test.suitebuilder.annotation.SmallTest; -import android.text.util.Regex; import junit.framework.TestCase; diff --git a/tests/CoreTests/android/core/StrictMathTest.java b/tests/CoreTests/android/core/StrictMathTest.java index c98c91d..92e6cb6 100644 --- a/tests/CoreTests/android/core/StrictMathTest.java +++ b/tests/CoreTests/android/core/StrictMathTest.java @@ -709,8 +709,7 @@ public class StrictMathTest extends TestCase { /** * @tests java.lang.StrictMath#tanh(double) */ - // TODO: Known failure, temporarily remove from small suite - // @SmallTest + @SmallTest public void testTanhD() { // Test for special situations assertTrue(Double.isNaN(StrictMath.tanh(Double.NaN))); diff --git a/tests/CoreTests/android/webkit/CookieTest.java b/tests/CoreTests/android/webkit/CookieTest.java deleted file mode 100644 index 5c5a6a8..0000000 --- a/tests/CoreTests/android/webkit/CookieTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.webkit; - -import android.content.Context; -import android.test.AndroidTestCase; -import android.util.Log; -import android.webkit.CookieManager; -import android.webkit.CookieSyncManager; - -public class CookieTest extends AndroidTestCase { - - /** - * To run these tests: $ mmm frameworks/base/tests/CoreTests/android && adb - * remount && adb sync $ adb shell am instrument -w \ -e class - * android.webkit.CookieTest \ - * android.core/android.test.InstrumentationTestRunner - */ - - private CookieManager mCookieManager; - - @Override - public void setContext(Context context) { - assertTrue(mContext == null); - super.setContext(context); - CookieSyncManager.createInstance(context); - mCookieManager = CookieManager.getInstance(); - mCookieManager.removeAllCookie(); - } - - public void testParse() { - mCookieManager.removeAllCookie(); - String url = "http://www.foo.com"; - - // basic - mCookieManager.setCookie(url, "a=b"); - String cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b")); - - // quoted - mCookieManager.setCookie(url, "c=\"d;\""); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b; c=\"d;\"")); - - // empty - mCookieManager.setCookie(url, "; path=/"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b; c=\"d;\"")); - } - - public void testDomain() { - mCookieManager.removeAllCookie(); - String url = "http://www.foo.com"; - - // basic - mCookieManager.setCookie(url, "a=b"); - String cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b")); - - // no cross domain cookie - cookie = mCookieManager.getCookie("http://bar.com"); - assertTrue(cookie == null); - - // more than one cookie - mCookieManager.setCookie(url, "c=d; domain=.foo.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b; c=d")); - - // host cookie should not be accessible from a sub-domain. - cookie = mCookieManager.getCookie("http://bar.www.foo.com"); - assertTrue(cookie.equals("c=d")); - - // test setting a domain= that doesn't start w/ a dot, should - // treat it as a domain cookie, as if there was a pre-pended dot. - mCookieManager.setCookie(url, "e=f; domain=www.foo.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=b; c=d; e=f")); - cookie = mCookieManager.getCookie("http://sub.www.foo.com"); - assertTrue(cookie.equals("c=d; e=f")); - cookie = mCookieManager.getCookie("http://foo.com"); - assertTrue(cookie.equals("c=d")); - } - - public void testSubDomain() { - mCookieManager.removeAllCookie(); - String url_abcd = "http://a.b.c.d.com"; - String url_bcd = "http://b.c.d.com"; - String url_cd = "http://c.d.com"; - String url_d = "http://d.com"; - - mCookieManager.setCookie(url_abcd, "a=1; domain=.a.b.c.d.com"); - mCookieManager.setCookie(url_abcd, "b=2; domain=.b.c.d.com"); - mCookieManager.setCookie(url_abcd, "c=3; domain=.c.d.com"); - mCookieManager.setCookie(url_abcd, "d=4; domain=.d.com"); - - String cookie = mCookieManager.getCookie(url_abcd); - assertTrue(cookie.equals("a=1; b=2; c=3; d=4")); - cookie = mCookieManager.getCookie(url_bcd); - assertTrue(cookie.equals("b=2; c=3; d=4")); - cookie = mCookieManager.getCookie(url_cd); - assertTrue(cookie.equals("c=3; d=4")); - cookie = mCookieManager.getCookie(url_d); - assertTrue(cookie.equals("d=4")); - - // check that the same cookie can exist on different sub-domains. - mCookieManager.setCookie(url_bcd, "x=bcd; domain=.b.c.d.com"); - mCookieManager.setCookie(url_bcd, "x=cd; domain=.c.d.com"); - cookie = mCookieManager.getCookie(url_bcd); - assertTrue(cookie.equals("b=2; c=3; d=4; x=bcd; x=cd")); - cookie = mCookieManager.getCookie(url_cd); - assertTrue(cookie.equals("c=3; d=4; x=cd")); - } - - public void testInvalidDomain() { - mCookieManager.removeAllCookie(); - String url = "http://foo.bar.com"; - - mCookieManager.setCookie(url, "a=1; domain=.yo.foo.bar.com"); - String cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "b=2; domain=.foo.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "c=3; domain=.bar.foo.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "d=4; domain=.foo.bar.com.net"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "e=5; domain=.ar.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "f=6; domain=.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "g=7; domain=.co.uk"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "h=8; domain=.foo.bar.com.com"); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - } - - public void testPath() { - mCookieManager.removeAllCookie(); - String url = "http://www.foo.com"; - - mCookieManager.setCookie(url, "a=b; path=/wee"); - String cookie = mCookieManager.getCookie(url + "/wee"); - assertTrue(cookie.equals("a=b")); - cookie = mCookieManager.getCookie(url + "/wee/"); - assertTrue(cookie.equals("a=b")); - cookie = mCookieManager.getCookie(url + "/wee/hee"); - assertTrue(cookie.equals("a=b")); - cookie = mCookieManager.getCookie(url + "/wee/hee/more"); - assertTrue(cookie.equals("a=b")); - cookie = mCookieManager.getCookie(url + "/weehee"); - assertTrue(cookie == null); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie == null); - - mCookieManager.setCookie(url, "a=c; path="); - cookie = mCookieManager.getCookie(url + "/wee"); - assertTrue(cookie.equals("a=b; a=c")); - cookie = mCookieManager.getCookie(url); - assertTrue(cookie.equals("a=c")); - - mCookieManager.setCookie(url, "a=d"); - cookie = mCookieManager.getCookie(url + "/wee"); - assertTrue(cookie.equals("a=b; a=d")); - } -} diff --git a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java index 20ea4d7..aa2981b 100644 --- a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java +++ b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java @@ -25,7 +25,7 @@ import junit.framework.TestCase; public class PhoneNumberUtilsTest extends TestCase { @SmallTest - public void testA() throws Exception { + public void testExtractNetworkPortion() throws Exception { assertEquals( "+17005554141", PhoneNumberUtils.extractNetworkPortion("+17005554141") @@ -181,6 +181,68 @@ public class PhoneNumberUtilsTest extends TestCase { } @SmallTest + public void testExtractNetworkPortionAlt() throws Exception { + assertEquals( + "+17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("+17005554141") + ); + + assertEquals( + "+17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("+1 (700).555-4141") + ); + + assertEquals( + "17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141") + ); + + // This may seem wrong, but it's probably ok + assertEquals( + "17005554141*#", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141*#") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN,1234") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN;1234") + ); + + // An MMI string is unperterbed, even though it contains a + // (valid in this case) embedded + + assertEquals( + "**21**+17005554141#", + PhoneNumberUtils.extractNetworkPortionAlt("**21**+17005554141#") + ); + + assertEquals( + "*31#+447966164208", + PhoneNumberUtils.extractNetworkPortionAlt("*31#+447966164208") + ); + + assertEquals( + "*31#+447966164208", + PhoneNumberUtils.extractNetworkPortionAlt("*31# (+44) 79 6616 4208") + ); + + assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt("")); + + assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(",1234")); + + assertNull(PhoneNumberUtils.extractNetworkPortionAlt(null)); + } + + @SmallTest public void testB() throws Exception { assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141")); assertEquals("", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-4141")); @@ -252,6 +314,9 @@ public class PhoneNumberUtilsTest extends TestCase { // 444 is not a valid country code, but // matchIntlPrefixAndCC doesnt know this assertTrue(PhoneNumberUtils.compare("+444 207 792 3490", "0 207 792 3490")); + + // compare SMS short code + assertTrue(PhoneNumberUtils.compare("404-04", "40404")); } diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java index ae53b76..cde2c71 100644 --- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java +++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java @@ -141,20 +141,20 @@ public class DpiTestActivity extends Activity { private View scrollWrap(View view) { ScrollView scroller = new ScrollView(this); - scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.FILL_PARENT, - ScrollView.LayoutParams.FILL_PARENT)); + scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, + ScrollView.LayoutParams.MATCH_PARENT)); return scroller; } private void addLabelToRoot(LinearLayout root, String text) { TextView label = new TextView(this); label.setText(text); - root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, + root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); } private void addChildToRoot(LinearLayout root, LinearLayout layout) { - root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, + root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); } diff --git a/tests/DumpRenderTree/assets/run_page_cycler.py b/tests/DumpRenderTree/assets/run_page_cycler.py index 7dd4a88..8b8fb38 100755 --- a/tests/DumpRenderTree/assets/run_page_cycler.py +++ b/tests/DumpRenderTree/assets/run_page_cycler.py @@ -20,7 +20,7 @@ import time def main(options, args): """Run the tests. Will call sys.exit when complete. - + """ # Set up logging format. @@ -56,7 +56,15 @@ def main(options, args): run_load_test_cmd_postfix = " -w com.android.dumprendertree/.LayoutTestsAutoRunner" # Call LoadTestsAutoTest::runTest. - run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e path \"" + path + "\" -e timeout " + timeout_ms + run_load_test_cmd_postfix + run_load_test_cmd = run_load_test_cmd_prefix + " -e class com.android.dumprendertree.LoadTestsAutoTest#runPageCyclerTest -e path \"" + path + "\" -e timeout " + timeout_ms + + if options.drawtime: + run_load_test_cmd += " -e drawtime true " + + if options.save_image: + run_load_test_cmd += " -e saveimage \"%s\"" % options.save_image + + run_load_test_cmd += run_load_test_cmd_postfix (adb_output, adb_error) = subprocess.Popen(run_load_test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() fail_flag = False @@ -101,18 +109,26 @@ def main(options, args): if '__main__' == __name__: option_parser = optparse.OptionParser() - option_parser.add_option("", "--time-out-ms", + option_parser.add_option("-t", "--time-out-ms", default=None, help="set the timeout for each test") - option_parser.add_option("", "--verbose", action="store_true", + option_parser.add_option("-v", "--verbose", action="store_true", default=False, help="include debug-level logging") - option_parser.add_option("", "--adb-options", + option_parser.add_option("-a", "--adb-options", default=None, help="pass options to adb, such as -d -e, etc"); - option_parser.add_option("", "--results-directory", + option_parser.add_option("-r", "--results-directory", default="layout-test-results", help="directory which results are stored.") + option_parser.add_option("-d", "--drawtime", action="store_true", + default=False, + help="log draw time for each page rendered.") + + option_parser.add_option("-s", "--save-image", + default=None, + help="stores rendered page to a location on device.") + options, args = option_parser.parse_args(); main(options, args) diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java index fea366c..1a265e8 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java @@ -25,6 +25,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.util.regex.Pattern; @@ -156,4 +157,43 @@ public class FsUtils { return same; } + public static boolean isTestPageUrl(String url) { + int qmPostion = url.indexOf('?'); + int slashPostion = url.lastIndexOf('/'); + if (slashPostion < qmPostion) { + String fileName = url.substring(slashPostion + 1, qmPostion); + if ("index.html".equals(fileName)) { + return true; + } + } + return false; + } + + public static String getLastSegmentInPath(String path) { + int endPos = path.lastIndexOf('/'); + path = path.substring(0, endPos); + endPos = path.lastIndexOf('/'); + return path.substring(endPos + 1); + } + + public static void writeDrawTime(String fileName, String url, long[] times) { + StringBuffer lineBuffer = new StringBuffer(); + // grab the last segment of path in url + lineBuffer.append(getLastSegmentInPath(url)); + for (long time : times) { + lineBuffer.append('\t'); + lineBuffer.append(time); + } + lineBuffer.append('\n'); + String line = lineBuffer.toString(); + Log.v(LOGTAG, "logging draw times: " + line); + try { + FileWriter fw = new FileWriter(fileName, true); + fw.write(line); + fw.close(); + } catch (IOException ioe) { + Log.e(LOGTAG, "Failed to log draw times", ioe); + } + } + } diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java index 283b98c..539d551 100755 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java @@ -73,13 +73,20 @@ public class LayoutTestsAutoRunner extends InstrumentationTestRunner { this.mLogtime = (logtime != null && logtime.toLowerCase().equals("true")); + String drawTime = (String) icicle.get("drawtime"); + this.mGetDrawTime = (drawTime != null + && drawTime.toLowerCase().equals("true")); + + mSaveImagePath = (String) icicle.get("saveimage"); + super.onCreate(icicle); } public String mTestPath = null; + public String mSaveImagePath = null; public int mTimeoutInMillis = 0; public int mDelay = 0; public boolean mRebaseline = false; public boolean mLogtime = false; + public boolean mGetDrawTime = false; } - diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index ba46197..2ef342f 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -70,7 +70,8 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel freeMem(); // Run tests - runTestAndWaitUntilDone(activity, runner.mTestPath, runner.mTimeoutInMillis); + runTestAndWaitUntilDone(activity, runner.mTestPath, runner.mTimeoutInMillis, + runner.mGetDrawTime, runner.mSaveImagePath); activity.clearCache(); try { @@ -161,7 +162,8 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel } // A convenient method to be called by another activity. - private void runTestAndWaitUntilDone(TestShellActivity activity, String url, int timeout) { + private void runTestAndWaitUntilDone(TestShellActivity activity, String url, int timeout, + boolean getDrawTime, String saveImagePath) { activity.setCallback(new TestShellCallback() { public void finished() { synchronized (LoadTestsAutoTest.this) { @@ -181,6 +183,9 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel intent.putExtra(TestShellActivity.TEST_URL, url); intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout); intent.putExtra(TestShellActivity.RESULT_FILE, LOAD_TEST_RESULT); + intent.putExtra(TestShellActivity.GET_DRAW_TIME, getDrawTime); + if (saveImagePath != null) + intent.putExtra(TestShellActivity.SAVE_IMAGE, saveImagePath); activity.startActivity(intent); // Wait until done. diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java index fbce78a..9a4e99e 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java @@ -85,8 +85,8 @@ public class ReliabilityTestActivity extends Activity { webView.setWebChromeClient(chromeClient); contentView.addView(webView, new LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT, 0.0f)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 0.0f)); handler = new Handler() { @Override diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java index aeb55b4..5763b85 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java @@ -25,6 +25,9 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.DialogInterface.OnClickListener; import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Bitmap.CompressFormat; +import android.graphics.Bitmap.Config; import android.net.http.SslError; import android.os.Bundle; import android.os.Handler; @@ -123,7 +126,7 @@ public class TestShellActivity extends Activity implements LayoutTestController mWebView.addJavascriptInterface(mCallbackProxy, "eventSender"); setupWebViewForLayoutTests(mWebView, mCallbackProxy); - contentView.addView(mWebView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0f)); + contentView.addView(mWebView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f)); mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); @@ -163,6 +166,8 @@ public class TestShellActivity extends Activity implements LayoutTestController mResultFile = intent.getStringExtra(RESULT_FILE); mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 0); + mGetDrawtime = intent.getBooleanExtra(GET_DRAW_TIME, false); + mSaveImagePath = intent.getStringExtra(SAVE_IMAGE); Log.v(LOGTAG, " Loading " + mTestUrl); mWebView.loadUrl(mTestUrl); @@ -459,6 +464,18 @@ public class TestShellActivity extends Activity implements LayoutTestController public void onPageFinished(WebView view, String url) { Log.v(LOGTAG, "onPageFinished, url=" + url); mPageFinished = true; + // get page draw time + if (FsUtils.isTestPageUrl(url)) { + if (mGetDrawtime) { + long[] times = new long[DRAW_RUNS]; + times = getDrawWebViewTime(mWebView, DRAW_RUNS); + FsUtils.writeDrawTime(DRAW_TIME_LOG, url, times); + } + if (mSaveImagePath != null) { + String name = FsUtils.getLastSegmentInPath(url); + drawPageToFile(mSaveImagePath + "/" + name + ".png", mWebView); + } + } // Calling finished() will check if we've met all the conditions for completing // this test and move to the next one if we are ready. if (finished()) { @@ -691,6 +708,41 @@ public class TestShellActivity extends Activity implements LayoutTestController mPageFinished = false; mOneHundredPercentComplete = false; mDumpWebKitData = false; + mGetDrawtime = false; + mSaveImagePath = null; + } + + private long[] getDrawWebViewTime(WebView view, int count) { + if (count == 0) + return null; + long[] ret = new long[count]; + long start; + Canvas canvas = new Canvas(); + Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888); + canvas.setBitmap(bitmap); + for (int i = 0; i < count; i++) { + start = System.currentTimeMillis(); + view.draw(canvas); + ret[i] = System.currentTimeMillis() - start; + } + return ret; + } + + private void drawPageToFile(String fileName, WebView view) { + Canvas canvas = new Canvas(); + Bitmap bitmap = Bitmap.createBitmap(view.getContentWidth(), view.getContentHeight(), + Config.ARGB_8888); + canvas.setBitmap(bitmap); + view.drawPage(canvas); + try { + FileOutputStream fos = new FileOutputStream(fileName); + if(!bitmap.compress(CompressFormat.PNG, 90, fos)) { + Log.w(LOGTAG, "Failed to compress and save image."); + } + } catch (IOException ioe) { + Log.e(LOGTAG, "", ioe); + } + bitmap.recycle(); } private boolean canMoveToNextTest() { @@ -730,7 +782,9 @@ public class TestShellActivity extends Activity implements LayoutTestController private String mResultFile; private int mTimeoutInMillis; private String mUiAutoTestPath; + private String mSaveImagePath; private BufferedReader mTestListReader; + private boolean mGetDrawtime; // States private boolean mTimedOut; @@ -766,6 +820,11 @@ public class TestShellActivity extends Activity implements LayoutTestController static final String RESULT_FILE = "ResultFile"; static final String TIMEOUT_IN_MILLIS = "TimeoutInMillis"; static final String UI_AUTO_TEST = "UiAutoTest"; + static final String GET_DRAW_TIME = "GetDrawTime"; + static final String SAVE_IMAGE = "SaveImage"; + + static final int DRAW_RUNS = 5; + static final String DRAW_TIME_LOG = "/sdcard/android/page_draw_time.txt"; private boolean mGeolocationPermissionSet; private boolean mGeolocationPermission; diff --git a/tests/FrameworkTest/AndroidManifest.xml b/tests/FrameworkTest/AndroidManifest.xml index 4e4ebff..3030c06 100644 --- a/tests/FrameworkTest/AndroidManifest.xml +++ b/tests/FrameworkTest/AndroidManifest.xml @@ -377,6 +377,13 @@ </intent-filter> </activity> + <activity android:name=".view.VisibilityCallback" android:label="VisibilityCallback"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" /> + </intent-filter> + </activity> + <activity android:name=".view.BigCache" android:label="BigCache"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -955,6 +962,14 @@ <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> </service> + + <activity android:name=".radiogroup.RadioGroupActivity" android:label="RadioGroupActivity"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" /> + </intent-filter> + </activity> + </application> diff --git a/tests/FrameworkTest/res/layout/add_column_in_table.xml b/tests/FrameworkTest/res/layout/add_column_in_table.xml index 62c27f3..05f55a8 100644 --- a/tests/FrameworkTest/res/layout/add_column_in_table.xml +++ b/tests/FrameworkTest/res/layout/add_column_in_table.xml @@ -16,11 +16,11 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <TableLayout android:id="@+id/table" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1.0"> diff --git a/tests/FrameworkTest/res/layout/autocompletetextview_simple.xml b/tests/FrameworkTest/res/layout/autocompletetextview_simple.xml index d408a86..1a20076 100644 --- a/tests/FrameworkTest/res/layout/autocompletetextview_simple.xml +++ b/tests/FrameworkTest/res/layout/autocompletetextview_simple.xml @@ -20,12 +20,12 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <AutoCompleteTextView android:id="@+id/autocompletetextview1" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text|textAutoComplete" android:completionThreshold="1" /> diff --git a/tests/FrameworkTest/res/layout/baseline_0width_and_weight.xml b/tests/FrameworkTest/res/layout/baseline_0width_and_weight.xml index 83f3fcb..aa3132d 100644 --- a/tests/FrameworkTest/res/layout/baseline_0width_and_weight.xml +++ b/tests/FrameworkTest/res/layout/baseline_0width_and_weight.xml @@ -19,10 +19,10 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <LinearLayout android:id="@+id/layout" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:visibility="gone"> diff --git a/tests/FrameworkTest/res/layout/baseline_buttons.xml b/tests/FrameworkTest/res/layout/baseline_buttons.xml index ae94201..3e364bd 100644 --- a/tests/FrameworkTest/res/layout/baseline_buttons.xml +++ b/tests/FrameworkTest/res/layout/baseline_buttons.xml @@ -19,7 +19,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> diff --git a/tests/FrameworkTest/res/layout/baseline_center_gravity.xml b/tests/FrameworkTest/res/layout/baseline_center_gravity.xml index 9793ab4..dd1318d 100644 --- a/tests/FrameworkTest/res/layout/baseline_center_gravity.xml +++ b/tests/FrameworkTest/res/layout/baseline_center_gravity.xml @@ -19,7 +19,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/button1" android:layout_height="wrap_content" diff --git a/tests/FrameworkTest/res/layout/descendant_focusability.xml b/tests/FrameworkTest/res/layout/descendant_focusability.xml index 6a30d50..0cb75fd 100644 --- a/tests/FrameworkTest/res/layout/descendant_focusability.xml +++ b/tests/FrameworkTest/res/layout/descendant_focusability.xml @@ -20,19 +20,19 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" > <LinearLayout android:id="@+id/beforeDescendants" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantFocusability="beforeDescendants" > <Button - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> @@ -40,12 +40,12 @@ <LinearLayout android:id="@+id/afterDescendants" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantFocusability="afterDescendants" > <Button - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> @@ -53,12 +53,12 @@ <LinearLayout android:id="@+id/blocksDescendants" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantFocusability="blocksDescendants" > <Button - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/disabled.xml b/tests/FrameworkTest/res/layout/disabled.xml index ed7ff06..4b41248 100644 --- a/tests/FrameworkTest/res/layout/disabled.xml +++ b/tests/FrameworkTest/res/layout/disabled.xml @@ -23,8 +23,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/clickableParent" android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/disabledButton" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/fill_in_wrap.xml b/tests/FrameworkTest/res/layout/fill_in_wrap.xml index b61fd30..1c3f811 100644 --- a/tests/FrameworkTest/res/layout/fill_in_wrap.xml +++ b/tests/FrameworkTest/res/layout/fill_in_wrap.xml @@ -15,7 +15,7 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:orientation="horizontal" android:baselineAligned="false" @@ -28,7 +28,7 @@ /> <LinearLayout android:id="@+id/layout" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="0dip" android:paddingRight="0dip" @@ -43,7 +43,7 @@ <EditText android:id="@+id/data" android:layout_width="0dip" android:layout_weight="1" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_marginLeft="8dip" android:paddingBottom="4dip" android:layout_gravity="center_vertical" diff --git a/tests/FrameworkTest/res/layout/focus_after_removal.xml b/tests/FrameworkTest/res/layout/focus_after_removal.xml index 7cf6cbe..f4e388d 100644 --- a/tests/FrameworkTest/res/layout/focus_after_removal.xml +++ b/tests/FrameworkTest/res/layout/focus_after_removal.xml @@ -20,7 +20,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/leftLayout" diff --git a/tests/FrameworkTest/res/layout/focus_listener.xml b/tests/FrameworkTest/res/layout/focus_listener.xml index a838205..6faa21c 100644 --- a/tests/FrameworkTest/res/layout/focus_listener.xml +++ b/tests/FrameworkTest/res/layout/focus_listener.xml @@ -20,7 +20,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/left" diff --git a/tests/FrameworkTest/res/layout/framelayout_gravity.xml b/tests/FrameworkTest/res/layout/framelayout_gravity.xml index ce48825..e89fce5 100644 --- a/tests/FrameworkTest/res/layout/framelayout_gravity.xml +++ b/tests/FrameworkTest/res/layout/framelayout_gravity.xml @@ -16,8 +16,8 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parent" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/left" android:layout_gravity="left" diff --git a/tests/FrameworkTest/res/layout/framelayout_margin.xml b/tests/FrameworkTest/res/layout/framelayout_margin.xml index 1e14899..9120bcb 100644 --- a/tests/FrameworkTest/res/layout/framelayout_margin.xml +++ b/tests/FrameworkTest/res/layout/framelayout_margin.xml @@ -16,8 +16,8 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parent" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/left" android:layout_gravity="left" diff --git a/tests/FrameworkTest/res/layout/grid_in_horizontal.xml b/tests/FrameworkTest/res/layout/grid_in_horizontal.xml index 835dce3..62d7bcb 100644 --- a/tests/FrameworkTest/res/layout/grid_in_horizontal.xml +++ b/tests/FrameworkTest/res/layout/grid_in_horizontal.xml @@ -16,12 +16,12 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <GridView android:id="@+id/grid" android:layout_width="0dip" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:padding="10dip" android:verticalSpacing="10dp" diff --git a/tests/FrameworkTest/res/layout/grid_in_vertical.xml b/tests/FrameworkTest/res/layout/grid_in_vertical.xml index 731bc54..fea459a 100644 --- a/tests/FrameworkTest/res/layout/grid_in_vertical.xml +++ b/tests/FrameworkTest/res/layout/grid_in_vertical.xml @@ -16,8 +16,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <GridView android:id="@+id/grid" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/grid_scroll_listener.xml b/tests/FrameworkTest/res/layout/grid_scroll_listener.xml index c02aed9..82b1058 100644 --- a/tests/FrameworkTest/res/layout/grid_scroll_listener.xml +++ b/tests/FrameworkTest/res/layout/grid_scroll_listener.xml @@ -16,11 +16,11 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <GridView android:id="@+id/grid" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:padding="10dip" @@ -32,7 +32,7 @@ android:gravity="center"/> <TextView android:id="@+id/text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"/> diff --git a/tests/FrameworkTest/res/layout/grid_thrasher.xml b/tests/FrameworkTest/res/layout/grid_thrasher.xml index 1a260df..346acff 100644 --- a/tests/FrameworkTest/res/layout/grid_thrasher.xml +++ b/tests/FrameworkTest/res/layout/grid_thrasher.xml @@ -16,12 +16,12 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <GridView android:id="@+id/grid" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:padding="10dip" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" @@ -31,7 +31,7 @@ android:gravity="center"/> <TextView android:id="@+id/text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"/> diff --git a/tests/FrameworkTest/res/layout/include_tag.xml b/tests/FrameworkTest/res/layout/include_tag.xml index d1047f1..b2f6ab1 100644 --- a/tests/FrameworkTest/res/layout/include_tag.xml +++ b/tests/FrameworkTest/res/layout/include_tag.xml @@ -16,8 +16,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <TextView android:text="@string/include_label" diff --git a/tests/FrameworkTest/res/layout/inflated_expandablelistview.xml b/tests/FrameworkTest/res/layout/inflated_expandablelistview.xml index d01e7c5..6f683e5 100644 --- a/tests/FrameworkTest/res/layout/inflated_expandablelistview.xml +++ b/tests/FrameworkTest/res/layout/inflated_expandablelistview.xml @@ -16,5 +16,5 @@ <ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/elv" - android:layout_height="fill_parent" - android:layout_width="fill_parent" /> + android:layout_height="match_parent" + android:layout_width="match_parent" /> diff --git a/tests/FrameworkTest/res/layout/linear_layout_buttons.xml b/tests/FrameworkTest/res/layout/linear_layout_buttons.xml index f60692a..bcb28e7 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_buttons.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_buttons.xml @@ -20,26 +20,26 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/button1" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:text="@string/keypad_one"/> <Button android:id="@+id/button2" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:text="@string/keypad_two"/> <Button android:id="@+id/button3" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:text="@string/keypad_three"/> diff --git a/tests/FrameworkTest/res/layout/linear_layout_edittext_then_button.xml b/tests/FrameworkTest/res/layout/linear_layout_edittext_then_button.xml index 21e7399..ab76e29 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_edittext_then_button.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_edittext_then_button.xml @@ -20,18 +20,18 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <EditText android:id="@+id/editText" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1"/> <Button android:id="@+id/button" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:text="@string/keypad_one"/> diff --git a/tests/FrameworkTest/res/layout/linear_layout_grid.xml b/tests/FrameworkTest/res/layout/linear_layout_grid.xml index 81f7b15..67b6877 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_grid.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_grid.xml @@ -20,80 +20,80 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <LinearLayout android:id="@+id/column1" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:orientation="horizontal"> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_one"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_two"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_three"/> </LinearLayout> <LinearLayout android:id="@+id/column2" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:orientation="horizontal"> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_four"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_five"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_six"/> </LinearLayout> <LinearLayout android:id="@+id/column3" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0sp" android:layout_weight="1" android:orientation="horizontal"> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_seven"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_eight"/> <Button android:layout_width="0sp" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="1" android:text="@string/keypad_nine"/> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/linear_layout_listview_height.xml b/tests/FrameworkTest/res/layout/linear_layout_listview_height.xml index 10ef2ce..873b2d2 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_listview_height.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_listview_height.xml @@ -20,19 +20,19 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <!-- Outer linear layout providing vertical layout --> <LinearLayout android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" > <!-- The control buttons --> <LinearLayout android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" > <Button @@ -58,7 +58,7 @@ <ListView android:id="@+id/inner_list" android:layout_width="200dip" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:background="@android:drawable/spinner_dropdown_background" android:divider="@android:drawable/divider_horizontal_bright" /> diff --git a/tests/FrameworkTest/res/layout/linear_layout_spinner_then_button.xml b/tests/FrameworkTest/res/layout/linear_layout_spinner_then_button.xml index 7ed245b..53c0280 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_spinner_then_button.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_spinner_then_button.xml @@ -20,7 +20,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Spinner android:id="@+id/reminder_value" diff --git a/tests/FrameworkTest/res/layout/linear_layout_textviews.xml b/tests/FrameworkTest/res/layout/linear_layout_textviews.xml index 84a898c..ccec213 100644 --- a/tests/FrameworkTest/res/layout/linear_layout_textviews.xml +++ b/tests/FrameworkTest/res/layout/linear_layout_textviews.xml @@ -21,7 +21,7 @@ android:id="@+id/layout" android:background="#FFFF0000" android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText diff --git a/tests/FrameworkTest/res/layout/list_dividers.xml b/tests/FrameworkTest/res/layout/list_dividers.xml index b56511e..93810b4 100644 --- a/tests/FrameworkTest/res/layout/list_dividers.xml +++ b/tests/FrameworkTest/res/layout/list_dividers.xml @@ -16,8 +16,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/list_filter.xml b/tests/FrameworkTest/res/layout/list_filter.xml index cea518c..0ab7101 100644 --- a/tests/FrameworkTest/res/layout/list_filter.xml +++ b/tests/FrameworkTest/res/layout/list_filter.xml @@ -16,24 +16,24 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <FrameLayout android:id="@+id/frame" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1"> <ListView android:id="@android:id/list" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:drawSelectorOnTop="false" /> </FrameLayout> <LinearLayout android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/hide" diff --git a/tests/FrameworkTest/res/layout/list_in_horizontal.xml b/tests/FrameworkTest/res/layout/list_in_horizontal.xml index 371cb84..b770628 100644 --- a/tests/FrameworkTest/res/layout/list_in_horizontal.xml +++ b/tests/FrameworkTest/res/layout/list_in_horizontal.xml @@ -15,8 +15,8 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <TableRow> diff --git a/tests/FrameworkTest/res/layout/list_in_vertical.xml b/tests/FrameworkTest/res/layout/list_in_vertical.xml index 0ea2475..f951cb7 100644 --- a/tests/FrameworkTest/res/layout/list_in_vertical.xml +++ b/tests/FrameworkTest/res/layout/list_in_vertical.xml @@ -15,16 +15,16 @@ --> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/list" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageButton diff --git a/tests/FrameworkTest/res/layout/list_recycler_profiling.xml b/tests/FrameworkTest/res/layout/list_recycler_profiling.xml index 9678eb7..3fc6bd6 100644 --- a/tests/FrameworkTest/res/layout/list_recycler_profiling.xml +++ b/tests/FrameworkTest/res/layout/list_recycler_profiling.xml @@ -16,11 +16,11 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ListView android:id="@+id/list" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1.0" /> diff --git a/tests/FrameworkTest/res/layout/list_scroll_listener.xml b/tests/FrameworkTest/res/layout/list_scroll_listener.xml index 001296a..58ab55f 100644 --- a/tests/FrameworkTest/res/layout/list_scroll_listener.xml +++ b/tests/FrameworkTest/res/layout/list_scroll_listener.xml @@ -16,17 +16,17 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ListView android:id="@android:id/list" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:drawSelectorOnTop="false"/> <TextView android:id="@+id/text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"/> diff --git a/tests/FrameworkTest/res/layout/list_take_focus_from_side.xml b/tests/FrameworkTest/res/layout/list_take_focus_from_side.xml index cf141cc..ee40019 100644 --- a/tests/FrameworkTest/res/layout/list_take_focus_from_side.xml +++ b/tests/FrameworkTest/res/layout/list_take_focus_from_side.xml @@ -16,19 +16,19 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ListView android:id="@android:id/list" android:layout_width="0dip" android:layout_weight="1" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:drawSelectorOnTop="false"/> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" - android:layout_height="fill_parent"> + android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/tests/FrameworkTest/res/layout/list_thrasher.xml b/tests/FrameworkTest/res/layout/list_thrasher.xml index 001296a..58ab55f 100644 --- a/tests/FrameworkTest/res/layout/list_thrasher.xml +++ b/tests/FrameworkTest/res/layout/list_thrasher.xml @@ -16,17 +16,17 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ListView android:id="@android:id/list" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:drawSelectorOnTop="false"/> <TextView android:id="@+id/text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"/> diff --git a/tests/FrameworkTest/res/layout/list_with_button_above.xml b/tests/FrameworkTest/res/layout/list_with_button_above.xml index 25db016..18bcf6b 100644 --- a/tests/FrameworkTest/res/layout/list_with_button_above.xml +++ b/tests/FrameworkTest/res/layout/list_with_button_above.xml @@ -19,18 +19,18 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/button" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/button_above_list_label"/> <ListView android:id="@android:id/list" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:paddingTop="2dip" diff --git a/tests/FrameworkTest/res/layout/list_with_disappearing_item_bug_item.xml b/tests/FrameworkTest/res/layout/list_with_disappearing_item_bug_item.xml index 0163d96..82af6ca 100644 --- a/tests/FrameworkTest/res/layout/list_with_disappearing_item_bug_item.xml +++ b/tests/FrameworkTest/res/layout/list_with_disappearing_item_bug_item.xml @@ -16,13 +16,13 @@ <!-- A layout is needed to reprod the bug. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight"> <TextView android:id="@+id/text1" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:paddingLeft="27dip" diff --git a/tests/FrameworkTest/res/layout/list_with_empty_view.xml b/tests/FrameworkTest/res/layout/list_with_empty_view.xml index 00d81a7..23bb658 100644 --- a/tests/FrameworkTest/res/layout/list_with_empty_view.xml +++ b/tests/FrameworkTest/res/layout/list_with_empty_view.xml @@ -16,17 +16,17 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" > + android:layout_width="match_parent" + android:layout_height="match_parent" > <ListView android:id="@android:id/list" android:drawSelectorOnTop="false" - android:layout_width="fill_parent" - android:layout_height="fill_parent"/> + android:layout_width="match_parent" + android:layout_height="match_parent"/> <TextView android:id="@+id/empty" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:gravity="center" android:textSize="36sp" android:textColor="#999" diff --git a/tests/FrameworkTest/res/layout/longpress.xml b/tests/FrameworkTest/res/layout/longpress.xml index ef3672c..3a69fae 100644 --- a/tests/FrameworkTest/res/layout/longpress.xml +++ b/tests/FrameworkTest/res/layout/longpress.xml @@ -20,8 +20,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <View android:id="@+id/simple_view" android:background="@drawable/blue" diff --git a/tests/FrameworkTest/res/layout/mail_message.xml b/tests/FrameworkTest/res/layout/mail_message.xml index ed52751..7f15e4f 100644 --- a/tests/FrameworkTest/res/layout/mail_message.xml +++ b/tests/FrameworkTest/res/layout/mail_message.xml @@ -18,11 +18,11 @@ a list with a list of messages.--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/subject" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"/> <WebView android:id="@+id/body" diff --git a/tests/FrameworkTest/res/layout/popup_window_visibility.xml b/tests/FrameworkTest/res/layout/popup_window_visibility.xml index 21c94bb..3aa714d 100644 --- a/tests/FrameworkTest/res/layout/popup_window_visibility.xml +++ b/tests/FrameworkTest/res/layout/popup_window_visibility.xml @@ -16,25 +16,25 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <FrameLayout android:id="@+id/frame" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1"> <LinearLayout android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Spinner android:id="@+id/spinner" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> <AutoCompleteTextView android:id="@+id/auto" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> @@ -43,7 +43,7 @@ <LinearLayout android:orientation="horizontal" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/hide" diff --git a/tests/FrameworkTest/res/layout/pre_draw_listener.xml b/tests/FrameworkTest/res/layout/pre_draw_listener.xml index d348d9f..7a8f33f 100644 --- a/tests/FrameworkTest/res/layout/pre_draw_listener.xml +++ b/tests/FrameworkTest/res/layout/pre_draw_listener.xml @@ -16,20 +16,20 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <ScrollView android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1"> <view class="com.android.frameworktest.view.PreDrawListener$MyLinearLayout" android:id="@+id/frame" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" /> + android:layout_width="match_parent" + android:layout_height="match_parent" /> </ScrollView> diff --git a/tests/FrameworkTest/res/layout/radiogroup_checkedchild.xml b/tests/FrameworkTest/res/layout/radiogroup_checkedchild.xml new file mode 100644 index 0000000..db88f4d --- /dev/null +++ b/tests/FrameworkTest/res/layout/radiogroup_checkedchild.xml @@ -0,0 +1,44 @@ +<?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. +--> + +<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/group" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <RadioButton + android:id="@+id/value_one" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textColor="#555555" + android:checked="true" + android:text="@string/visibility_1_view_1" /> + + <RadioButton + android:id="@+id/value_two" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textColor="#555555" + android:text="@string/visibility_1_view_2" /> + + <RadioButton + android:id="@+id/value_three" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textColor="#555555" + android:text="@string/visibility_1_view_3" /> + +</RadioGroup> diff --git a/tests/FrameworkTest/res/layout/remote_view_host.xml b/tests/FrameworkTest/res/layout/remote_view_host.xml index dc52181..19d0a73 100644 --- a/tests/FrameworkTest/res/layout/remote_view_host.xml +++ b/tests/FrameworkTest/res/layout/remote_view_host.xml @@ -20,6 +20,6 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/remote_view_test_bad_1.xml b/tests/FrameworkTest/res/layout/remote_view_test_bad_1.xml index 6a65976..bdac697 100644 --- a/tests/FrameworkTest/res/layout/remote_view_test_bad_1.xml +++ b/tests/FrameworkTest/res/layout/remote_view_test_bad_1.xml @@ -21,8 +21,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <EditText android:id="@+id/edit" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/remote_view_test_bad_2.xml b/tests/FrameworkTest/res/layout/remote_view_test_bad_2.xml index 70613c3..630e603 100644 --- a/tests/FrameworkTest/res/layout/remote_view_test_bad_2.xml +++ b/tests/FrameworkTest/res/layout/remote_view_test_bad_2.xml @@ -21,8 +21,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <WebView android:id="@+id/web" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/remote_view_test_good.xml b/tests/FrameworkTest/res/layout/remote_view_test_good.xml index 54f4db9..ce9755b 100644 --- a/tests/FrameworkTest/res/layout/remote_view_test_good.xml +++ b/tests/FrameworkTest/res/layout/remote_view_test_good.xml @@ -21,8 +21,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <TextView android:id="@+id/text" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/scroll_to_rect_with_internal_scroll.xml b/tests/FrameworkTest/res/layout/scroll_to_rect_with_internal_scroll.xml index d22122d..b6ec479 100644 --- a/tests/FrameworkTest/res/layout/scroll_to_rect_with_internal_scroll.xml +++ b/tests/FrameworkTest/res/layout/scroll_to_rect_with_internal_scroll.xml @@ -22,24 +22,24 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/scrollToBlob" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/scroll_top_button"/> <TextView android:id="@+id/blob" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="80dip" android:layout_marginTop="500dip" android:layout_marginBottom="5dip"/> diff --git a/tests/FrameworkTest/res/layout/scroll_to_rectangle.xml b/tests/FrameworkTest/res/layout/scroll_to_rectangle.xml index 0839b1a..55d057d 100644 --- a/tests/FrameworkTest/res/layout/scroll_to_rectangle.xml +++ b/tests/FrameworkTest/res/layout/scroll_to_rectangle.xml @@ -22,55 +22,55 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/scrollToRectFromTop" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/scroll_top_button"/> <Button android:id="@+id/scrollToRectFromTop2" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="10dip" android:text="@string/scroll_top_button2"/> <TextView android:id="@+id/topBlob" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"/> <TextView android:id="@+id/childToMakeVisible" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="5dip" android:text="@string/scroll_to_me"/> <TextView android:id="@+id/bottomBlob" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"/> <Button android:id="@+id/scrollToRectFromBottom2" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dip" android:text="@string/scroll_bottom_button2"/> <Button android:id="@+id/scrollToRectFromBottom" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/scroll_bottom_button"/> diff --git a/tests/FrameworkTest/res/layout/scrollview_linear_layout.xml b/tests/FrameworkTest/res/layout/scrollview_linear_layout.xml index 536d2ed..a3c12ce 100644 --- a/tests/FrameworkTest/res/layout/scrollview_linear_layout.xml +++ b/tests/FrameworkTest/res/layout/scrollview_linear_layout.xml @@ -16,14 +16,14 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/scrollview_with_webviews.xml b/tests/FrameworkTest/res/layout/scrollview_with_webviews.xml index 7963475..e0c0c66 100644 --- a/tests/FrameworkTest/res/layout/scrollview_with_webviews.xml +++ b/tests/FrameworkTest/res/layout/scrollview_with_webviews.xml @@ -16,27 +16,27 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:id="@+id/layout" android:orientation="vertical" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <WebView android:id="@+id/wb1" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"/> <Button android:id="@+id/button" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"/> <WebView android:id="@+id/wb2" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/table_layout_cell_span.xml b/tests/FrameworkTest/res/layout/table_layout_cell_span.xml index 26831e4..fceef0a 100644 --- a/tests/FrameworkTest/res/layout/table_layout_cell_span.xml +++ b/tests/FrameworkTest/res/layout/table_layout_cell_span.xml @@ -18,7 +18,7 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TableRow> diff --git a/tests/FrameworkTest/res/layout/table_layout_fixed_width.xml b/tests/FrameworkTest/res/layout/table_layout_fixed_width.xml index 91d9128..507701e 100644 --- a/tests/FrameworkTest/res/layout/table_layout_fixed_width.xml +++ b/tests/FrameworkTest/res/layout/table_layout_fixed_width.xml @@ -19,7 +19,7 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TableRow> diff --git a/tests/FrameworkTest/res/layout/table_layout_horizontal_gravity.xml b/tests/FrameworkTest/res/layout/table_layout_horizontal_gravity.xml index dee81a5..fb72d81 100644 --- a/tests/FrameworkTest/res/layout/table_layout_horizontal_gravity.xml +++ b/tests/FrameworkTest/res/layout/table_layout_horizontal_gravity.xml @@ -19,7 +19,7 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1"> diff --git a/tests/FrameworkTest/res/layout/table_layout_vertical_gravity.xml b/tests/FrameworkTest/res/layout/table_layout_vertical_gravity.xml index 6a8b784..ae17ada 100644 --- a/tests/FrameworkTest/res/layout/table_layout_vertical_gravity.xml +++ b/tests/FrameworkTest/res/layout/table_layout_vertical_gravity.xml @@ -19,7 +19,7 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TableRow> diff --git a/tests/FrameworkTest/res/layout/table_layout_weight.xml b/tests/FrameworkTest/res/layout/table_layout_weight.xml index 432c04a..ba4fade 100644 --- a/tests/FrameworkTest/res/layout/table_layout_weight.xml +++ b/tests/FrameworkTest/res/layout/table_layout_weight.xml @@ -19,7 +19,7 @@ --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TableRow android:id="@+id/row" diff --git a/tests/FrameworkTest/res/layout/translucent_background.xml b/tests/FrameworkTest/res/layout/translucent_background.xml index 6b6e1cf..c4a1acf 100644 --- a/tests/FrameworkTest/res/layout/translucent_background.xml +++ b/tests/FrameworkTest/res/layout/translucent_background.xml @@ -19,6 +19,6 @@ <!-- This screen consists of a single text field that displays some text. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text" - android:layout_width="fill_parent" android:layout_height="fill_parent" + android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical|center_horizontal" android:text="@string/translucent_background"/> diff --git a/tests/FrameworkTest/res/layout/viewgroupchildren.xml b/tests/FrameworkTest/res/layout/viewgroupchildren.xml index a5bb7cb..22595ed 100644 --- a/tests/FrameworkTest/res/layout/viewgroupchildren.xml +++ b/tests/FrameworkTest/res/layout/viewgroupchildren.xml @@ -23,7 +23,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/group" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/viewstub.xml b/tests/FrameworkTest/res/layout/viewstub.xml index 9a6f376..8b32d8f 100644 --- a/tests/FrameworkTest/res/layout/viewstub.xml +++ b/tests/FrameworkTest/res/layout/viewstub.xml @@ -20,8 +20,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/vis" android:layout_width="wrap_content" diff --git a/tests/FrameworkTest/res/layout/visibility.xml b/tests/FrameworkTest/res/layout/visibility.xml index b4f9d8b..7edfa33 100644 --- a/tests/FrameworkTest/res/layout/visibility.xml +++ b/tests/FrameworkTest/res/layout/visibility.xml @@ -22,30 +22,30 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:background="@drawable/box" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/refUp" android:background="@drawable/red" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/visibility_1_view_1"/> <TextView android:id="@+id/victim" android:background="@drawable/green" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/visibility_1_view_2"/> <TextView android:id="@+id/refDown" android:background="@drawable/blue" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/visibility_1_view_3"/> diff --git a/tests/FrameworkTest/res/layout/visibility_callback.xml b/tests/FrameworkTest/res/layout/visibility_callback.xml new file mode 100644 index 0000000..322b640 --- /dev/null +++ b/tests/FrameworkTest/res/layout/visibility_callback.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2007, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Demonstrates changing view visibility. See corresponding Java code. --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:orientation="vertical" + android:background="@drawable/box" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView android:id="@+id/refUp" + android:background="@drawable/red" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/visibility_1_view_1"/> + + <FrameLayout android:id="@+id/parent" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <view class="com.android.frameworktest.view.VisibilityCallback$MonitoredTextView" + android:id="@+id/victim" + android:background="@drawable/green" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/visibility_1_view_2"/> + </FrameLayout> + + <TextView android:id="@+id/refDown" + android:background="@drawable/blue" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/visibility_1_view_3"/> + + </LinearLayout> + + <LinearLayout + android:orientation="horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <Button android:id="@+id/vis" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/visibility_1_vis"/> + + <Button android:id="@+id/invis" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/visibility_1_invis"/> + + <Button android:id="@+id/gone" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/visibility_1_gone"/> + + </LinearLayout> +</LinearLayout> diff --git a/tests/FrameworkTest/res/layout/weight_sum.xml b/tests/FrameworkTest/res/layout/weight_sum.xml index 249dc68..f8921ec 100644 --- a/tests/FrameworkTest/res/layout/weight_sum.xml +++ b/tests/FrameworkTest/res/layout/weight_sum.xml @@ -22,8 +22,8 @@ android:orientation="horizontal" android:weightSum="1.0" android:gravity="center_horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <Button android:id="@+id/child" android:layout_width="0dip" diff --git a/tests/FrameworkTest/res/layout/with_bitmap_background.xml b/tests/FrameworkTest/res/layout/with_bitmap_background.xml index b32d99e..01605d5 100644 --- a/tests/FrameworkTest/res/layout/with_bitmap_background.xml +++ b/tests/FrameworkTest/res/layout/with_bitmap_background.xml @@ -20,8 +20,8 @@ <LinearLayout android:id="@+id/container" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:background="@drawable/bitmap_drawable"> </LinearLayout> diff --git a/tests/FrameworkTest/res/layout/zero_sized.xml b/tests/FrameworkTest/res/layout/zero_sized.xml index c837bf9..f1c94f8 100644 --- a/tests/FrameworkTest/res/layout/zero_sized.xml +++ b/tests/FrameworkTest/res/layout/zero_sized.xml @@ -22,8 +22,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> <View android:id="@+id/dimension" android:background="#ffff0000" diff --git a/tests/FrameworkTest/src/com/android/frameworktest/expandablelistview/InflatedExpandableListView.java b/tests/FrameworkTest/src/com/android/frameworktest/expandablelistview/InflatedExpandableListView.java index f1089a1..aff0507 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/expandablelistview/InflatedExpandableListView.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/expandablelistview/InflatedExpandableListView.java @@ -65,7 +65,7 @@ public class InflatedExpandableListView extends Activity { public TextView getGenericView() { // Layout parameters for the ExpandableListView AbsListView.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, 64); + ViewGroup.LayoutParams.MATCH_PARENT, 64); TextView textView = new TextView(InflatedExpandableListView.this); textView.setLayoutParams(lp); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/AdjacentVerticalRectLists.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/AdjacentVerticalRectLists.java index c4e2705..09bec2c 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/AdjacentVerticalRectLists.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/AdjacentVerticalRectLists.java @@ -66,11 +66,11 @@ public class AdjacentVerticalRectLists extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.HORIZONTAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, - ViewGroup.LayoutParams.FILL_PARENT, 1); + ViewGroup.LayoutParams.MATCH_PARENT, 1); mLeftColumn = new InternalSelectionView(this, 5, "left column"); mLeftColumn.setLayoutParams(params); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/GoneParentFocusedChild.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/GoneParentFocusedChild.java index 91bd7b4..8f2245f 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/GoneParentFocusedChild.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/GoneParentFocusedChild.java @@ -58,15 +58,15 @@ public class GoneParentFocusedChild extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.HORIZONTAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mGoneGroup = new LinearLayout(this); mGoneGroup.setOrientation(LinearLayout.HORIZONTAL); mGoneGroup.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mButton = new Button(this); mButton.setLayoutParams(new LinearLayout.LayoutParams( diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/HorizontalFocusSearch.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/HorizontalFocusSearch.java index 01a9821..05f05ee 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/HorizontalFocusSearch.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/HorizontalFocusSearch.java @@ -61,8 +61,8 @@ public class HorizontalFocusSearch extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.HORIZONTAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mLeftTall = makeTall("left tall"); mLayout.addView(mLeftTall); @@ -95,7 +95,7 @@ public class HorizontalFocusSearch extends Activity { button.setText(label); button.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT)); return button; } @@ -118,7 +118,7 @@ public class HorizontalFocusSearch extends Activity { ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT)); if (atBottom) { ll.addView(filler); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfEditTexts.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfEditTexts.java index f59e2b7..41a276a 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfEditTexts.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfEditTexts.java @@ -45,14 +45,14 @@ public class ListOfEditTexts extends Activity { mLinearLayout = new LinearLayout(this); mLinearLayout.setOrientation(LinearLayout.VERTICAL); mLinearLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); // add a button above Button buttonAbove = new Button(this); buttonAbove.setLayoutParams( new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); buttonAbove.setText("button above list"); mLinearLayout.addView(buttonAbove); @@ -60,12 +60,12 @@ public class ListOfEditTexts extends Activity { // add a list view to it mListView = new ListView(this); mListView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mListView.setDrawSelectorOnTop(false); mListView.setItemsCanFocus(true); mListView.setLayoutParams((new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f))); @@ -82,7 +82,7 @@ public class ListOfEditTexts extends Activity { Button buttonBelow = new Button(this); buttonBelow.setLayoutParams( new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); buttonBelow.setText("button below list"); mLinearLayout.addView(buttonBelow); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfInternalSelectionViews.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfInternalSelectionViews.java index 4bbca74..6104068 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfInternalSelectionViews.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/ListOfInternalSelectionViews.java @@ -119,8 +119,8 @@ public class ListOfInternalSelectionViews extends Activity { mListView = new ListView(this); mListView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mListView.setDrawSelectorOnTop(false); mListView.setAdapter(new MyAdapter()); mListView.setItemsCanFocus(true); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/focus/VerticalFocusSearch.java b/tests/FrameworkTest/src/com/android/frameworktest/focus/VerticalFocusSearch.java index d1b83a3..a8f12d8 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/focus/VerticalFocusSearch.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/focus/VerticalFocusSearch.java @@ -68,8 +68,8 @@ public class VerticalFocusSearch extends Activity { mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setHorizontalGravity(Gravity.LEFT); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mTopWide = makeWide("top wide"); mLayout.addView(mTopWide); @@ -102,7 +102,7 @@ public class VerticalFocusSearch extends Activity { Button button = new MyButton(this); button.setText(label); button.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); return button; } @@ -133,7 +133,7 @@ public class VerticalFocusSearch extends Activity { LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (atRight) { diff --git a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemISVAndButton.java b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemISVAndButton.java index d6c11b7..ceb94b7 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemISVAndButton.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemISVAndButton.java @@ -47,13 +47,13 @@ public class ListItemISVAndButton extends ListScenario { final InternalSelectionView isv = new InternalSelectionView(context, 8, "ISV postion " + position); isv.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, desiredHeight - 240)); ll.addView(isv); final LinearLayout.LayoutParams buttonLp = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 40); final Button topButton = new Button(context); topButton.setLayoutParams( @@ -63,7 +63,7 @@ public class ListItemISVAndButton extends ListScenario { final TextView filler = new TextView(context); filler.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 200)); filler.setText("filler"); ll.addView(filler); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemsExpandOnSelection.java b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemsExpandOnSelection.java index a137116..b0ad5e9 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemsExpandOnSelection.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListItemsExpandOnSelection.java @@ -44,7 +44,7 @@ public class ListItemsExpandOnSelection extends ListScenario { result.setFocusable(mItemsFocusable); result.setText(getValueAtPosition(position)); final AbsListView.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); result.setLayoutParams(lp); return result; diff --git a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListSetSelection.java b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListSetSelection.java index 87888ca..45d5892 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListSetSelection.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListSetSelection.java @@ -51,7 +51,7 @@ public class ListSetSelection extends ListScenario { }); getListViewContainer().addView(mButton, new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.FILL_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT )); } diff --git a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListViewHeight.java b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListViewHeight.java index 17222d9..1d6d598 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/listview/ListViewHeight.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/listview/ListViewHeight.java @@ -70,14 +70,14 @@ public class ListViewHeight extends Activity { } }); - // Clicking this button will show the list view and set it fill_parent height + // Clicking this button will show the list view and set it match_parent height // If you then hide the views, there is an NPE when calculating the ListView height. mButton2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // set listview to fill screen ViewGroup.MarginLayoutParams lp; lp = (ViewGroup.MarginLayoutParams) mInnerList.getLayoutParams(); - lp.height = lp.FILL_PARENT; + lp.height = lp.MATCH_PARENT; mInnerList.setLayoutParams(lp); // enable list adapter mInnerList.setAdapter(mAdapter); diff --git a/tests/AndroidTests/src/com/android/unit_tests/AndroidTests.java b/tests/FrameworkTest/src/com/android/frameworktest/radiogroup/RadioGroupActivity.java index 4b86add..ac9e870 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/AndroidTests.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/radiogroup/RadioGroupActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 The Android Open Source Project + * 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. @@ -14,19 +14,18 @@ * limitations under the License. */ -package com.android.unit_tests; -import android.test.FrameworkTests; -import android.test.suitebuilder.TestSuiteBuilder; +package com.android.frameworktest.radiogroup; -import junit.framework.TestSuite; +import com.android.frameworktest.R; -public class AndroidTests extends TestSuite { +import android.app.Activity; +import android.os.Bundle; - public static TestSuite suite() { - TestSuiteBuilder suiteBuilder = new TestSuiteBuilder(AndroidTests.class); - TestSuite suite = suiteBuilder.includeAllPackagesUnderHere().build(); - - return suite; +public class RadioGroupActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.radiogroup_checkedchild); } } diff --git a/tests/FrameworkTest/src/com/android/frameworktest/scroll/ScrollViewButtonsAndLabels.java b/tests/FrameworkTest/src/com/android/frameworktest/scroll/ScrollViewButtonsAndLabels.java index 4763ab1..2d3be2e 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/scroll/ScrollViewButtonsAndLabels.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/scroll/ScrollViewButtonsAndLabels.java @@ -70,7 +70,7 @@ public class ScrollViewButtonsAndLabels extends Activity { mLinearLayout = (LinearLayout) findViewById(R.id.layout); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.FILL_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/util/ExpandableListScenario.java b/tests/FrameworkTest/src/com/android/frameworktest/util/ExpandableListScenario.java index f72cbe8..5aa9479 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/util/ExpandableListScenario.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/util/ExpandableListScenario.java @@ -18,7 +18,6 @@ package com.android.frameworktest.util; import java.util.ArrayList; import java.util.List; -import java.util.Random; import android.view.Gravity; import android.view.View; @@ -256,7 +255,7 @@ public abstract class ExpandableListScenario extends ListScenario { result.setHeight(desiredHeight); result.setText(getValueAtPosition(packedPosition)); final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); result.setLayoutParams(lp); result.setGravity(Gravity.CENTER_VERTICAL); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/util/GridScenario.java b/tests/FrameworkTest/src/com/android/frameworktest/util/GridScenario.java index 746cf23..76a1101 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/util/GridScenario.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/util/GridScenario.java @@ -242,8 +242,8 @@ public abstract class GridScenario extends Activity { mGridView = new GridView(this); mGridView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mGridView.setDrawSelectorOnTop(false); if (mNumColumns >= GridView.AUTO_FIT) { mGridView.setNumColumns(mNumColumns); @@ -330,7 +330,7 @@ public abstract class GridScenario extends Activity { result.setHeight(desiredHeight); result.setText(getValueAtPosition(position)); final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); result.setLayoutParams(lp); result.setId(position); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/util/ListItemFactory.java b/tests/FrameworkTest/src/com/android/frameworktest/util/ListItemFactory.java index 4327a8a..2c1cf5b 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/util/ListItemFactory.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/util/ListItemFactory.java @@ -50,7 +50,7 @@ public class ListItemFactory { final LinearLayout.LayoutParams buttonLp = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 50); final Button topButton = new Button(context); @@ -61,7 +61,7 @@ public class ListItemFactory { final TextView middleFiller = new TextView(context); middleFiller.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, desiredHeight - 100)); middleFiller.setText("filler"); ll.addView(middleFiller); @@ -157,7 +157,7 @@ public class ListItemFactory { result.setHeight(desiredHeight); result.setText(text); final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); result.setLayoutParams(lp); result.setId(position); @@ -197,7 +197,7 @@ public class ListItemFactory { result.setHeight(desiredHeight); result.setText(text); final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); result.setLayoutParams(lp); result.setId(position); @@ -239,7 +239,7 @@ public class ListItemFactory { final AbsListView.LayoutParams lp = new AbsListView.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, desiredHeight); ll.setLayoutParams(lp); ll.setId(position); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/util/ListScenario.java b/tests/FrameworkTest/src/com/android/frameworktest/util/ListScenario.java index 5889658..a6ae188 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/util/ListScenario.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/util/ListScenario.java @@ -315,8 +315,8 @@ public abstract class ListScenario extends Activity { mListView = createListView(); mListView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mListView.setDrawSelectorOnTop(false); for (int i=0; i<mHeaderViewCount; i++) { @@ -375,16 +375,16 @@ public abstract class ListScenario extends Activity { mHeaderTextView = new TextView(this); mHeaderTextView.setText("hi"); mHeaderTextView.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mLinearLayout.addView(mHeaderTextView); mLinearLayout.setOrientation(LinearLayout.VERTICAL); mLinearLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mListView.setLayoutParams((new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f))); @@ -394,10 +394,10 @@ public abstract class ListScenario extends Activity { mLinearLayout = new LinearLayout(this); mLinearLayout.setOrientation(LinearLayout.VERTICAL); mLinearLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mListView.setLayoutParams((new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f))); mLinearLayout.addView(mListView); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/util/ScrollViewScenario.java b/tests/FrameworkTest/src/com/android/frameworktest/util/ScrollViewScenario.java index aa17194..daa168d 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/util/ScrollViewScenario.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/util/ScrollViewScenario.java @@ -174,7 +174,7 @@ public abstract class ScrollViewScenario extends Activity { // fill width, equally weighted on height final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, 0, 1f); + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f); for (int i = 0; i < numButtons; i++) { final Button button = new Button(context); button.setText(prefix + i); @@ -240,15 +240,15 @@ public abstract class ScrollViewScenario extends Activity { // create views specified by params for (ViewFactory viewFactory : params.mViewFactories) { final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, (int) (viewFactory.getHeightRatio() * screenHeight)); mLinearLayout.addView(viewFactory.create(this), lp); } mScrollView = createScrollView(); mScrollView.addView(mLinearLayout, new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); // no animation to speed up tests mScrollView.setSmoothScrollingEnabled(false); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/view/BigCache.java b/tests/FrameworkTest/src/com/android/frameworktest/view/BigCache.java index 6f5eb00..52f7a07 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/view/BigCache.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/view/BigCache.java @@ -39,7 +39,7 @@ public class BigCache extends Activity { final LinearLayout testBed = new LinearLayout(this); testBed.setOrientation(LinearLayout.VERTICAL); testBed.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize(); final Display display = getWindowManager().getDefaultDisplay(); @@ -60,7 +60,7 @@ public class BigCache extends Activity { final ScrollView scroller = new ScrollView(this); scroller.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); testBed.addView(tiny); testBed.addView(large); diff --git a/tests/FrameworkTest/src/com/android/frameworktest/view/PreDrawListener.java b/tests/FrameworkTest/src/com/android/frameworktest/view/PreDrawListener.java index cb456b2..e907b24 100644 --- a/tests/FrameworkTest/src/com/android/frameworktest/view/PreDrawListener.java +++ b/tests/FrameworkTest/src/com/android/frameworktest/view/PreDrawListener.java @@ -60,7 +60,7 @@ public class PreDrawListener extends Activity implements OnClickListener { if (mCancelNextDraw) { Button b = new Button(this.getContext()); b.setText("Hello"); - addView(b, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, + addView(b, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mCancelNextDraw = false; return false; diff --git a/tests/FrameworkTest/src/com/android/frameworktest/view/VisibilityCallback.java b/tests/FrameworkTest/src/com/android/frameworktest/view/VisibilityCallback.java new file mode 100644 index 0000000..c601f10 --- /dev/null +++ b/tests/FrameworkTest/src/com/android/frameworktest/view/VisibilityCallback.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworktest.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.widget.TextView; +import com.android.frameworktest.R; + +import android.os.Bundle; +import android.widget.Button; +import android.view.View; +import android.app.Activity; + +/** + * Exercise View's ability to change their visibility: GONE, INVISIBLE and + * VISIBLE. + */ +public class VisibilityCallback extends Activity { + private static final boolean DEBUG = false; + + private MonitoredTextView mVictim; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.visibility_callback); + + // Find the view whose visibility will change + mVictim = (MonitoredTextView)findViewById(R.id.victim); + + // Find our buttons + Button visibleButton = (Button) findViewById(R.id.vis); + Button invisibleButton = (Button) findViewById(R.id.invis); + Button goneButton = (Button) findViewById(R.id.gone); + + // Wire each button to a click listener + visibleButton.setOnClickListener(mVisibleListener); + invisibleButton.setOnClickListener(mInvisibleListener); + goneButton.setOnClickListener(mGoneListener); + } + + + View.OnClickListener mVisibleListener = new View.OnClickListener() { + public void onClick(View v) { + mVictim.setVisibility(View.VISIBLE); + } + }; + + View.OnClickListener mInvisibleListener = new View.OnClickListener() { + public void onClick(View v) { + mVictim.setVisibility(View.INVISIBLE); + } + }; + + View.OnClickListener mGoneListener = new View.OnClickListener() { + public void onClick(View v) { + mVictim.setVisibility(View.GONE); + } + }; + + public static class MonitoredTextView extends TextView { + private View mLastVisChangedView; + private int mLastChangedVisibility; + + public MonitoredTextView(Context context) { + super(context); + } + + public MonitoredTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public MonitoredTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public View getLastVisChangedView() { + return mLastVisChangedView; + } + + public int getLastChangedVisibility() { + return mLastChangedVisibility; + } + + @Override + protected void onVisibilityChanged(View changedView, int visibility) { + mLastVisChangedView = changedView; + mLastChangedVisibility = visibility; + + if (DEBUG) { + Log.d("viewVis", "visibility: " + visibility); + } + } + } +} diff --git a/tests/FrameworkTest/tests/src/android/content/AbstractTableMergerTest.java b/tests/FrameworkTest/tests/src/android/content/AbstractTableMergerTest.java deleted file mode 100644 index a8af7f8..0000000 --- a/tests/FrameworkTest/tests/src/android/content/AbstractTableMergerTest.java +++ /dev/null @@ -1,587 +0,0 @@ -package android.content; - -import com.google.android.collect.Lists; -import com.google.android.collect.Sets; - -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.net.Uri; -import android.test.AndroidTestCase; -import android.text.TextUtils; -import android.accounts.Account; - -import java.util.ArrayList; -import java.util.Map; -import java.util.SortedSet; - -/** Unit test for {@link android.content.AbstractTableMerger}. */ -public class AbstractTableMergerTest extends AndroidTestCase { - MockSyncableContentProvider mRealProvider; - MockSyncableContentProvider mTempProvider; - MockTableMerger mMerger; - MockSyncContext mSyncContext; - - static final String TABLE_NAME = "items"; - static final String DELETED_TABLE_NAME = "deleted_items"; - static final Uri CONTENT_URI = Uri.parse("content://testdata"); - static final Uri TABLE_URI = Uri.withAppendedPath(CONTENT_URI, TABLE_NAME); - static final Uri DELETED_TABLE_URI = Uri.withAppendedPath(CONTENT_URI, DELETED_TABLE_NAME); - - private final Account ACCOUNT = new Account("account@goo.com", "example.type"); - - private final ArrayList<Expectation> mExpectations = Lists.newArrayList(); - - static class Expectation { - enum Type { - UPDATE, - INSERT, - DELETE, - RESOLVE - } - - Type mType; - ContentValues mValues; - Long mLocalRowId; - - Expectation(Type type, Long localRowId, ContentValues values) { - mType = type; - mValues = values; - mLocalRowId = localRowId; - if (type == Type.DELETE) { - assertNull(values); - } else { - assertFalse(values.containsKey("_id")); - } - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mSyncContext = new MockSyncContext(); - mRealProvider = new MockSyncableContentProvider(); - mTempProvider = mRealProvider.getTemporaryInstance(); - mMerger = new MockTableMerger(mRealProvider.getDatabase(), - TABLE_NAME, TABLE_URI, DELETED_TABLE_NAME, DELETED_TABLE_URI); - mExpectations.clear(); - } - - ContentValues newValues(String data, String syncId, Account syncAccount, - String syncTime, String syncVersion, Long syncLocalId) { - ContentValues values = new ContentValues(); - if (data != null) values.put("data", data); - if (syncTime != null) values.put("_sync_time", syncTime); - if (syncVersion != null) values.put("_sync_version", syncVersion); - if (syncId != null) values.put("_sync_id", syncId); - if (syncAccount != null) { - values.put("_sync_account", syncAccount.name); - values.put("_sync_account_type", syncAccount.type); - } - values.put("_sync_local_id", syncLocalId); - values.put("_sync_dirty", 0); - return values; - } - - ContentValues newDeletedValues(String syncId, Account syncAccount, String syncVersion, - Long syncLocalId) { - ContentValues values = new ContentValues(); - if (syncVersion != null) values.put("_sync_version", syncVersion); - if (syncId != null) values.put("_sync_id", syncId); - if (syncAccount != null) { - values.put("_sync_account", syncAccount.name); - values.put("_sync_account_type", syncAccount.type); - } - if (syncLocalId != null) values.put("_sync_local_id", syncLocalId); - return values; - } - - ContentValues newModifyData(String data) { - ContentValues values = new ContentValues(); - values.put("data", data); - values.put("_sync_dirty", 1); - return values; - } - - // Want to test adding, changing, deleting entries to a provider that has extra entries - // before and after the entries being changed. - public void testInsert() { - // add rows to the real provider - // add new row to the temp provider - final ContentValues row1 = newValues("d1", "si1", ACCOUNT, "st1", "sv1", null); - mTempProvider.insert(TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.INSERT, null /* syncLocalId */, row1)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testUpdateWithLocalId() { - // add rows to the real provider - // add new row to the temp provider that matches an unsynced row in the real provider - final ContentValues row1 = newValues("d1", "si1", ACCOUNT, "st1", "sv1", 11L); - mTempProvider.insert(TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.UPDATE, 11L, row1)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testUpdateWithoutLocalId() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - - // add new row to the temp provider that matches an unsynced row in the real provider - final ContentValues row1 = newValues("d2", "si1", ACCOUNT, "st2", "sv2", null); - mTempProvider.insert(TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.UPDATE, ContentUris.parseId(i1), row1)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testResolve() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - mRealProvider.update(TABLE_URI, newModifyData("d2"), null, null); - - // add row to the temp provider that matches a dirty, synced row in the real provider - final ContentValues row1 = newValues("d3", "si1", ACCOUNT, "st2", "sv2", null); - mTempProvider.insert(TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.RESOLVE, ContentUris.parseId(i1), row1)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testResolveWithLocalId() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - mRealProvider.update(TABLE_URI, newModifyData("d2"), null, null); - - // add row to the temp provider that matches a dirty, synced row in the real provider - ContentValues row1 = newValues("d2", "si1", ACCOUNT, "st2", "sv2", ContentUris.parseId(i1)); - mTempProvider.insert(TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.UPDATE, ContentUris.parseId(i1), row1)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testDeleteRowAfterDelete() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - - // add a deleted record to the temp provider - ContentValues row1 = newDeletedValues(null, null, null, ContentUris.parseId(i1)); - mTempProvider.insert(DELETED_TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.DELETE, ContentUris.parseId(i1), null)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testDeleteRowAfterInsert() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, newModifyData("d1")); - - // add a deleted record to the temp provider - ContentValues row1 = newDeletedValues(null, null, null, ContentUris.parseId(i1)); - mTempProvider.insert(DELETED_TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.DELETE, ContentUris.parseId(i1), null)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testDeleteRowAfterUpdate() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - - // add a deleted record to the temp provider - ContentValues row1 = newDeletedValues("si1", ACCOUNT, "sv1", ContentUris.parseId(i1)); - mTempProvider.insert(DELETED_TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.DELETE, ContentUris.parseId(i1), null)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - public void testDeleteRowFromServer() { - // add rows to the real provider - Uri i1 = mRealProvider.insert(TABLE_URI, - newValues("d1", "si1", ACCOUNT, "st1", "sv1", null)); - - // add a deleted record to the temp provider - ContentValues row1 = newDeletedValues("si1", ACCOUNT, "sv1", null); - mTempProvider.insert(DELETED_TABLE_URI, row1); - - // add expected callbacks to merger - mExpectations.add(new Expectation(Expectation.Type.DELETE, ContentUris.parseId(i1), null)); - - // run merger - SyncResult syncResult = new SyncResult(); - mMerger.mergeServerDiffs(mSyncContext, ACCOUNT, mTempProvider, syncResult); - - // check that all expectations were met - assertEquals("not all expectations were met", 0, mExpectations.size()); - } - - class MockTableMerger extends AbstractTableMerger { - public MockTableMerger(SQLiteDatabase database, String table, Uri tableURL, - String deletedTable, Uri deletedTableURL) { - super(database, table, tableURL, deletedTable, deletedTableURL); - } - - public void insertRow(ContentProvider diffs, Cursor diffsCursor) { - Expectation expectation = mExpectations.remove(0); - checkExpectation(expectation, - Expectation.Type.INSERT, null /* syncLocalId */, diffsCursor); - } - - public void updateRow(long localPersonID, ContentProvider diffs, Cursor diffsCursor) { - Expectation expectation = mExpectations.remove(0); - checkExpectation(expectation, Expectation.Type.UPDATE, localPersonID, diffsCursor); - } - - public void resolveRow(long localPersonID, String syncID, ContentProvider diffs, - Cursor diffsCursor) { - Expectation expectation = mExpectations.remove(0); - checkExpectation(expectation, Expectation.Type.RESOLVE, localPersonID, diffsCursor); - } - - @Override - public void deleteRow(Cursor cursor) { - Expectation expectation = mExpectations.remove(0); - assertEquals(expectation.mType, Expectation.Type.DELETE); - assertNotNull(expectation.mLocalRowId); - final long localRowId = cursor.getLong(cursor.getColumnIndexOrThrow("_id")); - assertEquals((long)expectation.mLocalRowId, localRowId); - cursor.moveToNext(); - mDb.delete(TABLE_NAME, "_id=" + localRowId, null); - } - - protected void notifyChanges() { - throw new UnsupportedOperationException(); - } - - void checkExpectation(Expectation expectation, - Expectation.Type actualType, Long localRowId, - Cursor cursor) { - assertEquals(expectation.mType, actualType); - assertEquals(expectation.mLocalRowId, localRowId); - - final SortedSet<String> actualKeys = Sets.newSortedSet(cursor.getColumnNames()); - final SortedSet<String> expectedKeys = Sets.newSortedSet(); - for (Map.Entry<String, Object> entry : expectation.mValues.valueSet()) { - expectedKeys.add(entry.getKey()); - } - actualKeys.remove("_id"); - actualKeys.remove("_sync_mark"); - actualKeys.remove("_sync_local_id"); - expectedKeys.remove("_sync_local_id"); - expectedKeys.remove("_id"); - assertEquals("column mismatch", - TextUtils.join(",", expectedKeys), TextUtils.join(",", actualKeys)); - -// if (localRowId != null) { -// assertEquals((long) localRowId, -// cursor.getLong(cursor.getColumnIndexOrThrow("_sync_local_id"))); -// } else { -// assertTrue("unexpected _sync_local_id, " -// + cursor.getLong(cursor.getColumnIndexOrThrow("_sync_local_id")), -// cursor.isNull(cursor.getColumnIndexOrThrow("_sync_local_id"))); -// } - - for (String name : cursor.getColumnNames()) { - if ("_id".equals(name)) { - continue; - } - if (cursor.isNull(cursor.getColumnIndexOrThrow(name))) { - assertNull(expectation.mValues.getAsString(name)); - } else { - String actualValue = - cursor.getString(cursor.getColumnIndexOrThrow(name)); - assertEquals("mismatch on column " + name, - expectation.mValues.getAsString(name), actualValue); - } - } - } - } - - class MockSyncableContentProvider extends SyncableContentProvider { - SQLiteDatabase mDb; - boolean mIsTemporary; - boolean mContainsDiffs; - - private final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH); - - private static final int MATCHER_ITEMS = 0; - private static final int MATCHER_DELETED_ITEMS = 1; - - public MockSyncableContentProvider() { - mIsTemporary = false; - setContainsDiffs(false); - sURIMatcher.addURI(CONTENT_URI.getAuthority(), "items", MATCHER_ITEMS); - sURIMatcher.addURI(CONTENT_URI.getAuthority(), "deleted_items", MATCHER_DELETED_ITEMS); - - mDb = SQLiteDatabase.create(null); - mDb.execSQL("CREATE TABLE items (" - + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " - + "data TEXT, " - + "_sync_time TEXT, " - + "_sync_version TEXT, " - + "_sync_id TEXT, " - + "_sync_local_id INTEGER, " - + "_sync_dirty INTEGER NOT NULL DEFAULT 0, " - + "_sync_account TEXT, " - + "_sync_account_type TEXT, " - + "_sync_mark INTEGER)"); - - mDb.execSQL("CREATE TABLE deleted_items (" - + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " - + "_sync_version TEXT, " - + "_sync_id TEXT, " - + "_sync_local_id INTEGER, " - + "_sync_account TEXT, " - + "_sync_account_type TEXT, " - + "_sync_mark INTEGER)"); - } - - public boolean onCreate() { - throw new UnsupportedOperationException(); - } - - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, - String sortOrder) { - int match = sURIMatcher.match(uri); - switch (match) { - case MATCHER_ITEMS: - return mDb.query(TABLE_NAME, projection, selection, selectionArgs, - null, null, sortOrder); - case MATCHER_DELETED_ITEMS: - return mDb.query(DELETED_TABLE_NAME, projection, selection, selectionArgs, - null, null, sortOrder); - default: - throw new UnsupportedOperationException("Cannot query URL: " + uri); - } - } - - public String getType(Uri uri) { - throw new UnsupportedOperationException(); - } - - public Uri insert(Uri uri, ContentValues values) { - int match = sURIMatcher.match(uri); - switch (match) { - case MATCHER_ITEMS: { - long id = mDb.insert(TABLE_NAME, "_id", values); - return CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(); - } - case MATCHER_DELETED_ITEMS: { - long id = mDb.insert(DELETED_TABLE_NAME, "_id", values); - return CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(); - } - default: - throw new UnsupportedOperationException("Cannot query URL: " + uri); - } - } - - public int delete(Uri uri, String selection, String[] selectionArgs) { - int match = sURIMatcher.match(uri); - switch (match) { - case MATCHER_ITEMS: - return mDb.delete(TABLE_NAME, selection, selectionArgs); - case MATCHER_DELETED_ITEMS: - return mDb.delete(DELETED_TABLE_NAME, selection, selectionArgs); - default: - throw new UnsupportedOperationException("Cannot query URL: " + uri); - } - } - - public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - int match = sURIMatcher.match(uri); - switch (match) { - case MATCHER_ITEMS: - return mDb.update(TABLE_NAME, values, selection, selectionArgs); - case MATCHER_DELETED_ITEMS: - return mDb.update(DELETED_TABLE_NAME, values, selection, selectionArgs); - default: - throw new UnsupportedOperationException("Cannot query URL: " + uri); - } - } - - protected boolean isTemporary() { - return mIsTemporary; - } - - public void close() { - throw new UnsupportedOperationException(); - } - - protected void bootstrapDatabase(SQLiteDatabase db) { - throw new UnsupportedOperationException(); - } - - protected boolean upgradeDatabase(SQLiteDatabase db, int oldVersion, int newVersion) { - throw new UnsupportedOperationException(); - } - - protected void onDatabaseOpened(SQLiteDatabase db) { - throw new UnsupportedOperationException(); - } - - public MockSyncableContentProvider getTemporaryInstance() { - MockSyncableContentProvider temp = new MockSyncableContentProvider(); - temp.mIsTemporary = true; - temp.setContainsDiffs(true); - return temp; - } - - public SQLiteDatabase getDatabase() { - return mDb; - } - - public boolean getContainsDiffs() { - return mContainsDiffs; - } - - public void setContainsDiffs(boolean containsDiffs) { - mContainsDiffs = containsDiffs; - } - - protected Iterable<? extends AbstractTableMerger> getMergers() { - throw new UnsupportedOperationException(); - } - - public boolean changeRequiresLocalSync(Uri uri) { - throw new UnsupportedOperationException(); - } - - public void onSyncStart(SyncContext context, Account account) { - throw new UnsupportedOperationException(); - } - - public void onSyncStop(SyncContext context, boolean success) { - throw new UnsupportedOperationException(); - } - - public Account getSyncingAccount() { - throw new UnsupportedOperationException(); - } - - public void merge(SyncContext context, SyncableContentProvider diffs, - TempProviderSyncResult result, SyncResult syncResult) { - throw new UnsupportedOperationException(); - } - - public void onSyncCanceled() { - throw new UnsupportedOperationException(); - } - - public boolean isMergeCancelled() { - return false; - } - - protected int updateInternal(Uri url, ContentValues values, String selection, - String[] selectionArgs) { - throw new UnsupportedOperationException(); - } - - protected int deleteInternal(Uri url, String selection, String[] selectionArgs) { - throw new UnsupportedOperationException(); - } - - protected Uri insertInternal(Uri url, ContentValues values) { - throw new UnsupportedOperationException(); - } - - protected Cursor queryInternal(Uri url, String[] projection, String selection, - String[] selectionArgs, String sortOrder) { - throw new UnsupportedOperationException(); - } - - protected void onAccountsChanged(Account[] accountsArray) { - throw new UnsupportedOperationException(); - } - - protected void deleteRowsForRemovedAccounts(Map<Account, Boolean> accounts, String table - ) { - throw new UnsupportedOperationException(); - } - - public void wipeAccount(Account account) { - throw new UnsupportedOperationException(); - } - - public byte[] readSyncDataBytes(Account account) { - throw new UnsupportedOperationException(); - } - - public void writeSyncDataBytes(Account account, byte[] data) { - throw new UnsupportedOperationException(); - } - } - - class MockSyncContext extends SyncContext { - public MockSyncContext() { - super(null); - } - - @Override - public void setStatusText(String message) { - } - } -} diff --git a/tests/FrameworkTest/tests/src/android/widget/AutoCompleteTextViewCallbacks.java b/tests/FrameworkTest/tests/src/android/widget/AutoCompleteTextViewCallbacks.java index 29000dd..1b81c98 100644 --- a/tests/FrameworkTest/tests/src/android/widget/AutoCompleteTextViewCallbacks.java +++ b/tests/FrameworkTest/tests/src/android/widget/AutoCompleteTextViewCallbacks.java @@ -42,6 +42,7 @@ public class AutoCompleteTextViewCallbacks textView.requestFocus(); instrumentation.waitForIdleSync(); sendKeys("A"); + instrumentation.waitForIdleSync(); // give UI time to settle Thread.sleep(WAIT_TIME); @@ -58,7 +59,7 @@ public class AutoCompleteTextViewCallbacks /** Test that arrow-down into the popup calls the onSelected callback. */ @FlakyTest(tolerance=3) public void testPopupEnterSelection() throws Exception { - AutoCompleteTextViewSimple theActivity = getActivity(); + final AutoCompleteTextViewSimple theActivity = getActivity(); AutoCompleteTextView textView = theActivity.getTextView(); final Instrumentation instrumentation = getInstrumentation(); @@ -67,9 +68,15 @@ public class AutoCompleteTextViewCallbacks instrumentation.waitForIdleSync(); sendKeys("A"); - // prepare to move down into the popup - theActivity.resetItemListeners(); + textView.post(new Runnable() { + public void run() { + // prepare to move down into the popup + theActivity.resetItemListeners(); + } + }); + sendKeys("DPAD_DOWN"); + instrumentation.waitForIdleSync(); // give UI time to settle Thread.sleep(WAIT_TIME); @@ -79,9 +86,15 @@ public class AutoCompleteTextViewCallbacks assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition); assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled); - // try one more time - should move from 0 to 1 - theActivity.resetItemListeners(); + textView.post(new Runnable() { + public void run() { + // try one more time - should move from 0 to 1 + theActivity.resetItemListeners(); + } + }); + sendKeys("DPAD_DOWN"); + instrumentation.waitForIdleSync(); // give UI time to settle Thread.sleep(WAIT_TIME); @@ -95,7 +108,7 @@ public class AutoCompleteTextViewCallbacks /** Test that arrow-up out of the popup calls the onNothingSelected callback */ @FlakyTest(tolerance=3) public void testPopupLeaveSelection() { - AutoCompleteTextViewSimple theActivity = getActivity(); + final AutoCompleteTextViewSimple theActivity = getActivity(); AutoCompleteTextView textView = theActivity.getTextView(); final Instrumentation instrumentation = getInstrumentation(); @@ -103,13 +116,21 @@ public class AutoCompleteTextViewCallbacks textView.requestFocus(); instrumentation.waitForIdleSync(); sendKeys("A"); + instrumentation.waitForIdleSync(); // move down into the popup sendKeys("DPAD_DOWN"); + instrumentation.waitForIdleSync(); + + textView.post(new Runnable() { + public void run() { + // prepare to move down into the popup + theActivity.resetItemListeners(); + } + }); - // now move back up out of the popup - theActivity.resetItemListeners(); sendKeys("DPAD_UP"); + instrumentation.waitForIdleSync(); // now check for selection callbacks. assertFalse("onItemClick should not be called", theActivity.mItemClickCalled); diff --git a/tests/FrameworkTest/tests/src/android/widget/SimpleCursorAdapterTest.java b/tests/FrameworkTest/tests/src/android/widget/SimpleCursorAdapterTest.java index 58f4ccb..7726f02 100644 --- a/tests/FrameworkTest/tests/src/android/widget/SimpleCursorAdapterTest.java +++ b/tests/FrameworkTest/tests/src/android/widget/SimpleCursorAdapterTest.java @@ -16,7 +16,7 @@ package android.widget; -import com.android.internal.database.ArrayListCursor; +import com.android.common.ArrayListCursor; import com.google.android.collect.Lists; import android.content.Context; diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/expandablelistview/ExpandableListWithHeadersTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/expandablelistview/ExpandableListWithHeadersTest.java deleted file mode 100644 index 49b5106..0000000 --- a/tests/FrameworkTest/tests/src/com/android/frameworktest/expandablelistview/ExpandableListWithHeadersTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.frameworktest.expandablelistview; - -import android.test.ActivityInstrumentationTestCase; -import android.test.suitebuilder.annotation.LargeTest; -import android.test.suitebuilder.annotation.MediumTest; -import android.view.KeyEvent; -import android.widget.ExpandableListView; - -import com.android.frameworktest.expandablelistview.ExpandableListWithHeaders; -import com.android.frameworktest.util.ListUtil; - -public class ExpandableListWithHeadersTest extends ActivityInstrumentationTestCase<ExpandableListWithHeaders> { - private ExpandableListView mExpandableListView; - private ListUtil mListUtil; - - public ExpandableListWithHeadersTest() { - super("com.android.frameworktest", - ExpandableListWithHeaders.class); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - - mExpandableListView = getActivity().getExpandableListView(); - mListUtil = new ListUtil(mExpandableListView, getInstrumentation()); - } - - @MediumTest - public void testPreconditions() { - assertNotNull(mExpandableListView); - } - - @MediumTest - public void testExpandOnFirstPosition() { - // Should be a header, and hence the first group should NOT have expanded - mListUtil.arrowScrollToSelectedPosition(0); - sendKeys(KeyEvent.KEYCODE_DPAD_CENTER); - getInstrumentation().waitForIdleSync(); - assertFalse(mExpandableListView.isGroupExpanded(0)); - } - - @LargeTest - public void testExpandOnFirstGroup() { - mListUtil.arrowScrollToSelectedPosition(getActivity().getNumOfHeadersAndFooters()); - sendKeys(KeyEvent.KEYCODE_DPAD_CENTER); - getInstrumentation().waitForIdleSync(); - assertTrue(mExpandableListView.isGroupExpanded(0)); - } -} diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java index cc8fa6e..d11a39ba 100644 --- a/tests/FrameworkTest/tests/src/com/android/frameworktest/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java +++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java @@ -16,6 +16,7 @@ package com.android.frameworktest.gridview.touch; +import android.content.Context; import android.test.ActivityInstrumentationTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; @@ -30,6 +31,7 @@ import com.android.frameworktest.gridview.GridVerticalSpacingStackFromBottom; public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrumentationTestCase<GridVerticalSpacingStackFromBottom> { private GridVerticalSpacingStackFromBottom mActivity; private GridView mGridView; + private ViewConfiguration mViewConfig; public GridTouchVerticalSpacingStackFromBottomTest() { super("com.android.frameworktest", GridVerticalSpacingStackFromBottom.class); @@ -41,6 +43,8 @@ public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrum mActivity = getActivity(); mGridView = getActivity().getGridView(); + final Context context = mActivity.getApplicationContext(); + mViewConfig = ViewConfiguration.get(context); } @MediumTest @@ -83,7 +87,7 @@ public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrum int lastTop = lastChild.getTop(); TouchUtils.dragViewBy(this, firstChild, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, - ViewConfiguration.getTouchSlop() + 1 + 10); + mViewConfig.getScaledTouchSlop() + 1 + 10); View newLastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); @@ -107,7 +111,7 @@ public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrum (int) (mActivity.getWindowManager().getDefaultDisplay().getHeight() * 0.75f)); assertEquals("View scrolled to wrong position", firstTop - + (distance - ViewConfiguration.getTouchSlop() - 1), firstChild.getTop()); + + (distance - mViewConfig.getScaledTouchSlop() - 1), firstChild.getTop()); } @LargeTest diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/radiogroup/RadioGroupPreCheckedTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/radiogroup/RadioGroupPreCheckedTest.java new file mode 100644 index 0000000..8771830 --- /dev/null +++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/radiogroup/RadioGroupPreCheckedTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworktest.radiogroup; + +import android.test.TouchUtils; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import com.android.frameworktest.R; + +import android.test.ActivityInstrumentationTestCase2; +import android.test.suitebuilder.annotation.LargeTest; + +/** + * Exercises {@link android.widget.RadioGroup}'s check feature. + */ +public class RadioGroupPreCheckedTest extends ActivityInstrumentationTestCase2<RadioGroupActivity> { + public RadioGroupPreCheckedTest() { + super("com.android.frameworktest", RadioGroupActivity.class); + } + + @LargeTest + public void testRadioButtonPreChecked() throws Exception { + final RadioGroupActivity activity = getActivity(); + + RadioButton radio = (RadioButton) activity.findViewById(R.id.value_one); + assertTrue("The first radio button should be checked", radio.isChecked()); + + RadioGroup group = (RadioGroup) activity.findViewById(R.id.group); + assertEquals("The first radio button should be checked", R.id.value_one, + group.getCheckedRadioButtonId()); + } + + @LargeTest + public void testRadioButtonChangePreChecked() throws Exception { + final RadioGroupActivity activity = getActivity(); + + RadioButton radio = (RadioButton) activity.findViewById(R.id.value_two); + TouchUtils.clickView(this, radio); + + RadioButton old = (RadioButton) activity.findViewById(R.id.value_one); + + assertFalse("The first radio button should not be checked", old.isChecked()); + assertTrue("The second radio button should be checked", radio.isChecked()); + + RadioGroup group = (RadioGroup) activity.findViewById(R.id.group); + assertEquals("The second radio button should be checked", R.id.value_two, + group.getCheckedRadioButtonId()); + } +} diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java deleted file mode 100644 index 3dcb252..0000000 --- a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.frameworktest.view; - -import android.os.Parcel; -import android.test.ActivityInstrumentationTestCase; -import android.test.suitebuilder.annotation.MediumTest; -import android.view.InflateException; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RemoteViews; - -import com.android.frameworktest.R; -import com.android.frameworktest.view.RemoteViewsActivity; - -public class RemoteViewsActivityTest extends ActivityInstrumentationTestCase<RemoteViewsActivity> { - public RemoteViewsActivityTest() { - super("com.android.frameworktest", RemoteViewsActivity.class); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - } - - @MediumTest - public void testGood() throws Exception { - final RemoteViewsActivity activity = getActivity(); - - RemoteViews orig = new RemoteViews("com.android.frameworktest", - R.layout.remote_view_test_good); - Parcel p = Parcel.obtain(); - orig.writeToParcel(p, 0); - p.setDataPosition(0); - - RemoteViews r = RemoteViews.CREATOR.createFromParcel(p); - - ViewGroup parent = (ViewGroup) activity.findViewById(R.id.parent); - - View result = r.apply(activity, parent); - - p.recycle(); - - assertTrue("LinearLayout not inflated", result.findViewById(R.id.linear) != null); - assertTrue("TextView not inflated", result.findViewById(R.id.text) != null); - assertTrue("ImageView not inflated", result.findViewById(R.id.image) != null); - assertTrue("FrameLayout not inflated", result.findViewById(R.id.frame) != null); - assertTrue("RelateiveLayout not inflated", result.findViewById(R.id.relative) != null); - assertTrue("AbsoluteLayout not inflated", result.findViewById(R.id.absolute) != null); - assertTrue("ProgressBar not inflated", result.findViewById(R.id.progress) != null); - assertTrue("ImageButton not inflated", result.findViewById(R.id.image_button) != null); - assertTrue("Button not inflated", result.findViewById(R.id.button) != null); - } - - @MediumTest - public void testDerivedClass() throws Exception { - final RemoteViewsActivity activity = getActivity(); - - RemoteViews orig = new RemoteViews("com.android.frameworktest", - R.layout.remote_view_test_bad_1); - Parcel p = Parcel.obtain(); - orig.writeToParcel(p, 0); - p.setDataPosition(0); - - RemoteViews r = RemoteViews.CREATOR.createFromParcel(p); - - ViewGroup parent = (ViewGroup) activity.findViewById(R.id.parent); - - boolean exceptionThrown = false; - View result = null; - - try { - result = r.apply(activity, parent); - } catch (InflateException e) { - exceptionThrown = true; - } - - p.recycle(); - - assertTrue("Derived class (EditText) allowed to be inflated", exceptionThrown); - assertNull("Derived class (EditText) allowed to be inflated", result); - } - - @MediumTest - public void testWebView() throws Exception { - final RemoteViewsActivity activity = getActivity(); - - RemoteViews orig = new RemoteViews("com.android.frameworktest", - R.layout.remote_view_test_bad_2); - Parcel p = Parcel.obtain(); - orig.writeToParcel(p, 0); - p.setDataPosition(0); - - RemoteViews r = RemoteViews.CREATOR.createFromParcel(p); - - ViewGroup parent = (ViewGroup) activity.findViewById(R.id.parent); - - boolean exceptionThrown = false; - View result = null; - - try { - result = r.apply(activity, parent); - } catch (InflateException e) { - exceptionThrown = true; - } - - p.recycle(); - - assertTrue("WebView allowed to be inflated", exceptionThrown); - assertNull("WebView allowed to be inflated", result); - } -} diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/ViewGroupChildrenTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/ViewGroupChildrenTest.java index fceec51..a6007e1 100644 --- a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/ViewGroupChildrenTest.java +++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/ViewGroupChildrenTest.java @@ -260,7 +260,7 @@ public class ViewGroupChildrenTest extends ActivityInstrumentationTestCase<ViewG TextView view = new TextView(getActivity()); view.setText(text); view.setLayoutParams(new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.FILL_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT )); return view; diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/VisibilityCallbackTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/VisibilityCallbackTest.java new file mode 100644 index 0000000..6bef230 --- /dev/null +++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/VisibilityCallbackTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.frameworktest.view; + +import android.test.ActivityInstrumentationTestCase2; +import android.test.UiThreadTest; +import android.test.suitebuilder.annotation.MediumTest; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import com.android.frameworktest.R; + +/** + * Exercises {@link android.view.View}'s ability to change visibility between + * GONE, VISIBLE and INVISIBLE. + */ +public class VisibilityCallbackTest extends ActivityInstrumentationTestCase2<VisibilityCallback> { + private TextView mRefUp; + private TextView mRefDown; + private VisibilityCallback.MonitoredTextView mVictim; + private ViewGroup mParent; + private Button mVisible; + private Button mInvisible; + private Button mGone; + + public VisibilityCallbackTest() { + super("com.android.frameworktest", VisibilityCallback.class); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + + final VisibilityCallback a = getActivity(); + mRefUp = (TextView) a.findViewById(R.id.refUp); + mRefDown = (TextView) a.findViewById(R.id.refDown); + mVictim = (VisibilityCallback.MonitoredTextView) a.findViewById(R.id.victim); + mParent = (ViewGroup) a.findViewById(R.id.parent); + mVisible = (Button) a.findViewById(R.id.vis); + mInvisible = (Button) a.findViewById(R.id.invis); + mGone = (Button) a.findViewById(R.id.gone); + + mVictim.post(new Runnable() { + public void run() { + mVictim.setVisibility(View.INVISIBLE); + } + }); + getInstrumentation().waitForIdleSync(); + } + + @MediumTest + @UiThreadTest + public void testSetUpConditions() throws Exception { + assertNotNull(mRefUp); + assertNotNull(mRefDown); + assertNotNull(mVictim); + assertNotNull(mVisible); + assertNotNull(mInvisible); + assertNotNull(mGone); + + assertTrue(mVisible.hasFocus()); + assertEquals(View.INVISIBLE, mVictim.getVisibility()); + assertEquals(View.VISIBLE, mParent.getVisibility()); + } + + @MediumTest + @UiThreadTest + public void testDirect() throws Exception { + mVictim.setVisibility(View.VISIBLE); + assertEquals(View.VISIBLE, mVictim.getLastChangedVisibility()); + assertEquals(mVictim, mVictim.getLastVisChangedView()); + + mVictim.setVisibility(View.INVISIBLE); + assertEquals(View.INVISIBLE, mVictim.getLastChangedVisibility()); + assertEquals(mVictim, mVictim.getLastVisChangedView()); + + mVictim.setVisibility(View.GONE); + assertEquals(View.GONE, mVictim.getLastChangedVisibility()); + assertEquals(mVictim, mVictim.getLastVisChangedView()); + } + + @MediumTest + @UiThreadTest + public void testChild() throws Exception { + mParent.setVisibility(View.INVISIBLE); + assertEquals(View.INVISIBLE, mVictim.getLastChangedVisibility()); + assertEquals(mParent, mVictim.getLastVisChangedView()); + + mParent.setVisibility(View.GONE); + assertEquals(View.GONE, mVictim.getLastChangedVisibility()); + assertEquals(mParent, mVictim.getLastVisChangedView()); + + mParent.setVisibility(View.VISIBLE); + assertEquals(View.VISIBLE, mVictim.getLastChangedVisibility()); + assertEquals(mParent, mVictim.getLastVisChangedView()); + } +} diff --git a/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml index e8ffa1c..1a2b7eb 100644 --- a/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml +++ b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml @@ -15,21 +15,21 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:padding="20dip" android:orientation="vertical"> <View android:id="@+id/blank" android:layout_height="0dip" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_weight="1"/> <EditText android:id="@+id/dialog_edit_text" android:layout_height="wrap_content" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:scrollHorizontally="true" android:textAppearance="?android:attr/textAppearanceMedium" /> diff --git a/tests/ImfTest/res/layout/full_screen_edit_text.xml b/tests/ImfTest/res/layout/full_screen_edit_text.xml index f22aa2f..e760ac1 100755 --- a/tests/ImfTest/res/layout/full_screen_edit_text.xml +++ b/tests/ImfTest/res/layout/full_screen_edit_text.xml @@ -20,8 +20,8 @@ <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/data" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:minLines="15" android:gravity="top"/> diff --git a/tests/ImfTest/res/layout/one_edit_text_activity.xml b/tests/ImfTest/res/layout/one_edit_text_activity.xml index 09925e1..0558228 100755 --- a/tests/ImfTest/res/layout/one_edit_text_activity.xml +++ b/tests/ImfTest/res/layout/one_edit_text_activity.xml @@ -18,32 +18,32 @@ */ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical" android:baselineAligned="false"> <View android:id="@+id/blank" android:layout_height="0dip" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_weight="1" /> <EditText android:id="@+id/dialog_edit_text" android:layout_height="wrap_content" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:scrollHorizontally="true" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> <View - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="1dip" android:background="@android:drawable/divider_horizontal_dark" /> diff --git a/tests/ImfTest/res/layout/sample_edit_text.xml b/tests/ImfTest/res/layout/sample_edit_text.xml index 99a5cf8..3ff6767 100755 --- a/tests/ImfTest/res/layout/sample_edit_text.xml +++ b/tests/ImfTest/res/layout/sample_edit_text.xml @@ -18,12 +18,12 @@ */ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:orientation="horizontal" @@ -46,7 +46,7 @@ </LinearLayout> <View - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="1dip" android:background="@android:drawable/divider_horizontal_dark" /> diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java index 9754381..21734a6 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java @@ -7,9 +7,7 @@ import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.ScrollView; public class BigEditTextActivityNonScrollablePanScan extends Activity { @@ -25,8 +23,8 @@ public class BigEditTextActivityNonScrollablePanScan extends Activity { mRootView = new LinearLayout(this); ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); mRootView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); View view = getLayoutInflater().inflate( R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false); diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java index 701795f..48287fb 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java @@ -7,9 +7,7 @@ import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.ScrollView; public class BigEditTextActivityNonScrollableResize extends Activity { @@ -25,8 +23,8 @@ public class BigEditTextActivityNonScrollableResize extends Activity { mRootView = new LinearLayout(this); ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); mRootView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); View view = getLayoutInflater().inflate( R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false); diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java index bb3f767..48e1359 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java @@ -7,7 +7,6 @@ import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ScrollView; @@ -26,14 +25,14 @@ public class BigEditTextActivityScrollablePanScan extends Activity { mRootView = new ScrollView(this); ((ScrollView) mRootView).setFillViewport(true); mRootView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); View view = getLayoutInflater().inflate( R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java index f2cae1c..d51e8a7 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java @@ -7,7 +7,6 @@ import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ScrollView; @@ -26,14 +25,14 @@ public class BigEditTextActivityScrollableResize extends Activity { mRootView = new ScrollView(this); ((ScrollView) mRootView).setFillViewport(true); mRootView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); View view = getLayoutInflater().inflate( R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); diff --git a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java index e49301c..f65e1fd 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java +++ b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java @@ -2,18 +2,14 @@ package com.android.imftest.samples; import android.app.Activity; import android.os.Bundle; -import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.EditText; import android.widget.Button; import android.view.LayoutInflater; import android.app.Dialog; -import com.android.internal.R; - public class DialogActivity extends Activity { private static final int DIALOG_WITHOUT_EDITTEXT = 0; @@ -34,8 +30,8 @@ public class DialogActivity extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mButton1 = new Button(this); mButton1.setText("Dialog WITHOUT EditText");//(R.string.open_dialog_scrollable); diff --git a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java index bd1e934..d4726fc 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java +++ b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java @@ -3,7 +3,6 @@ package com.android.imftest.samples; import com.android.imftest.R; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.os.Bundle; import android.view.LayoutInflater; @@ -33,8 +32,8 @@ public class EditTextActivityDialog extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mButton1 = new Button(this); mButton1.setText(R.string.open_dialog_scrollable); diff --git a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java index 17f6bdc..25ac2f0 100755 --- a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java +++ b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java @@ -21,17 +21,13 @@ import com.android.imftest.R; import android.app.Activity; import android.widget.EditText; import android.widget.LinearLayout; -import android.widget.Button; import android.widget.ScrollView; import android.widget.TextView; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewParent; -import android.view.ViewRoot; import android.view.inputmethod.EditorInfo; -import android.content.Context; public class InputTypeActivity extends Activity { @@ -49,8 +45,8 @@ public class InputTypeActivity extends Activity { mLayout = new LinearLayout(this); mLayout.setOrientation(LinearLayout.VERTICAL); mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); mInflater = getLayoutInflater(); mParent = mLayout; diff --git a/tests/LowStorageTest/res/layout/main.xml b/tests/LowStorageTest/res/layout/main.xml index cc99102..f1cc680 100644 --- a/tests/LowStorageTest/res/layout/main.xml +++ b/tests/LowStorageTest/res/layout/main.xml @@ -14,8 +14,8 @@ limitations under the License. --> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" + android:layout_width="match_parent" + android:layout_height="match_parent" android:stretchColumns="1"> <TextView diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java index 85b91f1..5f53a9b 100644 --- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java +++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java @@ -20,7 +20,6 @@ import com.android.internal.os.RuntimeInit; import android.app.ActivityManager; import android.content.Context; -import android.server.data.CrashData; import android.test.AndroidTestCase; import android.util.Log; @@ -91,25 +90,12 @@ public class ProcessErrorsTest extends AndroidTestCase { break; default: condition = "<unknown>"; - break; - } - - String stackTrace = null; - try { - if (entry.crashData != null) { - CrashData cd = RuntimeInit.unmarshallException(entry.crashData); - stackTrace = cd.toString(); - } - } catch (RuntimeException e) { } - if (stackTrace == null) { - stackTrace = "<no stack trace>"; + break; } - final String entryReport = "Process error " + condition + " " + entry.shortMsg + - " detected in " + entry.processName + " " + entry.tag + - ". \n" + stackTrace; - - builder.append(entryReport).append(" "); + builder.append("Process error ").append(condition).append(" "); + builder.append(" ").append(entry.shortMsg); + builder.append(" detected in ").append(entry.processName).append(" ").append(entry.tag); } return builder.toString(); } diff --git a/tests/SslLoad/src/com/android/sslload/SslLoad.java b/tests/SslLoad/src/com/android/sslload/SslLoad.java index 9a08024..1470d48 100644 --- a/tests/SslLoad/src/com/android/sslload/SslLoad.java +++ b/tests/SslLoad/src/com/android/sslload/SslLoad.java @@ -34,8 +34,8 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; -import android.net.http.AndroidHttpClient; import android.util.Log; +import com.android.common.AndroidHttpClient; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; diff --git a/tests/StatusBar/res/layout/chrono_notification.xml b/tests/StatusBar/res/layout/chrono_notification.xml index 913a860..98a9fdd 100644 --- a/tests/StatusBar/res/layout/chrono_notification.xml +++ b/tests/StatusBar/res/layout/chrono_notification.xml @@ -1,12 +1,12 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="80sp" android:orientation="horizontal" > <LinearLayout android:layout_width="wrap_content" - android:layout_height="fill_parent" + android:layout_height="match_parent" android:layout_weight="0" android:orientation="vertical" > diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java index f2ddd0f..ffc2cbc 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java @@ -121,6 +121,20 @@ public class NotificationTestList extends TestActivity } }, + new Test("Times") { + public void run() + { + long now = System.currentTimeMillis(); + + timeNotification(7, "24 hours from now", now+(1000*60*60*24)); + timeNotification(6, "12:01:00 from now", now+(1000*60*60*12)+(60*1000)); + timeNotification(5, "12 hours from now", now+(1000*60*60*12)); + timeNotification(4, "now", now); + timeNotification(3, "11:59:00 ago", now-((1000*60*60*12)-(60*1000))); + timeNotification(2, "12 hours ago", now-(1000*60*60*12)); + timeNotification(1, "24 hours ago", now-(1000*60*60*24)); + } + }, new StateStress("Stress - Ongoing / Latest", 100, 100, new Runnable[] { new Runnable() { public void run() { @@ -590,5 +604,12 @@ public class NotificationTestList extends TestActivity mHandler.postDelayed(mRunnable, mPause); } } + + void timeNotification(int n, String label, long time) { + mNM.notify(n, new Notification(NotificationTestList.this, + R.drawable.ic_statusbar_missedcall, null, + time, label, "" + new java.util.Date(time), null)); + + } } diff --git a/tests/appwidgets/AppWidgetHostTest/Android.mk b/tests/appwidgets/AppWidgetHostTest/Android.mk index 1bb1e54..4d0c704 100644 --- a/tests/appwidgets/AppWidgetHostTest/Android.mk +++ b/tests/appwidgets/AppWidgetHostTest/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := user +LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-subdir-java-files) diff --git a/tests/appwidgets/AppWidgetHostTest/res/layout/appwidget_host.xml b/tests/appwidgets/AppWidgetHostTest/res/layout/appwidget_host.xml index e5c3b28..88c6488 100644 --- a/tests/appwidgets/AppWidgetHostTest/res/layout/appwidget_host.xml +++ b/tests/appwidgets/AppWidgetHostTest/res/layout/appwidget_host.xml @@ -16,8 +16,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" > + android:layout_width="match_parent" + android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" @@ -26,7 +26,7 @@ /> <ScrollView - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > diff --git a/tests/appwidgets/AppWidgetHostTest/res/layout/test_appwidget_configure.xml b/tests/appwidgets/AppWidgetHostTest/res/layout/test_appwidget_configure.xml index 0d9b983..a0f9cc2 100644 --- a/tests/appwidgets/AppWidgetHostTest/res/layout/test_appwidget_configure.xml +++ b/tests/appwidgets/AppWidgetHostTest/res/layout/test_appwidget_configure.xml @@ -15,21 +15,21 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/oh_hai_text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/oh_hai" /> <EditText android:id="@+id/edit_text" - android:layout_width="fill_parent" + android:layout_width="match_parent" android:layout_height="wrap_content" /> diff --git a/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java b/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java index 2fb2d1d..bb0fa60 100644 --- a/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java +++ b/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java @@ -129,7 +129,7 @@ public class AppWidgetHostActivity extends Activity // Add it to the list LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.FILL_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mAppWidgetContainer.addView(view, layoutParams); diff --git a/tests/appwidgets/AppWidgetProviderTest/Android.mk b/tests/appwidgets/AppWidgetProviderTest/Android.mk index c87a0f2..6084fb9 100644 --- a/tests/appwidgets/AppWidgetProviderTest/Android.mk +++ b/tests/appwidgets/AppWidgetProviderTest/Android.mk @@ -1,7 +1,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := user +LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-subdir-java-files) diff --git a/tests/framework-tests/src/android/test/FrameworkTests.java b/tests/framework-tests/src/android/test/FrameworkTests.java index b5f6292..623e294 100644 --- a/tests/framework-tests/src/android/test/FrameworkTests.java +++ b/tests/framework-tests/src/android/test/FrameworkTests.java @@ -1,8 +1,6 @@ package android.test; import com.android.internal.os.LoggingPrintStreamTest; -import android.util.EventLogFunctionalTest; -import android.util.EventLogTest; import junit.framework.TestSuite; import com.android.internal.http.multipart.MultipartTest; import com.android.internal.policy.impl.LockPatternKeyguardViewTest; @@ -18,8 +16,6 @@ public class FrameworkTests { TestSuite suite = new TestSuite(FrameworkTests.class.getName()); suite.addTestSuite(MultipartTest.class); - suite.addTestSuite(EventLogTest.class); - suite.addTestSuite(EventLogFunctionalTest.class); suite.addTestSuite(LoggingPrintStreamTest.class); suite.addTestSuite(LockPatternKeyguardViewTest.class); diff --git a/tests/framework-tests/src/android/util/EventLogFunctionalTest.java b/tests/framework-tests/src/android/util/EventLogFunctionalTest.java deleted file mode 100644 index 8263083..0000000 --- a/tests/framework-tests/src/android/util/EventLogFunctionalTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.util; - -import android.os.Process; - -import com.google.android.collect.Lists; - -import junit.framework.TestCase; -import junit.framework.Assert; - -import java.util.ArrayList; - -/** - * Functional tests of EventLog. - */ - -public class EventLogFunctionalTest extends TestCase { - private static final String TAG = "EventLogFunctionalTest"; - - private static final int TAG_SIZE = 4; - private static final int TYPE_FIELD_SIZE = 1; - private static final int STARTING_POS_OF_PAYLOAD = TAG_SIZE + TYPE_FIELD_SIZE; - - private static final int TEST_TAG = 42; - private static final int TEST_TAG2 = 314; - - //todo: For now all we do is test the returned length. More to come. - public void testLogOfPosInt() throws Exception { - final int numBytes = EventLog.writeEvent(TEST_TAG, 0x01020304); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 4, numBytes); - } - - //todo: For now all we do is test the returned length. More to come. - public void testLogOfPosLong() throws Exception { - final int numBytes = EventLog.writeEvent(TEST_TAG2, 0x0102030405060708L); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 8, numBytes); - } - - //todo: For now all we do is test the returned length. More to come. - public void testLogOfString() throws Exception { - final String valueStr = "foo bar baz"; - final int numBytes = EventLog.writeEvent(TEST_TAG, valueStr); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 4 + valueStr.length() + 1, numBytes); - } - - public void testLogOfListWithOneInt() throws Exception { - final EventLog.List list = new EventLog.List(1234); - final int numBytes = EventLog.writeEvent(TEST_TAG, list); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + 1 + 4 + 1, numBytes); - } - - public void testLogOfListWithMultipleInts() throws Exception { - final EventLog.List list = new EventLog.List(1234, 2345, 3456); - final int numBytes = EventLog.writeEvent(TEST_TAG, list); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + 1 + 4 + 1 + 4 + 1 + 4 + 1, numBytes); - } - - public void testLogOfListWithEmbeddedList() throws Exception { - final EventLog.List list = new EventLog.List( - new EventLog.List(1234, 2345, 3456)); - final int numBytes = EventLog.writeEvent(TEST_TAG, list); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 2 + 1 + 1 + 4 + 1 + 4 + 1 + 4 + 1, numBytes); - } - - public void testEventLargerThanInitialBufferCapacity() throws Exception { - final Integer[] array = new Integer[127]; - for (int i = 0; i < array.length; i++) { - array[i] = i; - } - final EventLog.List list = new EventLog.List((Object[]) array); - final int numBytes = EventLog.writeEvent(TEST_TAG, list); - Assert.assertEquals(STARTING_POS_OF_PAYLOAD + 1 + (5 * array.length) + 1, numBytes); - } - - // This test is obsolete. See http://b/issue?id=1262082 - public void disableTestReadSimpleEvent() throws Exception { - long when = System.currentTimeMillis(); - EventLog.writeEvent(2718, 12345); - Log.i(TAG, "Wrote simple event at T=" + when); - - ArrayList<EventLog.Event> list = new ArrayList<EventLog.Event>(); - EventLog.readEvents(new int[] { 2718 }, list); - - boolean found = false; - for (EventLog.Event event : list) { - assertEquals(event.getTag(), 2718); - long eventTime = event.getTimeNanos() / 1000000; - Log.i(TAG, " Found event T=" + eventTime); - if (eventTime > when - 100 && eventTime < when + 1000) { - assertEquals(event.getProcessId(), Process.myPid()); - assertEquals(event.getThreadId(), Process.myTid()); - assertEquals(event.getData(), 12345); - - assertFalse(found); - found = true; - } - } - - assertTrue(found); - } - - // This test is obsolete. See http://b/issue?id=1262082 - public void disableTestReadCompoundEntry() throws Exception { - long when = System.currentTimeMillis(); - EventLog.writeEvent(2719, - new EventLog.List(1l, new EventLog.List("2", "three", "4"), 5)); - Log.i(TAG, "Wrote compound event at T=" + when); - - ArrayList<EventLog.Event> list = new ArrayList<EventLog.Event>(); - EventLog.readEvents(new int[] { 2719 }, list); - - boolean found = false; - for (EventLog.Event event : list) { - long eventTime = event.getTimeNanos() / 1000000; - Log.i(TAG, " Found event T=" + eventTime); - if (eventTime > when - 100 && eventTime < when + 1000) { - EventLog.List data = (EventLog.List) event.getData(); - assertEquals(data.getNumItems(), 3); - - EventLog.List nested = (EventLog.List) data.getItem(1); - assertEquals(nested.getNumItems(), 3); - - assertEquals(data.getItem(0), 1l); - assertEquals(nested.getItem(0), "2"); - assertEquals(nested.getItem(1), "three"); - assertEquals(nested.getItem(2), "4"); - assertEquals(data.getItem(2), 5); - - assertFalse(found); - found = true; - } - } - - assertTrue(found); - } - - public void testEventLogTagsFile() throws Exception { - EventLogTags tags = new EventLogTags(); - assertEquals(tags.get("answer").mTag, 42); - assertEquals(tags.get("pi").mTag, 314); - assertEquals(tags.get("e").mTag, 2718); - assertEquals(tags.get(42).mName, "answer"); - assertEquals(tags.get(314).mName, "pi"); - assertEquals(tags.get(2718).mName, "e"); - } -} diff --git a/tests/framework-tests/src/android/util/EventLogTest.java b/tests/framework-tests/src/android/util/EventLogTest.java deleted file mode 100644 index 4a5d888..0000000 --- a/tests/framework-tests/src/android/util/EventLogTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.util; - -import com.google.android.collect.Lists; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -/** - * tests for {@link EventLog} - */ - -public class EventLogTest extends TestCase { - private static final int TEST_TAG = 42; - - public void testIllegalListTypesThrowException() throws Exception { - try { - EventLog.writeEvent(TEST_TAG, new EventLog.List(new Object())); - fail("Can't create List with any old Object"); - } catch (IllegalArgumentException e) { - // expected - } - try { - EventLog.writeEvent(TEST_TAG, new EventLog.List((byte) 1)); - fail("Can't create List with any old byte"); - } catch (IllegalArgumentException e) { - // expected - } - } - - void assertIntInByteArrayEquals(int expected, byte[] buf, int pos) { - ByteBuffer computedBuf = ByteBuffer.wrap(buf).order(ByteOrder.nativeOrder()); - int computed = computedBuf.getInt(pos); - Assert.assertEquals(expected, computed); - } - - void assertLongInByteArrayEquals(long expected, byte[] buf, int pos) { - ByteBuffer computedBuf = ByteBuffer.wrap(buf).order(ByteOrder.nativeOrder()); - long computed = computedBuf.getLong(pos); - Assert.assertEquals(expected, computed); - } - - void assertStringInByteArrayEquals(String expected, byte[] buf, int pos) { - byte[] expectedBytes = expected.getBytes(); - Assert.assertTrue(expectedBytes.length <= buf.length - pos); - for (byte expectedByte : expectedBytes) { - Assert.assertEquals(expectedByte, buf[pos++]); - } - } -} diff --git a/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java b/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java index 8e3a034..4d016d1 100644 --- a/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java +++ b/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java @@ -18,12 +18,12 @@ package com.android.internal.os; import junit.framework.TestCase; -import java.util.Arrays; -import java.util.List; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; -import java.io.StringWriter; -import java.io.PrintWriter; +import java.util.List; public class LoggingPrintStreamTest extends TestCase { @@ -121,6 +121,58 @@ public class LoggingPrintStreamTest extends TestCase { assertEquals(Arrays.asList("Foo", "4", "a"), out.lines); } + public void testMultiByteCharactersSpanningBuffers() throws Exception { + // assume 3*1000 bytes won't fit in LoggingPrintStream's internal buffer + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < 1000; i++) { + builder.append("\u20AC"); // a Euro character; 3 bytes in UTF-8 + } + String expected = builder.toString(); + + out.write(expected.getBytes("UTF-8")); + out.flush(); + assertEquals(Arrays.asList(expected), out.lines); + } + + public void testWriteOneByteAtATimeMultibyteCharacters() throws Exception { + String expected = " \u20AC \u20AC \u20AC \u20AC "; + for (byte b : expected.getBytes()) { + out.write(b); + } + out.flush(); + assertEquals(Arrays.asList(expected), out.lines); + } + + public void testWriteByteArrayAtATimeMultibyteCharacters() throws Exception { + String expected = " \u20AC \u20AC \u20AC \u20AC "; + out.write(expected.getBytes()); + out.flush(); + assertEquals(Arrays.asList(expected), out.lines); + } + + public void testWriteWithOffsetsMultibyteCharacters() throws Exception { + String expected = " \u20AC \u20AC \u20AC \u20AC "; + byte[] bytes = expected.getBytes(); + int i = 0; + while (i < bytes.length - 5) { + out.write(bytes, i, 5); + i += 5; + } + out.write(bytes, i, bytes.length - i); + out.flush(); + assertEquals(Arrays.asList(expected), out.lines); + } + + public void testWriteFlushesOnNewlines() throws Exception { + String a = " \u20AC \u20AC "; + String b = " \u20AC \u20AC "; + String c = " "; + String toWrite = a + "\n" + b + "\n" + c; + out.write(toWrite.getBytes()); + out.flush(); + assertEquals(Arrays.asList(a, b, c), out.lines); + } + static class TestPrintStream extends LoggingPrintStream { final List<String> lines = new ArrayList<String>(); @@ -129,5 +181,4 @@ public class LoggingPrintStreamTest extends TestCase { lines.add(line); } } - } diff --git a/tests/permission/src/com/android/framework/permission/tests/SettingsPermissionsTests.java b/tests/permission/src/com/android/framework/permission/tests/SettingsPermissionsTests.java deleted file mode 100644 index f55998f..0000000 --- a/tests/permission/src/com/android/framework/permission/tests/SettingsPermissionsTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.framework.permission.tests; - -import android.content.ContentResolver; -import android.content.ContentValues; -import android.provider.Settings; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.MediumTest; - -/** - * Verify that accessing private-API protected Settings require specific permissions. - */ -public class SettingsPermissionsTests extends AndroidTestCase { - - private ContentResolver mContentResolver; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mContentResolver = getContext().getContentResolver(); - } - - /** - * Verify that writing to the GServices table in Settings provider requires permissions. - * <p>Tests Permission: - * {@link android.Manifest.permission#WRITE_GSERVICES} - */ - @MediumTest - public void testWriteGServices() { - try { - ContentValues values = new ContentValues(); - values.put("url", "android"); - mContentResolver.insert(Settings.Gservices.CONTENT_URI, values); - fail("Write into Gservices provider did not throw SecurityException as expected."); - } catch (SecurityException e) { - // expected - } - } -}
\ No newline at end of file diff --git a/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java index 2290c1d..274ac00 100644 --- a/tests/permission/src/com/android/framework/permission/tests/HardwareServicePermissionTest.java +++ b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java @@ -19,7 +19,7 @@ package com.android.framework.permission.tests; import junit.framework.TestCase; import android.os.Binder; -import android.os.IHardwareService; +import android.os.IVibratorService; import android.os.RemoteException; import android.os.ServiceManager; import android.test.suitebuilder.annotation.SmallTest; @@ -28,25 +28,25 @@ import android.test.suitebuilder.annotation.SmallTest; * Verify that Hardware apis cannot be called without required permissions. */ @SmallTest -public class HardwareServicePermissionTest extends TestCase { +public class VibratorServicePermissionTest extends TestCase { - private IHardwareService mHardwareService; + private IVibratorService mVibratorService; @Override protected void setUp() throws Exception { - mHardwareService = IHardwareService.Stub.asInterface( - ServiceManager.getService("hardware")); + mVibratorService = IVibratorService.Stub.asInterface( + ServiceManager.getService("vibrator")); } /** - * Test that calling {@link android.os.IHardwareService#vibrate(long)} requires permissions. + * Test that calling {@link android.os.IVibratorService#vibrate(long)} requires permissions. * <p>Tests permission: * {@link android.Manifest.permission#VIBRATE} * @throws RemoteException */ public void testVibrate() throws RemoteException { try { - mHardwareService.vibrate(2000, new Binder()); + mVibratorService.vibrate(2000, new Binder()); fail("vibrate did not throw SecurityException as expected"); } catch (SecurityException e) { // expected @@ -54,7 +54,7 @@ public class HardwareServicePermissionTest extends TestCase { } /** - * Test that calling {@link android.os.IHardwareService#vibratePattern(long[], + * Test that calling {@link android.os.IVibratorService#vibratePattern(long[], * int, android.os.IBinder)} requires permissions. * <p>Tests permission: * {@link android.Manifest.permission#VIBRATE} @@ -62,7 +62,7 @@ public class HardwareServicePermissionTest extends TestCase { */ public void testVibratePattern() throws RemoteException { try { - mHardwareService.vibratePattern(new long[] {0}, 0, new Binder()); + mVibratorService.vibratePattern(new long[] {0}, 0, new Binder()); fail("vibratePattern did not throw SecurityException as expected"); } catch (SecurityException e) { // expected @@ -70,51 +70,17 @@ public class HardwareServicePermissionTest extends TestCase { } /** - * Test that calling {@link android.os.IHardwareService#cancelVibrate()} requires permissions. + * Test that calling {@link android.os.IVibratorService#cancelVibrate()} requires permissions. * <p>Tests permission: * {@link android.Manifest.permission#VIBRATE} * @throws RemoteException */ public void testCancelVibrate() throws RemoteException { try { - mHardwareService.cancelVibrate(new Binder()); + mVibratorService.cancelVibrate(new Binder()); fail("cancelVibrate did not throw SecurityException as expected"); } catch (SecurityException e) { // expected } } - - /** - * Test that calling {@link android.os.IHardwareService#setFlashlightEnabled(boolean)} - * requires permissions. - * <p>Tests permissions: - * {@link android.Manifest.permission#HARDWARE_TEST} - * {@link android.Manifest.permission#FLASHLIGHT} - * @throws RemoteException - */ - public void testSetFlashlightEnabled() throws RemoteException { - try { - mHardwareService.setFlashlightEnabled(true); - fail("setFlashlightEnabled did not throw SecurityException as expected"); - } catch (SecurityException e) { - // expected - } - } - - /** - * Test that calling {@link android.os.IHardwareService#enableCameraFlash(int)} requires - * permissions. - * <p>Tests permission: - * {@link android.Manifest.permission#HARDWARE_TEST} - * {@link android.Manifest.permission#CAMERA} - * @throws RemoteException - */ - public void testEnableCameraFlash() throws RemoteException { - try { - mHardwareService.enableCameraFlash(100); - fail("enableCameraFlash did not throw SecurityException as expected"); - } catch (SecurityException e) { - // expected - } - } } |