diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:31:44 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:31:44 -0800 |
commit | 9066cfe9886ac131c34d59ed0e2d287b0e3c0087 (patch) | |
tree | d88beb88001f2482911e3d28e43833b50e4b4e97 /tests/ImfTest | |
parent | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (diff) | |
download | frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.zip frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.gz frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tests/ImfTest')
41 files changed, 2326 insertions, 0 deletions
diff --git a/tests/ImfTest/Android.mk b/tests/ImfTest/Android.mk new file mode 100755 index 0000000..eb5327b --- /dev/null +++ b/tests/ImfTest/Android.mk @@ -0,0 +1,15 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# We only want this apk build for tests. +LOCAL_MODULE_TAGS := tests + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := ImfTest + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/ImfTest/AndroidManifest.xml b/tests/ImfTest/AndroidManifest.xml new file mode 100755 index 0000000..55e5d38 --- /dev/null +++ b/tests/ImfTest/AndroidManifest.xml @@ -0,0 +1,144 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.imftest"> + + <application> + + <activity android:name=".samples.InputTypeActivity" android:label="Input Type Activity"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.ButtonActivity" android:label="Button Activity"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BigEditTextActivityNonScrollablePanScan" android:label="Big ET !Scroll Pan/Scan"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.ManyEditTextActivityNoScrollPanScan" android:label="ManyEditTextActivityNoScrollPanScan"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BigEditTextActivityNonScrollableResize" android:label="Big ET !Scroll Resize"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BigEditTextActivityScrollablePanScan" android:label="Big ET Scroll Pan/Scan"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BigEditTextActivityScrollableResize" android:label="Big ET Scroll Resize"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.EditTextActivityDialog" android:label="ET Dialog"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.ManyEditTextActivityScrollPanScan" android:label="ManyEditTextActivityScrollPanScan"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.ManyEditTextActivityScrollResize" android:label="ManyEditTextActivityScrollResize"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BottomEditTextActivityPanScan" android:label="BottomEditTextActivityPanScan"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.BottomEditTextActivityResize" android:label="BottomEditTextActivityResize"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.OneEditTextActivitySelected" android:label="OneEditTextActivitySelected"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.OneEditTextActivityNotSelected" android:label="OneEditTextActivityNotSelected"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.AutoCompleteTextViewActivityPortrait" android:label="AutoCompleteTextViewActivityPortrait" android:screenOrientation="portrait"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.AutoCompleteTextViewActivityLandscape" android:label="AutoCompleteTextViewActivityLandscape" android:screenOrientation="landscape"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + <activity android:name=".samples.DialogActivity" android:label="DialogActivity" android:screenOrientation="portrait"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER" /> + <category android:name="android.intent.category.IMF_TEST" /> + </intent-filter> + </activity> + + </application> + +</manifest> diff --git a/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml new file mode 100644 index 0000000..e8ffa1c --- /dev/null +++ b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:padding="20dip" + android:orientation="vertical"> + + <View + android:id="@+id/blank" + android:layout_height="0dip" + android:layout_width="fill_parent" + android:layout_weight="1"/> + + <EditText + android:id="@+id/dialog_edit_text" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:scrollHorizontally="true" + android:textAppearance="?android:attr/textAppearanceMedium" /> + +</LinearLayout> diff --git a/tests/ImfTest/res/layout/full_screen_edit_text.xml b/tests/ImfTest/res/layout/full_screen_edit_text.xml new file mode 100755 index 0000000..f22aa2f --- /dev/null +++ b/tests/ImfTest/res/layout/full_screen_edit_text.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* //device/samples/SampleCode/res/layout/baseline_1.xml +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<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: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 new file mode 100755 index 0000000..09925e1 --- /dev/null +++ b/tests/ImfTest/res/layout/one_edit_text_activity.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* //device/samples/SampleCode/res/layout/baseline_1.xml +** +** 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. +*/ +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" +> + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" + android:baselineAligned="false"> + + <View android:id="@+id/blank" + android:layout_height="0dip" + android:layout_width="fill_parent" + android:layout_weight="1" + /> + + <EditText android:id="@+id/dialog_edit_text" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:scrollHorizontally="true" + android:textAppearance="?android:attr/textAppearanceMedium" + /> + </LinearLayout> + + <View + android:layout_width="fill_parent" + android:layout_height="1dip" + android:background="@android:drawable/divider_horizontal_dark" + /> +</LinearLayout> diff --git a/tests/ImfTest/res/layout/sample_edit_text.xml b/tests/ImfTest/res/layout/sample_edit_text.xml new file mode 100755 index 0000000..99a5cf8 --- /dev/null +++ b/tests/ImfTest/res/layout/sample_edit_text.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* //device/samples/SampleCode/res/layout/baseline_1.xml +** +** 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. +*/ +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" +> + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:orientation="horizontal" + android:baselineAligned="false" + android:gravity="center_vertical" + > + + <TextView android:id="@+id/label" + android:layout_width="100dip" + android:layout_height="wrap_content" + android:gravity="right|center_vertical" + /> + + <EditText android:id="@+id/data" + android:layout_width="0dip" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_marginLeft="8dip" + /> + </LinearLayout> + + <View + android:layout_width="fill_parent" + android:layout_height="1dip" + android:background="@android:drawable/divider_horizontal_dark" + /> +</LinearLayout> diff --git a/tests/ImfTest/res/values/config.xml b/tests/ImfTest/res/values/config.xml new file mode 100644 index 0000000..5ae40a3 --- /dev/null +++ b/tests/ImfTest/res/values/config.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2009, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources> + <bool name="def_expect_ime_autopop">false</bool> +</resources> diff --git a/tests/ImfTest/res/values/strings.xml b/tests/ImfTest/res/values/strings.xml new file mode 100755 index 0000000..fc87480 --- /dev/null +++ b/tests/ImfTest/res/values/strings.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 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. +*/ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Strings for sample activities --> + <string name="normal_edit_text_label">Normal</string> + <string name="uri_edit_text_label">Uri</string> + <string name="email_address_edit_text_label">Email Address</string> + <string name="email_subject_edit_text_label">Email Subject</string> + <string name="email_content_edit_text_label">Email Content</string> + <string name="person_name_edit_text_label">Person Name</string> + <string name="postal_address_edit_text_label">Postal Address</string> + <string name="password_edit_text_label">Password</string> + <string name="search_string_edit_text_label">Search String</string> + <string name="web_edit_text_label">Web Edit Text</string> + <string name="signed_number_edit_text_label">Signed Number</string> + <string name="decimal_number_edit_text_label">Decimal Number</string> + <string name="phone_number_edit_text_label">Phone Number</string> + <string name="normal_datetime_edit_text_label">Datetime</string> + <string name="date_edit_text_label">Date</string> + <string name="time_edit_text_label">Time</string> + <string name="cap_chars_edit_text_label">Cap Chars</string> + <string name="cap_words_edit_text_label">Cap Words</string> + <string name="multiline_edit_text_label">Multiline</string> + <string name="search_edit_text_label">Search (flag)</string> + <string name="cap_sentences_edit_text_label">Cap Sentences</string> + <string name="auto_complete_edit_text_label">Auto Complete</string> + <string name="auto_correct_edit_text_label">Auto Correct</string> + <string name="test_dialog">Test Dialog</string> + <string name="open_dialog_scrollable">open scrollable dialog</string> + <string name="open_dialog_nonscrollable">open nonscrollable dialog</string> + + +</resources> diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java new file mode 100644 index 0000000..9638d34 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java @@ -0,0 +1,85 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.app.ActivityManagerNative; +import android.os.Bundle; +import android.os.RemoteException; +import android.provider.MediaStore; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.AutoCompleteTextView; +import android.widget.ArrayAdapter; +import android.content.Intent; +import android.content.pm.ActivityInfo; + +import com.android.internal.R; + +/* + * Activity with AutoCompleteTextView forced to landscape mode + */ +public class AutoCompleteTextViewActivityLandscape extends Activity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + setContentView(R.layout.auto_complete_list); + + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_dropdown_item_1line, COUNTRIES); + AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit); + textView.setAdapter(adapter); + } + + static final String[] COUNTRIES = new String[] { + "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", + "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", + "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", + "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", + "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", + "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", + "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", + "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde", + "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", + "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", + "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic", + "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic", + "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", + "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland", + "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia", + "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", + "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", + "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", + "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", + "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", + "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", + "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", + "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", + "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", + "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", + "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", + "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", + "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", + "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena", + "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", + "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", + "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", + "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", + "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", + "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", + "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", + "Ukraine", "United Arab Emirates", "United Kingdom", + "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", + "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", + "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" + }; +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java new file mode 100644 index 0000000..58651e1 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java @@ -0,0 +1,79 @@ +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.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.AutoCompleteTextView; +import android.widget.ArrayAdapter; + +import com.android.internal.R; + +/* + * Activity with AutoCompleteTextView (Candidate bar should not appear) + */ +public class AutoCompleteTextViewActivityPortrait extends Activity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + setContentView(R.layout.auto_complete_list); + + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, + android.R.layout.simple_dropdown_item_1line, COUNTRIES); + AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit); + textView.setAdapter(adapter); + } + + static final String[] COUNTRIES = new String[] { + "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", + "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", + "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", + "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", + "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", + "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", + "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", + "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde", + "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", + "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", + "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic", + "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic", + "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", + "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland", + "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia", + "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", + "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", + "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", + "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", + "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", + "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", + "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", + "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", + "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", + "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", + "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", + "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", + "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", + "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena", + "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", + "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", + "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", + "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", + "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", + "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", + "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", + "Ukraine", "United Arab Emirates", "United Kingdom", + "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", + "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", + "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" + }; +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java new file mode 100644 index 0000000..9754381 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java @@ -0,0 +1,49 @@ +package com.android.imftest.samples; + +import com.android.imftest.R; + +import android.app.Activity; +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 { + + private View mRootView; + private View mDefaultFocusedView; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + + mRootView = new LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false); + + ((LinearLayout) mRootView).addView(view); + + mDefaultFocusedView = view.findViewById(R.id.data); + + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java new file mode 100644 index 0000000..701795f --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java @@ -0,0 +1,49 @@ +package com.android.imftest.samples; + +import com.android.imftest.R; + +import android.app.Activity; +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 { + + private View mRootView; + private View mDefaultFocusedView; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + + mRootView = new LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false); + + ((LinearLayout) mRootView).addView(view); + + mDefaultFocusedView = view.findViewById(R.id.data); + + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java new file mode 100644 index 0000000..bb3f767 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java @@ -0,0 +1,57 @@ +package com.android.imftest.samples; + +import com.android.imftest.R; + +import android.app.Activity; +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 BigEditTextActivityScrollablePanScan extends Activity { + + private View mRootView; + private View mDefaultFocusedView; + private LinearLayout mLayout; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + + mRootView = new ScrollView(this); + ((ScrollView) mRootView).setFillViewport(true); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + mLayout = new LinearLayout(this); + mLayout.setOrientation(LinearLayout.VERTICAL); + mLayout.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); + + mLayout.addView(view); + + ((ScrollView) mRootView).addView(mLayout); + mDefaultFocusedView = view.findViewById(R.id.data); + + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java new file mode 100644 index 0000000..f2cae1c --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java @@ -0,0 +1,57 @@ +package com.android.imftest.samples; + +import com.android.imftest.R; + +import android.app.Activity; +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 BigEditTextActivityScrollableResize extends Activity { + + private View mRootView; + private View mDefaultFocusedView; + private LinearLayout mLayout; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + + mRootView = new ScrollView(this); + ((ScrollView) mRootView).setFillViewport(true); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + mLayout = new LinearLayout(this); + mLayout.setOrientation(LinearLayout.VERTICAL); + mLayout.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); + + mLayout.addView(view); + + ((ScrollView) mRootView).addView(mLayout); + mDefaultFocusedView = view.findViewById(R.id.data); + + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java new file mode 100644 index 0000000..51f5045 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java @@ -0,0 +1,46 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.EditText; +import android.widget.ScrollView; +import android.widget.TextView; + +import com.android.imftest.R; + +/* + * Activity with EditText at the bottom (Pan&Scan) + */ +public class BottomEditTextActivityPanScan extends Activity +{ + private View mRootView; + private View mDefaultFocusedView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + mRootView = new LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); + + View view = getLayoutInflater().inflate(R.layout.one_edit_text_activity, ((LinearLayout) mRootView), false); + mDefaultFocusedView = view.findViewById(R.id.dialog_edit_text); + ((LinearLayout) mRootView).addView(view); + + setContentView(mRootView); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } +}
\ No newline at end of file diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java new file mode 100644 index 0000000..eb94b4f --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java @@ -0,0 +1,46 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.EditText; +import android.widget.ScrollView; +import android.widget.TextView; + +import com.android.imftest.R; + +/* + * Activity with EditText at the bottom (Resize) + */ +public class BottomEditTextActivityResize extends Activity +{ + private View mRootView; + private View mDefaultFocusedView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + mRootView = new LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); + + View view = getLayoutInflater().inflate(R.layout.one_edit_text_activity, ((LinearLayout) mRootView), false); + mDefaultFocusedView = view.findViewById(R.id.dialog_edit_text); + ((LinearLayout) mRootView).addView(view); + + setContentView(mRootView); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } +}
\ No newline at end of file diff --git a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java new file mode 100644 index 0000000..1191f19 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java @@ -0,0 +1,62 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.View; +import android.widget.LinearLayout; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Button; +import android.widget.TextView; + +public class ButtonActivity extends Activity +{ + static boolean mKeyboardIsActive = false; + public static final int BUTTON_ID = 0; + private View mRootView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + final ButtonActivity instance = this; + + final Button myButton = new Button(this); + myButton.setClickable(true); + myButton.setText("Keyboard UP!"); + myButton.setId(BUTTON_ID); + myButton.setFocusableInTouchMode(true); + myButton.setOnClickListener(new View.OnClickListener() + { + public void onClick (View v) + { + InputMethodManager imm = InputMethodManager.getInstance(instance); + if (mKeyboardIsActive) + { + imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0); + myButton.setText("Keyboard UP!"); + + } + else + { + myButton.requestFocusFromTouch(); + imm.showSoftInput(v, 0); + myButton.setText("Keyboard DOWN!"); + } + + mKeyboardIsActive = !mKeyboardIsActive; + } + }); + + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + layout.addView(myButton); + setContentView(layout); + mRootView = layout; + } + + public View getRootView() { + return mRootView; + } +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java new file mode 100644 index 0000000..e49301c --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java @@ -0,0 +1,102 @@ +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; + private static final int DIALOG_WITH_EDITTEXT = 1; + + private LinearLayout mLayout; + private LayoutInflater mInflater; + private Button mButton1; + private Button mButton2; + private EditText mEditText; + + + @Override + protected void onCreate(Bundle icicle) + { + super.onCreate(icicle); + + mLayout = new LinearLayout(this); + mLayout.setOrientation(LinearLayout.VERTICAL); + mLayout.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + mButton1 = new Button(this); + mButton1.setText("Dialog WITHOUT EditText");//(R.string.open_dialog_scrollable); + mButton1.setOnClickListener(new View.OnClickListener() + { + public void onClick(View v) + { + showDialog(DIALOG_WITHOUT_EDITTEXT); + } + }); + + mButton2 = new Button(this); + mButton2.setText("Dialog WITH EditText");//(R.string.open_dialog_nonscrollable); + mButton2.setOnClickListener(new View.OnClickListener() + { + public void onClick(View v) + { + showDialog(DIALOG_WITH_EDITTEXT); + } + }); + + mEditText = new EditText(this); + mLayout.addView(mEditText); + mLayout.addView(mButton1); + mLayout.addView(mButton2); + + setContentView(mLayout); + } + + @Override + protected Dialog onCreateDialog(int id) + { + switch (id) + { + case DIALOG_WITHOUT_EDITTEXT: + return createDialog(false); + case DIALOG_WITH_EDITTEXT: + return createDialog(true); + } + + return super.onCreateDialog(id); + } + + protected Dialog createDialog(boolean bEditText) + { + LinearLayout layout; + layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + + if(bEditText) + { + EditText editText; + editText = new EditText(this); + layout.addView(editText); + } + + Dialog d = new Dialog(this); + d.setTitle("The DIALOG!!!"); + d.setCancelable(true); + d.setContentView(layout); + return d; + } + + } diff --git a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java new file mode 100644 index 0000000..bd1e934 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java @@ -0,0 +1,96 @@ +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; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.ScrollView; + +public class EditTextActivityDialog extends Activity { + + private static final int SCROLLABLE_DIALOG_ID = 0; + private static final int NONSCROLLABLE_DIALOG_ID = 1; + + private LinearLayout mLayout; + private ScrollView mScrollView; + private LayoutInflater mInflater; + private Button mButton1; + private Button mButton2; + + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + mLayout = new LinearLayout(this); + mLayout.setOrientation(LinearLayout.VERTICAL); + mLayout.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + mButton1 = new Button(this); + mButton1.setText(R.string.open_dialog_scrollable); + mButton1.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + showDialog(SCROLLABLE_DIALOG_ID); + } + }); + + mButton2 = new Button(this); + mButton2.setText(R.string.open_dialog_nonscrollable); + mButton2.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + showDialog(NONSCROLLABLE_DIALOG_ID); + } + }); + + mLayout.addView(mButton1); + mLayout.addView(mButton2); + + setContentView(mLayout); + } + + @Override + protected Dialog onCreateDialog(int id) { + switch (id) { + case SCROLLABLE_DIALOG_ID: + return createDialog(true); + case NONSCROLLABLE_DIALOG_ID: + return createDialog(false); + } + + return super.onCreateDialog(id); + } + + protected Dialog createDialog(boolean scrollable) { + View layout; + EditText editText; + + if (scrollable) { + layout = new ScrollView(EditTextActivityDialog.this); + ((ScrollView) layout).setMinimumHeight(mLayout.getHeight()); + + ((ScrollView) layout).addView(( + LinearLayout) View.inflate(EditTextActivityDialog.this, + R.layout.dialog_edit_text_no_scroll, null)); + } else { + layout = View.inflate(EditTextActivityDialog.this, + R.layout.dialog_edit_text_no_scroll, null); + } + + Dialog d = new Dialog(EditTextActivityDialog.this); + d.setTitle(getString(R.string.test_dialog)); + d.setCancelable(true); + d.setContentView(layout); + return d; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java new file mode 100755 index 0000000..17f6bdc --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java @@ -0,0 +1,160 @@ +/* + * 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.imftest.samples; + +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 { + + private LinearLayout mLayout; + private ScrollView mScrollView; + private LayoutInflater mInflater; + private ViewGroup mParent; + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + + mScrollView = new ScrollView(this); + + mLayout = new LinearLayout(this); + mLayout.setOrientation(LinearLayout.VERTICAL); + mLayout.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT)); + + mInflater = getLayoutInflater(); + mParent = mLayout; + + /* Normal Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL, + R.string.normal_edit_text_label)); + + /* Normal Edit Text w/Cap Chars Flag*/ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS, + R.string.cap_chars_edit_text_label)); + + /* Normal Edit Text w/Cap Words Flag*/ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS, + R.string.cap_words_edit_text_label)); + + /* Normal Edit Text w/Cap Multiline Flag */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE, + R.string.multiline_edit_text_label)); + + /* Normal Edit Text w/Cap Sentences Flag */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES, + R.string.cap_sentences_edit_text_label)); + + /* Normal Edit Text w/Auto-complete Flag */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE, + R.string.auto_complete_edit_text_label)); + + /* Normal Edit Text w/Auto-correct Flag */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT, + R.string.auto_correct_edit_text_label)); + + /* Uri Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_URI, + R.string.uri_edit_text_label)); + + /* Email Address Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, + R.string.email_address_edit_text_label)); + + /* Email Subject Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT, + R.string.email_subject_edit_text_label)); + + /* Email Content Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_LONG_MESSAGE, + R.string.email_content_edit_text_label)); + + /* Person Name Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME, + R.string.person_name_edit_text_label)); + + /* Postal Address Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_POSTAL_ADDRESS, + R.string.postal_address_edit_text_label)); + + /* Password Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_PASSWORD, + R.string.password_edit_text_label)); + + /* Web Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT, + R.string.web_edit_text_label)); + + /* Signed Number Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_NUMBER|EditorInfo.TYPE_NUMBER_FLAG_SIGNED, + R.string.signed_number_edit_text_label)); + + /* Decimal Number Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_NUMBER|EditorInfo.TYPE_NUMBER_FLAG_DECIMAL, + R.string.decimal_number_edit_text_label)); + + /* Phone Number Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_PHONE, + R.string.phone_number_edit_text_label)); + + /* Normal Datetime Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_NORMAL, + R.string.normal_datetime_edit_text_label)); + + /* Date Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_DATE, + R.string.date_edit_text_label)); + + /* Time Edit Text */ + mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_TIME, + R.string.time_edit_text_label)); + + mScrollView.addView(mLayout); + setContentView(mScrollView); + } + + private View buildEntryView(int inputType, int label) { + + + View view = mInflater.inflate(R.layout.sample_edit_text, mParent, false); + + EditText editText = (EditText) view.findViewById(R.id.data); + editText.setInputType(inputType); + + TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText(label); + + return view; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java new file mode 100644 index 0000000..54ab57a --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java @@ -0,0 +1,50 @@ +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.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Button; +import android.widget.TextView; +import android.widget.ScrollView; + +import com.android.internal.R; + +/* + * Full screen of EditTexts (Non-Scrollable, Pan&Scan) + */ +public class ManyEditTextActivityNoScrollPanScan extends Activity +{ + public static final int NUM_EDIT_TEXTS = 9; + + private View mRootView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + mRootView = new LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); + + for (int i=0; i<NUM_EDIT_TEXTS; i++) + { + final EditText editText = new EditText(this); + editText.setText(String.valueOf(i)); + editText.setId(i); + ((LinearLayout) mRootView).addView(editText); + } + setContentView(mRootView); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + } + + public View getRootView() { + return mRootView; + } + +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java new file mode 100644 index 0000000..b228d34 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java @@ -0,0 +1,52 @@ +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.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Button; +import android.widget.TextView; +import android.widget.ScrollView; + +import com.android.internal.R; + +/* + * Full screen of EditTexts (Scrollable, Pan&Scan) + */ +public class ManyEditTextActivityScrollPanScan extends Activity +{ + public static final int NUM_EDIT_TEXTS = 12; + + private View mRootView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + mRootView = new ScrollView(this); + + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + + for (int i=0; i<NUM_EDIT_TEXTS; i++) + { + final EditText editText = new EditText(this); + editText.setText(String.valueOf(i)); + editText.setId(i); + layout.addView(editText); + } + + ((ScrollView) mRootView).addView(layout); + setContentView(mRootView); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + } + + public View getRootView() { + return mRootView; + } +}
\ No newline at end of file diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java new file mode 100644 index 0000000..777fbae --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java @@ -0,0 +1,45 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.EditText; +import android.widget.ScrollView; + +/* + * Full screen of EditTexts (Scrollable, Resize) + */ +public class ManyEditTextActivityScrollResize extends Activity +{ + public static final int NUM_EDIT_TEXTS = 12; + + private View mRootView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + mRootView = new ScrollView(this); + + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + + for (int i=0; i<NUM_EDIT_TEXTS; i++) + { + final EditText editText = new EditText(this); + editText.setText(String.valueOf(i)); + editText.setId(i); + layout.addView(editText); + } + + ((ScrollView) mRootView).addView(layout); + setContentView(mRootView); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + } + + public View getRootView() { + return mRootView; + } +}
\ No newline at end of file diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java new file mode 100644 index 0000000..88a3447 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java @@ -0,0 +1,56 @@ +package com.android.imftest.samples; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Debug; +import android.view.KeyEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.LinearLayout; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Button; +import android.widget.TextView; +import android.widget.ScrollView; + +import com.android.internal.R; + +/* + * Activity with non-EditText view selected initially + */ +public class OneEditTextActivityNotSelected extends Activity +{ + private View mRootView; + private View mDefaultFocusedView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + mRootView = new ScrollView(this); + + EditText editText = new EditText(this); + Button button = new Button(this); + button.setText("The focus is here."); + button.setFocusableInTouchMode(true); + button.requestFocus(); + mDefaultFocusedView = button; + layout.addView(button); + layout.addView(editText); + + ((ScrollView) mRootView).addView(layout); + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } +} diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java new file mode 100644 index 0000000..1b80263 --- /dev/null +++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java @@ -0,0 +1,51 @@ +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.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.Button; +import android.widget.TextView; +import android.widget.ScrollView; + +import com.android.internal.R; + +/* + * Activity with EditText selected initially + */ +public class OneEditTextActivitySelected extends Activity +{ + private View mRootView; + private View mDefaultFocusedView; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + mRootView = new ScrollView(this); + + EditText editText = new EditText(this); + editText.requestFocus(); + mDefaultFocusedView = editText; + layout.addView(editText); + + ((ScrollView) mRootView).addView(layout); + setContentView(mRootView); + } + + public View getRootView() { + return mRootView; + } + + public View getDefaultFocusedView() { + return mDefaultFocusedView; + } +} diff --git a/tests/ImfTest/tests/Android.mk b/tests/ImfTest/tests/Android.mk new file mode 100755 index 0000000..0f1924c --- /dev/null +++ b/tests/ImfTest/tests/Android.mk @@ -0,0 +1,16 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# We only want this apk build for tests. +LOCAL_MODULE_TAGS := tests + +# Include all test java files. +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_JAVA_LIBRARIES := android.test.runner + +LOCAL_PACKAGE_NAME := ImfTestTests + +LOCAL_INSTRUMENTATION_FOR := ImfTest + +include $(BUILD_PACKAGE) diff --git a/tests/ImfTest/tests/AndroidManifest.xml b/tests/ImfTest/tests/AndroidManifest.xml new file mode 100755 index 0000000..122d202 --- /dev/null +++ b/tests/ImfTest/tests/AndroidManifest.xml @@ -0,0 +1,34 @@ +<?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. +--> + +<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us --> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.imftest.tests"> + + <application> + <uses-library android:name="android.test.runner" /> + </application> + + <!-- + This declares that this app uses the instrumentation test runner targeting + the package of com.android.imftest. To run the tests use the command: + "adb shell am instrument -w com.android.imftest.tests/android.test.InstrumentationTestRunner" + --> + <instrumentation android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.android.imftest" + android:label="imf tests"/> + +</manifest> diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScanTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScanTests.java new file mode 100755 index 0000000..a1c5fd2 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScanTests.java @@ -0,0 +1,49 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BigEditTextActivityNonScrollablePanScanTests extends ImfBaseTestCase<BigEditTextActivityNonScrollablePanScan> { + + public final String TAG = "BigEditTextActivityNonScrollablePanScanTests"; + + public BigEditTextActivityNonScrollablePanScanTests() { + super(BigEditTextActivityNonScrollablePanScan.class); + } + + @LargeTest + public void testAppAdjustmentPanScan() { + // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BigEditTextActivityNonScrollablePanScan) mTargetActivity).getRootView(); + View servedView = ((BigEditTextActivityNonScrollablePanScan) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResizeTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResizeTests.java new file mode 100755 index 0000000..2e0b0eb --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResizeTests.java @@ -0,0 +1,48 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BigEditTextActivityNonScrollableResizeTests extends ImfBaseTestCase<BigEditTextActivityNonScrollableResize> { + + public final String TAG = "BigEditTextActivityNonScrollableResizeTests"; + + public BigEditTextActivityNonScrollableResizeTests() { + super(BigEditTextActivityNonScrollableResize.class); + } + + @LargeTest + public void testAppAdjustmentPanScan() { // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BigEditTextActivityNonScrollableResize) mTargetActivity).getRootView(); + View servedView = ((BigEditTextActivityNonScrollableResize) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScanTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScanTests.java new file mode 100755 index 0000000..d3eefb5 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScanTests.java @@ -0,0 +1,48 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BigEditTextActivityScrollablePanScanTests extends ImfBaseTestCase<BigEditTextActivityScrollablePanScan> { + + public final String TAG = "BigEditTextActivityScrollablePanScanTests"; + + public BigEditTextActivityScrollablePanScanTests() { + super(BigEditTextActivityScrollablePanScan.class); + } + + @LargeTest + public void testAppAdjustmentPanScan() { // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BigEditTextActivityScrollablePanScan) mTargetActivity).getRootView(); + View servedView = ((BigEditTextActivityScrollablePanScan) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollableResizeTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollableResizeTests.java new file mode 100755 index 0000000..5c40e6d --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollableResizeTests.java @@ -0,0 +1,49 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BigEditTextActivityScrollableResizeTests extends ImfBaseTestCase<BigEditTextActivityScrollableResize> { + + public final String TAG = "BigEditTextActivityScrollableResizeTests"; + + public BigEditTextActivityScrollableResizeTests() { + super(BigEditTextActivityScrollableResize.class); + } + + @LargeTest + public void testAppAdjustmentPanScan() { + // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BigEditTextActivityScrollableResize) mTargetActivity).getRootView(); + View servedView = ((BigEditTextActivityScrollableResize) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityPanScanTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityPanScanTests.java new file mode 100755 index 0000000..9a93133 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityPanScanTests.java @@ -0,0 +1,49 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BottomEditTextActivityPanScanTests extends ImfBaseTestCase<BottomEditTextActivityPanScan> { + + public final String TAG = "BottomEditTextActivityPanScanTests"; + + public BottomEditTextActivityPanScanTests() { + super(BottomEditTextActivityPanScan.class); + } + + @LargeTest + public void testAppAdjustmentPanScan() { + // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BottomEditTextActivityPanScan) mTargetActivity).getRootView(); + View servedView = ((BottomEditTextActivityPanScan) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityResizeTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityResizeTests.java new file mode 100755 index 0000000..9a69fd5 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityResizeTests.java @@ -0,0 +1,49 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + +import com.android.imftest.R; + + +public class BottomEditTextActivityResizeTests extends ImfBaseTestCase<BottomEditTextActivityResize> { + + public final String TAG = "BottomEditTextActivityResizeTests"; + + public BottomEditTextActivityResizeTests() { + super(BottomEditTextActivityResize.class); + } + + @LargeTest + public void testAppAdjustmentResize() { + // Give the IME 2 seconds to appear. + pause(2000); + + View rootView = ((BottomEditTextActivityResize) mTargetActivity).getRootView(); + View servedView = ((BottomEditTextActivityResize) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ButtonActivityTest.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ButtonActivityTest.java new file mode 100755 index 0000000..ae900c3 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ButtonActivityTest.java @@ -0,0 +1,58 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.KeyEvent; +import android.widget.Button; + + +public class ButtonActivityTest extends ImfBaseTestCase<ButtonActivity> { + + final public String TAG = "ButtonActivityTest"; + + public ButtonActivityTest() { + super(ButtonActivity.class); + } + + @LargeTest + public void testButtonActivatesIme() { + + final Button button = (Button) mTargetActivity.findViewById(ButtonActivity.BUTTON_ID); + + // Push button + // Bring the target EditText into focus. + mTargetActivity.runOnUiThread(new Runnable() { + public void run() { + button.requestFocus(); + } + }); + + sendKeys(KeyEvent.KEYCODE_DPAD_CENTER); + + // Give it a couple seconds + pause(2000); + + // We should have initialized imm.mServedView and imm.mCurrentTextBoxAttribute + assertTrue(mImm.isActive()); + // imm.mServedInputConnection should be null since Button doesn't override onCreateInputConnection(). + assertFalse(mImm.isAcceptingText()); + + destructiveCheckImeInitialState(mTargetActivity.getRootView(), button); + + } +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java new file mode 100755 index 0000000..61dc611 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java @@ -0,0 +1,135 @@ +/* + * 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.imftest.samples; + +import android.app.Activity; +import android.os.SystemClock; +import android.test.InstrumentationTestCase; +import android.view.KeyEvent; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; + +import com.android.imftest.R; + +public abstract class ImfBaseTestCase<T extends Activity> extends InstrumentationTestCase { + + /* + * The amount of time we are willing to wait for the IME to appear after a user action + * before we give up and fail the test. + */ + public final long WAIT_FOR_IME = 5000; + + /* + * Unfortunately there is now way for us to know how tall the IME is, + * so we have to hard code a minimum and maximum value. + */ + public final int IME_MIN_HEIGHT = 150; + public final int IME_MAX_HEIGHT = 300; + + public final String TARGET_PACKAGE_NAME = "com.android.imftest"; + protected InputMethodManager mImm; + protected T mTargetActivity; + protected boolean mExpectAutoPop; + private Class<T> mTargetActivityClass; + + public ImfBaseTestCase(Class<T> activityClass) { + mTargetActivityClass = activityClass; + } + + @Override + public void setUp() throws Exception { + super.setUp(); + + mTargetActivity = launchActivity(TARGET_PACKAGE_NAME, mTargetActivityClass, null); + mExpectAutoPop = mTargetActivity.getResources().getBoolean(R.bool.def_expect_ime_autopop); + mImm = InputMethodManager.getInstance(mTargetActivity); + } + + // Utility test methods + public void verifyEditTextAdjustment(final View editText, int rootViewHeight) { + + int[] origLocation = new int[2]; + int[] newLocation = new int[2]; + + // Tell the keyboard to go away. + mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + + // Bring the target EditText into focus. + mTargetActivity.runOnUiThread(new Runnable() { + public void run() { + editText.requestFocus(); + } + }); + + // Get the original location of the EditText. + editText.getLocationOnScreen(origLocation); + + // Tap the EditText to bring up the IME. + sendKeys(KeyEvent.KEYCODE_DPAD_CENTER); + + // Wait until the EditText pops above the IME or until we hit the timeout. + editText.getLocationOnScreen(newLocation); + long timeoutTime = SystemClock.uptimeMillis() + WAIT_FOR_IME; + while (newLocation[1] > rootViewHeight - IME_MIN_HEIGHT && SystemClock.uptimeMillis() < timeoutTime) { + editText.getLocationOnScreen(newLocation); + pause(100); + } + + assertTrue(newLocation[1] <= rootViewHeight - IME_MIN_HEIGHT); + + // Tell the keyboard to go away. + mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + + public void destructiveCheckImeInitialState(View rootView, View servedView) { + if (mExpectAutoPop && (mTargetActivity.getWindow().getAttributes(). + softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) + == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) { + assertTrue(destructiveCheckImeUp(rootView, servedView)); + } else { + assertFalse(destructiveCheckImeUp(rootView, servedView)); + } + } + + public boolean destructiveCheckImeUp(View rootView, View servedView) { + int origHeight; + int newHeight; + + origHeight = rootView.getHeight(); + + // Tell the keyboard to go away. + mImm.hideSoftInputFromWindow(servedView.getWindowToken(), 0); + + // Give it five seconds to adjust + newHeight = rootView.getHeight(); + long timeoutTime = SystemClock.uptimeMillis() + WAIT_FOR_IME; + while (Math.abs(newHeight - origHeight) < IME_MIN_HEIGHT && SystemClock.uptimeMillis() < timeoutTime) { + newHeight = rootView.getHeight(); + } + + return (Math.abs(origHeight - newHeight) >= IME_MIN_HEIGHT); + } + + void pause(int millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + } + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityBaseTestCase.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityBaseTestCase.java new file mode 100755 index 0000000..278efb1 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityBaseTestCase.java @@ -0,0 +1,40 @@ +/* + * 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.imftest.samples; + +import android.app.Activity; +import android.widget.EditText; + + +public abstract class ManyEditTextActivityBaseTestCase<T extends Activity> extends ImfBaseTestCase<T> { + + public ManyEditTextActivityBaseTestCase(Class<T> activityClass){ + super(activityClass); + } + + public abstract void testAllEditTextsAdjust(); + + public void verifyAllEditTextAdjustment(int numEditTexts, int rootViewHeight) { + + for (int i = 0; i < numEditTexts; i++) { + final EditText lastEditText = (EditText) mTargetActivity.findViewById(i); + verifyEditTextAdjustment(lastEditText, rootViewHeight); + } + + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScanTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScanTests.java new file mode 100755 index 0000000..4f8d14e --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScanTests.java @@ -0,0 +1,36 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; + + +public class ManyEditTextActivityNoScrollPanScanTests extends ManyEditTextActivityBaseTestCase<ManyEditTextActivityNoScrollPanScan> { + + public final String TAG = "ManyEditTextActivityNoScrollPanScanTests"; + + public ManyEditTextActivityNoScrollPanScanTests() { + super(ManyEditTextActivityNoScrollPanScan.class); + } + + + @LargeTest + public void testAllEditTextsAdjust() { + verifyAllEditTextAdjustment(mTargetActivity.NUM_EDIT_TEXTS, + mTargetActivity.getRootView().getMeasuredHeight()); + } +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScanTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScanTests.java new file mode 100755 index 0000000..7f98f7f --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScanTests.java @@ -0,0 +1,37 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; + + +public class ManyEditTextActivityScrollPanScanTests extends ManyEditTextActivityBaseTestCase<ManyEditTextActivityScrollPanScan> { + + public final String TAG = "ManyEditTextActivityScrollPanScanTests"; + + + public ManyEditTextActivityScrollPanScanTests() { + super(ManyEditTextActivityScrollPanScan.class); + } + + @LargeTest + public void testAllEditTextsAdjust() { + verifyAllEditTextAdjustment(mTargetActivity.NUM_EDIT_TEXTS, + mTargetActivity.getRootView().getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollResizeTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollResizeTests.java new file mode 100755 index 0000000..68dae87 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollResizeTests.java @@ -0,0 +1,37 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; + + +public class ManyEditTextActivityScrollResizeTests extends ManyEditTextActivityBaseTestCase<ManyEditTextActivityScrollResize> { + + public final String TAG = "ManyEditTextActivityScrollResizeTests"; + + + public ManyEditTextActivityScrollResizeTests() { + super(ManyEditTextActivityScrollResize.class); + } + + @LargeTest + public void testAllEditTextsAdjust() { + verifyAllEditTextAdjustment(mTargetActivity.NUM_EDIT_TEXTS, + mTargetActivity.getRootView().getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivityNotSelectedTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivityNotSelectedTests.java new file mode 100755 index 0000000..ed5b0c9 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivityNotSelectedTests.java @@ -0,0 +1,50 @@ +/* + * 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.imftest.samples; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.View; + + +public class OneEditTextActivityNotSelectedTests extends ImfBaseTestCase<OneEditTextActivityNotSelected> { + + public final String TAG = "OneEditTextActivityNotSelectedTests"; + + public OneEditTextActivityNotSelectedTests() { + super(OneEditTextActivityNotSelected.class); + } + + @LargeTest + public void testSoftKeyboardNoAutoPop() { + + // Give the IME 2 seconds to appear. + pause(2000); + + assertFalse(mImm.isAcceptingText()); + + View rootView = ((OneEditTextActivityNotSelected) mTargetActivity).getRootView(); + View servedView = ((OneEditTextActivityNotSelected) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivitySelectedTests.java b/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivitySelectedTests.java new file mode 100755 index 0000000..42fcd66 --- /dev/null +++ b/tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivitySelectedTests.java @@ -0,0 +1,53 @@ +/* + * 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.imftest.samples; + +import com.android.imftest.R; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.KeyEvent; +import android.view.View; + + +public class OneEditTextActivitySelectedTests extends ImfBaseTestCase<OneEditTextActivitySelected> { + + public final String TAG = "OneEditTextActivitySelectedTests"; + + public OneEditTextActivitySelectedTests() { + super(OneEditTextActivitySelected.class); + } + + @LargeTest + public void testSoftKeyboardAutoPop() { + + // Give the IME 2 seconds to appear. + pause(2000); + + assertTrue(mImm.isAcceptingText()); + + View rootView = ((OneEditTextActivitySelected) mTargetActivity).getRootView(); + View servedView = ((OneEditTextActivitySelected) mTargetActivity).getDefaultFocusedView(); + + assertNotNull(rootView); + assertNotNull(servedView); + + destructiveCheckImeInitialState(rootView, servedView); + + verifyEditTextAdjustment(servedView, rootView.getMeasuredHeight()); + } + +} |