From da996f390e17e16f2dfa60e972e7ebc4f868f37e Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Fri, 13 Feb 2009 12:57:50 -0800 Subject: auto import from //branches/cupcake/...@131421 --- tests/AndroidTests/AndroidManifest.xml | 1 + .../src/com/android/unit_tests/MenuTest.java | 15 +-- .../src/com/android/unit_tests/TextUtilsTest.java | 2 +- tests/DumpRenderTree/compare_layout_results.py | 33 +++-- tests/DumpRenderTree/run_layout_tests.py | 108 ++++++++++++++++- .../android/dumprendertree/HTMLHostActivity.java | 19 ++- tests/ImfTest/AndroidManifest.xml | 18 +-- tests/ImfTest/res/values/config.xml | 21 ++++ ...pAdjustmentBigEditTextNonScrollablePanScan.java | 35 ------ ...ppAdjustmentBigEditTextNonScrollableResize.java | 35 ------ .../AppAdjustmentBigEditTextScrollablePanScan.java | 44 ------- .../AppAdjustmentBigEditTextScrollableResize.java | 44 ------- .../samples/AppAdjustmentEditTextDialog.java | 96 --------------- .../BigEditTextActivityNonScrollablePanScan.java | 49 ++++++++ .../BigEditTextActivityNonScrollableResize.java | 49 ++++++++ .../BigEditTextActivityScrollablePanScan.java | 57 +++++++++ .../BigEditTextActivityScrollableResize.java | 57 +++++++++ .../samples/BottomEditTextActivityPanScan.java | 25 ++-- .../samples/BottomEditTextActivityResize.java | 25 ++-- .../android/imftest/samples/ButtonActivity.java | 12 +- .../imftest/samples/EditTextActivityDialog.java | 96 +++++++++++++++ .../samples/EditTextActivityNoScrollPanScan.java | 38 ------ .../ManyEditTextActivityNoScrollPanScan.java | 43 ++++--- .../samples/ManyEditTextActivityScrollPanScan.java | 51 ++++---- .../samples/ManyEditTextActivityScrollResize.java | 24 ++-- .../samples/OneEditTextActivityNotSelected.java | 48 +++++--- .../samples/OneEditTextActivitySelected.java | 40 ++++-- tests/ImfTest/tests/Android.mk | 16 +++ tests/ImfTest/tests/AndroidManifest.xml | 34 ++++++ ...gEditTextActivityNonScrollablePanScanTests.java | 49 ++++++++ ...igEditTextActivityNonScrollableResizeTests.java | 48 ++++++++ .../BigEditTextActivityScrollablePanScanTests.java | 48 ++++++++ .../BigEditTextActivityScrollableResizeTests.java | 49 ++++++++ .../BottomEditTextActivityPanScanTests.java | 49 ++++++++ .../samples/BottomEditTextActivityResizeTests.java | 49 ++++++++ .../imftest/samples/ButtonActivityTest.java | 58 +++++++++ .../android/imftest/samples/ImfBaseTestCase.java | 135 +++++++++++++++++++++ .../samples/ManyEditTextActivityBaseTestCase.java | 40 ++++++ .../ManyEditTextActivityNoScrollPanScanTests.java | 36 ++++++ .../ManyEditTextActivityScrollPanScanTests.java | 37 ++++++ .../ManyEditTextActivityScrollResizeTests.java | 37 ++++++ .../OneEditTextActivityNotSelectedTests.java | 50 ++++++++ .../samples/OneEditTextActivitySelectedTests.java | 53 ++++++++ tests/gadgets/GadgetHostTest/AndroidManifest.xml | 14 ++- .../gadgets/GadgetHostTest/res/xml/gadget_info.xml | 4 +- .../tests/gadgethost/GadgetHostActivity.java | 22 ++-- .../tests/gadgethost/TestGadgetProvider.java | 8 +- .../GadgetProviderTest/res/xml/gadget_info.xml | 2 +- .../tests/gadgetprovider/TestGadgetProvider.java | 6 +- 49 files changed, 1472 insertions(+), 457 deletions(-) create mode 100644 tests/ImfTest/res/values/config.xml delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java create mode 100644 tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java create mode 100644 tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java create mode 100644 tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java create mode 100644 tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java create mode 100644 tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java delete mode 100644 tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java create mode 100755 tests/ImfTest/tests/Android.mk create mode 100755 tests/ImfTest/tests/AndroidManifest.xml create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScanTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResizeTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScanTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BigEditTextActivityScrollableResizeTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityPanScanTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/BottomEditTextActivityResizeTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ButtonActivityTest.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityBaseTestCase.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScanTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScanTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/ManyEditTextActivityScrollResizeTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivityNotSelectedTests.java create mode 100755 tests/ImfTest/tests/src/com/android/imftest/samples/OneEditTextActivitySelectedTests.java (limited to 'tests') 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 @@ + 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 fixes = Maps.newHashMap(); fixes.put("a", ""); fixes.put("a b", ""); - fixes.put("a@b", ""); + fixes.put("a@b", ""); for (Map.Entry 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 @@ - + @@ -35,7 +35,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -130,14 +130,6 @@ - - - - - - - - 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 @@ + + + + false + 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/AppAdjustmentBigEditTextScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java deleted file mode 100644 index 50a980b..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java +++ /dev/null @@ -1,44 +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; -import android.widget.ScrollView; - -public class AppAdjustmentBigEditTextScrollablePanScan extends Activity { - - private ScrollView mScrollView; - private LinearLayout mLayout; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - - mScrollView = new ScrollView(this); - mScrollView.setFillViewport(true); - mScrollView.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)); - - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false); - - mLayout.addView(editText); - mScrollView.addView(mLayout); - - setContentView(mScrollView); - } - -} diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java deleted file mode 100644 index a256878..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java +++ /dev/null @@ -1,44 +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; -import android.widget.ScrollView; - -public class AppAdjustmentBigEditTextScrollableResize extends Activity { - - private ScrollView mScrollView; - private LinearLayout mLayout; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); - - mScrollView = new ScrollView(this); - mScrollView.setFillViewport(true); - mScrollView.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)); - - EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false); - - mLayout.addView(editText); - mScrollView.addView(mLayout); - - setContentView(mScrollView); - } - -} diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java deleted file mode 100644 index e82f1d5..0000000 --- a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java +++ /dev/null @@ -1,96 +0,0 @@ -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 AppAdjustmentEditTextDialog 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(AppAdjustmentEditTextDialog.this); - ((ScrollView) layout).setMinimumHeight(mLayout.getHeight()); - - ((ScrollView) layout).addView(( - LinearLayout) View.inflate(AppAdjustmentEditTextDialog.this, - R.layout.dialog_edit_text_no_scroll, null)); - } else { - layout = View.inflate(AppAdjustmentEditTextDialog.this, - R.layout.dialog_edit_text_no_scroll, null); - } - - Dialog d = new Dialog(AppAdjustmentEditTextDialog.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/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 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/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/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 + + + + + + + + + + + + + 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 { + + 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 { + + 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 { + + 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 { + + 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 { + + 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 { + + 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 { + + 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 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 mTargetActivityClass; + + public ImfBaseTestCase(Class 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 extends ImfBaseTestCase { + + public ManyEditTextActivityBaseTestCase(Class 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 { + + 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 { + + 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 { + + 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 { + + 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 { + + 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 @@ - + + + - + + + 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 @@ + + 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 @@ 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); -- cgit v1.1