diff options
Diffstat (limited to 'tests')
46 files changed, 1311 insertions, 296 deletions
diff --git a/tests/AndroidTests/AndroidManifest.xml b/tests/AndroidTests/AndroidManifest.xml index 230456a..36f7b9b 100644 --- a/tests/AndroidTests/AndroidManifest.xml +++ b/tests/AndroidTests/AndroidManifest.xml @@ -44,6 +44,7 @@ <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.GET_PACKAGE_SIZE" /> + <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> diff --git a/tests/AndroidTests/src/com/android/unit_tests/MenuTest.java b/tests/AndroidTests/src/com/android/unit_tests/MenuTest.java index d184543..c436726 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/MenuTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/MenuTest.java @@ -131,20 +131,7 @@ public class MenuTest extends AndroidTestCase { makeKeyEvent(KeyEvent.KEYCODE_A, KeyEvent.META_SYM_ON))); } - - @LargeTest - public void testIsNotShortcutWithMultipleMetas() throws Exception { - mMenu.setQwertyMode(true); - mMenu.add(0, 0, 0, "test").setShortcut('2', 'a'); - Assert.assertFalse(mMenu.isShortcutKey( - 'a', - makeKeyEvent(KeyEvent.KEYCODE_A, KeyEvent.META_SYM_ON & KeyEvent.META_ALT_ON))); - Assert.assertFalse(mMenu.isShortcutKey( - 'a', makeKeyEvent(KeyEvent.KEYCODE_A, KeyEvent.META_SYM_ON))); - Assert.assertFalse(mMenu.isShortcutKey( - 'a', makeKeyEvent(KeyEvent.KEYCODE_A, KeyEvent.META_SHIFT_ON))); - } - + @SmallTest public void testIsShortcutWithUpperCaseAlpha() throws Exception { mMenu.setQwertyMode(true); diff --git a/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java b/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java index 8c1c91f..51e841c 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/TextUtilsTest.java @@ -262,7 +262,7 @@ public class TextUtilsTest extends TestCase { Map<String, String> fixes = Maps.newHashMap(); fixes.put("a", "<a@gmail.com>"); fixes.put("a b", "<ab@gmail.com>"); - fixes.put("a@b", "<a@gmail.com>"); + fixes.put("a@b", "<a@b>"); for (Map.Entry<String, String> e : fixes.entrySet()) { assertEquals(e.getValue(), validator.fixText(e.getKey()).toString()); diff --git a/tests/DumpRenderTree/compare_layout_results.py b/tests/DumpRenderTree/compare_layout_results.py index 4383dbb..c4285f1 100644 --- a/tests/DumpRenderTree/compare_layout_results.py +++ b/tests/DumpRenderTree/compare_layout_results.py @@ -6,6 +6,7 @@ results to a file. import optparse import os +import sys def DiffResults(marker, new_results, old_results, diff_results, strip_reason): """ Given two result files, generate diff and @@ -45,7 +46,7 @@ def DiffResults(marker, new_results, old_results, diff_results, strip_reason): diff_file.writelines("- " + line) missing_count += 1 - print marker + " >>> New = " + str(new_count) + " , Missing = " + str(missing_count) + print marker + " >>> added " + str(new_count) + " tests, removed " + str(missing_count) + " tests" diff_file.writelines("\n\n") @@ -55,24 +56,32 @@ def DiffResults(marker, new_results, old_results, diff_results, strip_reason): return def main(options, args): - results_dir = options.results_directory + results_dir = os.path.abspath(options.results_directory) ref_dir = options.ref_directory - if os.path.exists(results_dir + "/layout_tests_diff.txt"): - os.remove(results_dir + "/layout_tests_diff.txt") - files=["passed", "nontext", "crashed"] - for f in files: - DiffResults(f, results_dir + "layout_tests_" + f + ".txt", - ref_dir + "layout_tests_" + f + ".txt", results_dir + "layout_tests_diff.txt", False) + # if ref_dir is null, cannonify ref_dir to the script dir. + if not ref_dir: + script_self = sys.argv[0] + script_dir = os.path.dirname(script_self) + ref_dir = os.path.join(script_dir, "results") + + ref_dir = os.path.abspath(ref_dir) - for f in ["failed"]: - DiffResults(f, results_dir + "layout_tests_" + f + ".txt", - ref_dir + "layout_tests_" + f + ".txt", results_dir + "layout_tests_diff.txt", True) + diff_result = os.path.join(results_dir, "layout_tests_diff.txt") + if os.path.exists(diff_result): + os.remove(diff_result) + + files=["passed", "failed", "nontext", "crashed"] + for f in files: + result_file_name = "layout_tests_" + f + ".txt" + DiffResults(f, os.path.join(results_dir, result_file_name), + os.path.join(ref_dir, result_file_name), diff_result, + f == "failed") if '__main__' == __name__: option_parser = optparse.OptionParser() option_parser.add_option("", "--ref-directory", - default="results/", + default=None, dest="ref_directory", help="directory name under which results are stored.") diff --git a/tests/DumpRenderTree/run_layout_tests.py b/tests/DumpRenderTree/run_layout_tests.py index b4eb685..433271e 100755 --- a/tests/DumpRenderTree/run_layout_tests.py +++ b/tests/DumpRenderTree/run_layout_tests.py @@ -48,6 +48,86 @@ def CountLineNumber(filename): fp.close() return lines +def DumpRenderTreeFinished(adb_cmd): + """ Check if DumpRenderTree finished running tests + + Args: + output: adb_cmd string + """ + + # pull /sdcard/running_test.txt, if the content is "#DONE", it's done + shell_cmd_str = adb_cmd + " shell cat /sdcard/running_test.txt" + adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] + return adb_output.strip() == "#DONE" + +def DiffResults(marker, new_results, old_results, diff_results, strip_reason): + """ Given two result files, generate diff and + write to diff_results file. All arguments are absolute paths + to files. + """ + old_file = open(old_results, "r") + new_file = open(new_results, "r") + diff_file = open(diff_results, "a") + + # Read lines from each file + ndict = new_file.readlines() + cdict = old_file.readlines() + + # Write marker to diff file + diff_file.writelines(marker + "\n") + diff_file.writelines("###############\n") + + # Strip reason from result lines + if strip_reason is True: + for i in range(0, len(ndict)): + ndict[i] = ndict[i].split(' ')[0] + "\n" + for i in range(0, len(cdict)): + cdict[i] = cdict[i].split(' ')[0] + "\n" + + # Find results in new_results missing in old_results + new_count=0 + for line in ndict: + if line not in cdict: + diff_file.writelines("+ " + line) + new_count += 1 + + # Find results in old_results missing in new_results + missing_count=0 + for line in cdict: + if line not in ndict: + diff_file.writelines("- " + line) + missing_count += 1 + + logging.info(marker + " >>> " + str(new_count) + " new, " + str(missing_count) + " misses") + + diff_file.writelines("\n\n") + + old_file.close() + new_file.close() + diff_file.close() + return + +def CompareResults(ref_dir, results_dir): + """Compare results in two directories + + Args: + ref_dir: the reference directory having layout results as references + results_dir: the results directory + """ + logging.info("Comparing results to " + ref_dir) + + diff_result = os.path.join(results_dir, "layout_tests_diff.txt") + if os.path.exists(diff_result): + os.remove(diff_result) + + files=["passed", "failed", "nontext", "crashed"] + for f in files: + result_file_name = "layout_tests_" + f + ".txt" + DiffResults(f, os.path.join(results_dir, result_file_name), + os.path.join(ref_dir, result_file_name), diff_result, + f == "failed") + logging.info("Detailed diffs are in " + diff_result) + def main(options, args): """Run the tests. Will call sys.exit when complete. @@ -84,7 +164,7 @@ def main(options, args): sys.exit(1) - logging.info("Starting tests") + logging.info("Running tests") # Count crashed tests. crashed_tests = [] @@ -98,7 +178,7 @@ def main(options, args): # Call LayoutTestsAutoTest::startLayoutTests. shell_cmd_str = adb_cmd + " shell am instrument -e class com.android.dumprendertree.LayoutTestsAutoTest#startLayoutTests -e path \"" + path + "\" -e timeout " + timeout_ms + " -w com.android.dumprendertree/.LayoutTestsAutoRunner" adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] - while adb_output.find('Process crashed') != -1: + while not DumpRenderTreeFinished(adb_cmd): # Get the running_test.txt logging.error("DumpRenderTree crashed, output:\n" + adb_output) @@ -118,8 +198,8 @@ def main(options, args): logging.error("Error happened : " + adb_output) sys.exit(1) - logging.info("Done"); logging.debug(adb_output); + logging.info("Done\n"); # Pull results from /sdcard results_dir = options.results_directory @@ -152,8 +232,21 @@ def main(options, args): nontext_tests = CountLineNumber(results_dir + "/layout_tests_nontext.txt") logging.info(str(nontext_tests) + " no dumpAsText") - logging.info("Results are stored under: " + results_dir) + logging.info("Results are stored under: " + results_dir + "\n") + + # Comparing results to references to find new fixes and regressions. + results_dir = os.path.abspath(options.results_directory) + ref_dir = options.ref_directory + # if ref_dir is null, cannonify ref_dir to the script dir. + if not ref_dir: + script_self = sys.argv[0] + script_dir = os.path.dirname(script_self) + ref_dir = os.path.join(script_dir, "results") + + ref_dir = os.path.abspath(ref_dir) + + CompareResults(ref_dir, results_dir) if '__main__' == __name__: option_parser = optparse.OptionParser() @@ -171,6 +264,11 @@ if '__main__' == __name__: help="pass options to adb, such as -d -e, etc"); option_parser.add_option("", "--results-directory", default="layout-test-results", - help="directory name under which results are stored.") + help="directory which results are stored.") + option_parser.add_option("", "--ref-directory", + default=None, + dest="ref_directory", + help="directory where reference results are stored.") + options, args = option_parser.parse_args(); main(options, args) diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java index c77d98a..86bfad7 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java @@ -68,9 +68,12 @@ class TestRecorder { } } - public void nontext(String layout_file) { + public void nontext(String layout_file, boolean has_results) { try { mBufferedOutputNontextStream.write(layout_file.getBytes()); + if (has_results) { + mBufferedOutputNontextStream.write(" : has expected results".getBytes()); + } mBufferedOutputNontextStream.write('\n'); mBufferedOutputNontextStream.flush(); } catch(Exception e) { @@ -299,6 +302,9 @@ public class HTMLHostActivity extends Activity resetTestStatus(); if (testIndex == mTestList.size()) { + if (!mSingleTestMode) { + updateTestStatus("#DONE"); + } finished(); return; } @@ -385,9 +391,9 @@ public class HTMLHostActivity extends Activity } } - public void nontextCase(String file) { + public void nontextCase(String file, boolean has_expected_results) { Log.v("Layout test:", file + " nontext"); - mResultRecorder.nontext(file); + mResultRecorder.nontext(file, has_expected_results); } public void setCallback(HTMLHostCallbackInterface callback) { @@ -447,8 +453,11 @@ public class HTMLHostActivity extends Activity } File nontext_result = new File(short_file + "-android-results.txt"); - if (nontext_result.exists()) - mResultRecorder.nontext(test_path); + if (nontext_result.exists()) { + // Check if the test has expected results. + File expected = new File(short_file + "-expected.txt"); + nontextCase(test_path, expected.exists()); + } } public void finished() { diff --git a/tests/ImfTest/AndroidManifest.xml b/tests/ImfTest/AndroidManifest.xml index 627ee6d..55e5d38 100755 --- a/tests/ImfTest/AndroidManifest.xml +++ b/tests/ImfTest/AndroidManifest.xml @@ -19,7 +19,7 @@ </intent-filter> </activity> - <activity android:name=".samples.AppAdjustmentBigEditTextNonScrollablePanScan" android:label="Big ET !Scroll Pan/Scan"> + <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" /> @@ -35,7 +35,7 @@ </intent-filter> </activity> - <activity android:name=".samples.AppAdjustmentBigEditTextNonScrollableResize" android:label="Big ET !Scroll Resize"> + <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" /> @@ -43,7 +43,7 @@ </intent-filter> </activity> - <activity android:name=".samples.AppAdjustmentBigEditTextScrollablePanScan" android:label="Big ET Scroll Pan/Scan"> + <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" /> @@ -51,7 +51,7 @@ </intent-filter> </activity> - <activity android:name=".samples.AppAdjustmentBigEditTextScrollableResize" android:label="Big ET Scroll Resize"> + <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" /> @@ -59,7 +59,7 @@ </intent-filter> </activity> - <activity android:name=".samples.AppAdjustmentEditTextDialog" android:label="ET Dialog"> + <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" /> @@ -130,14 +130,6 @@ <category android:name="android.intent.category.IMF_TEST" /> </intent-filter> </activity> - - <activity android:name=".samples.OneEditTextActivityLandscape" android:label="OneEditTextActivityLandscape" 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> 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/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java deleted file mode 100644 index 15a29c8..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.android.imftest.samples; - -import com.android.imftest.R; - -import android.app.Activity; -import android.os.Bundle; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.LinearLayout; - -public class AppAdjustmentBigEditTextNonScrollablePanScan extends Activity { - - private LinearLayout mLayout; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - - mLayout = new LinearLayout(this); - mLayout.setOrientation(LinearLayout.VERTICAL); - mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); - - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mLayout, false); - - mLayout.addView(editText); - - setContentView(mLayout); - } - -} diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java deleted file mode 100644 index 0726823..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.android.imftest.samples; - -import com.android.imftest.R; - -import android.app.Activity; -import android.os.Bundle; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.LinearLayout; - -public class AppAdjustmentBigEditTextNonScrollableResize extends Activity { - - private LinearLayout mLayout; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - - mLayout = new LinearLayout(this); - mLayout.setOrientation(LinearLayout.VERTICAL); - mLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - ViewGroup.LayoutParams.FILL_PARENT)); - - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mLayout, false); - - mLayout.addView(editText); - - setContentView(mLayout); - } - -} 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/AppAdjustmentBigEditTextScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java index 50a980b..bb3f767 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java @@ -4,15 +4,17 @@ 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 AppAdjustmentBigEditTextScrollablePanScan extends Activity { +public class BigEditTextActivityScrollablePanScan extends Activity { - private ScrollView mScrollView; + private View mRootView; + private View mDefaultFocusedView; private LinearLayout mLayout; @Override @@ -21,9 +23,9 @@ public class AppAdjustmentBigEditTextScrollablePanScan extends Activity { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - mScrollView = new ScrollView(this); - mScrollView.setFillViewport(true); - mScrollView.setLayoutParams(new ViewGroup.LayoutParams( + mRootView = new ScrollView(this); + ((ScrollView) mRootView).setFillViewport(true); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); @@ -33,12 +35,23 @@ public class AppAdjustmentBigEditTextScrollablePanScan extends Activity { ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false); + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); - mLayout.addView(editText); - mScrollView.addView(mLayout); + mLayout.addView(view); - setContentView(mScrollView); + ((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/AppAdjustmentBigEditTextScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java index a256878..f2cae1c 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java @@ -4,15 +4,17 @@ 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 AppAdjustmentBigEditTextScrollableResize extends Activity { +public class BigEditTextActivityScrollableResize extends Activity { - private ScrollView mScrollView; + private View mRootView; + private View mDefaultFocusedView; private LinearLayout mLayout; @Override @@ -21,9 +23,9 @@ public class AppAdjustmentBigEditTextScrollableResize extends Activity { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - mScrollView = new ScrollView(this); - mScrollView.setFillViewport(true); - mScrollView.setLayoutParams(new ViewGroup.LayoutParams( + mRootView = new ScrollView(this); + ((ScrollView) mRootView).setFillViewport(true); + mRootView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); @@ -33,12 +35,23 @@ public class AppAdjustmentBigEditTextScrollableResize extends Activity { ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false); + View view = getLayoutInflater().inflate( + R.layout.full_screen_edit_text, ((ScrollView) mRootView), false); - mLayout.addView(editText); - mScrollView.addView(mLayout); + mLayout.addView(view); - setContentView(mScrollView); + ((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 index d74b9dd..51f5045 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java @@ -17,21 +17,30 @@ import com.android.imftest.R; */ public class BottomEditTextActivityPanScan extends Activity { - private LayoutInflater mInflater; + 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 LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); - mInflater = getLayoutInflater(); - - View view = mInflater.inflate(R.layout.one_edit_text_activity, layout, false); - layout.addView(view); + 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(layout); + 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 index 82da29a..eb94b4f 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java +++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java @@ -17,21 +17,30 @@ import com.android.imftest.R; */ public class BottomEditTextActivityResize extends Activity { - private LayoutInflater mInflater; + 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 LinearLayout(this); + ((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL); - mInflater = getLayoutInflater(); - - View view = mInflater.inflate(R.layout.one_edit_text_activity, layout, false); - layout.addView(view); + 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(layout); + 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 index 4233811..1191f19 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java +++ b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java @@ -13,6 +13,8 @@ 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) @@ -23,6 +25,8 @@ public class ButtonActivity extends Activity 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) @@ -36,7 +40,8 @@ public class ButtonActivity extends Activity } else { - imm.showSoftInput(null, 0); + myButton.requestFocusFromTouch(); + imm.showSoftInput(v, 0); myButton.setText("Keyboard DOWN!"); } @@ -48,5 +53,10 @@ public class ButtonActivity extends Activity 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/AppAdjustmentEditTextDialog.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java index e82f1d5..bd1e934 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java +++ b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java @@ -14,7 +14,7 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ScrollView; -public class AppAdjustmentEditTextDialog extends Activity { +public class EditTextActivityDialog extends Activity { private static final int SCROLLABLE_DIALOG_ID = 0; private static final int NONSCROLLABLE_DIALOG_ID = 1; @@ -75,18 +75,18 @@ public class AppAdjustmentEditTextDialog extends Activity { EditText editText; if (scrollable) { - layout = new ScrollView(AppAdjustmentEditTextDialog.this); + layout = new ScrollView(EditTextActivityDialog.this); ((ScrollView) layout).setMinimumHeight(mLayout.getHeight()); ((ScrollView) layout).addView(( - LinearLayout) View.inflate(AppAdjustmentEditTextDialog.this, + LinearLayout) View.inflate(EditTextActivityDialog.this, R.layout.dialog_edit_text_no_scroll, null)); } else { - layout = View.inflate(AppAdjustmentEditTextDialog.this, + layout = View.inflate(EditTextActivityDialog.this, R.layout.dialog_edit_text_no_scroll, null); } - Dialog d = new Dialog(AppAdjustmentEditTextDialog.this); + Dialog d = new Dialog(EditTextActivityDialog.this); d.setTitle(getString(R.string.test_dialog)); d.setCancelable(true); d.setContentView(layout); diff --git a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java deleted file mode 100644 index b596023..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java +++ /dev/null @@ -1,38 +0,0 @@ -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; - -public class EditTextActivityNoScrollPanScan extends Activity -{ - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); - - String string = new String(); - for (int i=0; i<9; i++) - { - final EditText editText = new EditText(this); - editText.setText(string.valueOf(i)); - layout.addView(editText); - } - setContentView(layout); - this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - } -} diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java index 4cb3af6..54ab57a 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java @@ -20,22 +20,31 @@ import com.android.internal.R; */ public class ManyEditTextActivityNoScrollPanScan extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); - - String string = new String(); - for (int i=0; i<9; i++) - { - final EditText editText = new EditText(this); - editText.setText(string.valueOf(i)); - layout.addView(editText); - } - setContentView(layout); - this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + 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 index bd32828..b228d34 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java @@ -20,26 +20,33 @@ import com.android.internal.R; */ public class ManyEditTextActivityScrollPanScan extends Activity { - private ScrollView mScrollView; - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - mScrollView = new ScrollView(this); - - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); - - String string = new String(); - for (int i=0; i<12; i++) - { - final EditText editText = new EditText(this); - editText.setText(string.valueOf(i)); - layout.addView(editText); - } - - mScrollView.addView(layout); - setContentView(mScrollView); - this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - } + 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 index eaaa98b..777fbae 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java +++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java @@ -2,6 +2,7 @@ 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; @@ -12,26 +13,33 @@ import android.widget.ScrollView; */ public class ManyEditTextActivityScrollResize extends Activity { - private ScrollView mScrollView; + public static final int NUM_EDIT_TEXTS = 12; + + private View mRootView; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mScrollView = new ScrollView(this); + mRootView = new ScrollView(this); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); - String string = new String(); - for (int i=0; i<12; i++) + for (int i=0; i<NUM_EDIT_TEXTS; i++) { final EditText editText = new EditText(this); - editText.setText(string.valueOf(i)); + editText.setText(String.valueOf(i)); + editText.setId(i); layout.addView(editText); } - mScrollView.addView(layout); - setContentView(mScrollView); - this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + ((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 index 5fef884..88a3447 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java +++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java @@ -2,6 +2,7 @@ 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; @@ -20,21 +21,36 @@ import com.android.internal.R; */ public class OneEditTextActivityNotSelected extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); - - final EditText editText = new EditText(this); - final TextView textView = new TextView(this); - textView.setText("The focus is here."); - layout.addView(editText); - layout.addView(textView); - - setContentView(layout); - textView.requestFocus(); + 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 index 2fd19e8..1b80263 100644 --- a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java +++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java @@ -20,18 +20,32 @@ import com.android.internal.R; */ public class OneEditTextActivitySelected extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); - - final EditText editText = new EditText(this); - layout.addView(editText); - - setContentView(layout); - editText.requestFocus(); + 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()); + } + +} diff --git a/tests/gadgets/GadgetHostTest/AndroidManifest.xml b/tests/gadgets/GadgetHostTest/AndroidManifest.xml index cac2776..52e314f 100644 --- a/tests/gadgets/GadgetHostTest/AndroidManifest.xml +++ b/tests/gadgets/GadgetHostTest/AndroidManifest.xml @@ -17,12 +17,20 @@ <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - <receiver android:name="TestGadgetProvider" android:label="@string/oh_hai" - android:icon="@drawable/oh_hai_icon"> + + <!-- BEGIN_INCLUDE(GadgetProvider) --> + <receiver android:name="TestGadgetProvider" + android:label="@string/oh_hai" + android:icon="@drawable/oh_hai_icon" + > <intent-filter> <action android:name="android.gadget.action.GADGET_UPDATE" /> </intent-filter> - <meta-data android:name="android.gadget.provider" android:resource="@xml/gadget_info" /> + <meta-data android:name="android.gadget.provider" + android:resource="@xml/gadget_info" + /> </receiver> + <!-- END_INCLUDE(GadgetProvider) --> + </application> </manifest> diff --git a/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml b/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml index 353df30..e0c4222 100644 --- a/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml +++ b/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml @@ -1,8 +1,10 @@ +<!-- BEGIN_INCLUDE(GadgetProviderInfo) --> <gadget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="40dp" android:minHeight="30dp" - android:updatePeriodMillis="3000" + android:updatePeriodMillis="86400000" android:initialLayout="@layout/test_gadget" android:configure="com.android.tests.gadgethost.TestGadgetConfigure" > </gadget-provider> +<!-- END_INCLUDE(GadgetProviderInfo) --> diff --git a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java index d3dcf41..0bd8926 100644 --- a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java +++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java @@ -23,7 +23,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.gadget.GadgetHost; import android.gadget.GadgetHostView; -import android.gadget.GadgetInfo; +import android.gadget.GadgetProviderInfo; import android.gadget.GadgetManager; import android.os.Bundle; import android.util.Log; @@ -73,14 +73,13 @@ public class GadgetHostActivity extends Activity }; void discoverGadget(int requestCode) { - Intent intent = new Intent(GadgetManager.GADGET_PICK_ACTION); - intent.putExtra(GadgetManager.EXTRA_HOST_ID, HOST_ID); + Intent intent = new Intent(GadgetManager.ACTION_GADGET_PICK); intent.putExtra(GadgetManager.EXTRA_GADGET_ID, mHost.allocateGadgetId()); startActivityForResult(intent, requestCode); } void configureGadget(int requestCode, int gadgetId, ComponentName configure) { - Intent intent = new Intent(GadgetManager.GADGET_CONFIGURE_ACTION); + Intent intent = new Intent(GadgetManager.ACTION_GADGET_CONFIGURE); intent.setComponent(configure); intent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId); SharedPreferences.Editor prefs = getPreferences(0).edit(); @@ -89,11 +88,13 @@ public class GadgetHostActivity extends Activity startActivityForResult(intent, requestCode); } - void handleGadgetPickResult(int resultCode, Intent data) { - Bundle extras = data.getExtras(); + void handleGadgetPickResult(int resultCode, Intent intent) { + // BEGIN_INCLUDE(getExtra_EXTRA_GADGET_ID) + Bundle extras = intent.getExtras(); int gadgetId = extras.getInt(GadgetManager.EXTRA_GADGET_ID); + // END_INCLUDE(getExtra_EXTRA_GADGET_ID) if (resultCode == RESULT_OK) { - GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId); + GadgetProviderInfo gadget = mGadgetManager.getGadgetInfo(gadgetId); if (gadget.configure != null) { // configure the gadget if we should @@ -115,14 +116,14 @@ public class GadgetHostActivity extends Activity return; } if (resultCode == RESULT_OK) { - GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId); + GadgetProviderInfo gadget = mGadgetManager.getGadgetInfo(gadgetId); addGadgetView(gadgetId, gadget); } else { mHost.deleteGadgetId(gadgetId); } } - void addGadgetView(int gadgetId, GadgetInfo gadget) { + void addGadgetView(int gadgetId, GadgetProviderInfo gadget) { // Inflate the gadget's RemoteViews GadgetHostView view = mHost.createView(this, gadgetId, gadget); @@ -188,11 +189,10 @@ public class GadgetHostActivity extends Activity } GadgetHost mHost = new GadgetHost(this, HOST_ID) { - protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) { + protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetProviderInfo gadget) { return new MyGadgetView(gadgetId); } }; - } diff --git a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java index 7614c9e..370a50b 100644 --- a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java +++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java @@ -37,16 +37,18 @@ public class TestGadgetProvider extends BroadcastReceiver { String action = intent.getAction(); Log.d(TAG, "intent=" + intent); - if (GadgetManager.GADGET_ENABLED_ACTION.equals(action)) { + if (GadgetManager.ACTION_GADGET_ENABLED.equals(action)) { Log.d(TAG, "ENABLED"); } - else if (GadgetManager.GADGET_DISABLED_ACTION.equals(action)) { + else if (GadgetManager.ACTION_GADGET_DISABLED.equals(action)) { Log.d(TAG, "DISABLED"); } - else if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) { + else if (GadgetManager.ACTION_GADGET_UPDATE.equals(action)) { Log.d(TAG, "UPDATE"); + // BEGIN_INCLUDE(getExtra_EXTRA_GADGET_IDS) Bundle extras = intent.getExtras(); int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS); + // END_INCLUDE(getExtra_EXTRA_GADGET_IDS) SharedPreferences prefs = context.getSharedPreferences( TestGadgetProvider.PREFS_NAME, 0); diff --git a/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml b/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml index 0b8ca2e..0fc7812 100644 --- a/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml +++ b/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml @@ -1,7 +1,7 @@ <gadget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="40dp" android:minHeight="30dp" - android:updatePeriodMillis="3000" + android:updatePeriodMillis="60000" android:initialLayout="@layout/test_gadget" > </gadget-provider> diff --git a/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java b/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java index 8622bc7..b81575f 100644 --- a/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java +++ b/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java @@ -34,13 +34,13 @@ public class TestGadgetProvider extends BroadcastReceiver { String action = intent.getAction(); Log.d(TAG, "intent=" + intent); - if (GadgetManager.GADGET_ENABLED_ACTION.equals(action)) { + if (GadgetManager.ACTION_GADGET_ENABLED.equals(action)) { Log.d(TAG, "ENABLED"); } - else if (GadgetManager.GADGET_DISABLED_ACTION.equals(action)) { + else if (GadgetManager.ACTION_GADGET_DISABLED.equals(action)) { Log.d(TAG, "DISABLED"); } - else if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) { + else if (GadgetManager.ACTION_GADGET_UPDATE.equals(action)) { Log.d(TAG, "UPDATE"); Bundle extras = intent.getExtras(); int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS); |