From 4ba34ff136727244ead91780152b3248fe7ce0fd Mon Sep 17 00:00:00 2001 From: jaekyun Date: Wed, 22 Apr 2015 21:22:48 -0700 Subject: [PATCH] Enable components_browsertests on Android BUG=465351 Review URL: https://codereview.chromium.org/1075783002 Cr-Commit-Position: refs/heads/master@{#326449} --- build/all.gyp | 1 + build/android/pylib/constants/__init__.py | 7 ++ build/android/pylib/gtest/gtest_config.py | 1 + build/android/pylib/gtest/gtest_test_instance.py | 7 +- .../android/pylib/gtest/local_device_gtest_run.py | 3 +- build/android/pylib/gtest/setup.py | 4 +- build/android/pylib/gtest/test_package_apk.py | 13 +++ build/android/pylib/gtest/test_runner.py | 1 + components/BUILD.gn | 22 +++++ .../password_form_conversion_utils_browsertest.cc | 50 ++++++----- components/components_browsertests.isolate | 18 +++- components/components_tests.gyp | 90 ++++++++++++++++++++ .../content/distillable_page_utils_browsertest.cc | 5 ++ .../distiller_page_web_contents_browsertest.cc | 5 ++ .../content/test/dom_distiller_js_browsertest.cc | 8 +- .../printing/renderer/print_web_view_helper.h | 23 +++-- .../test/print_web_view_helper_browsertest.cc | 94 ++++++++++++-------- components/test/DEPS | 10 +++ components/test/android/OWNERS | 3 + .../browsertests_apk/AndroidManifest.xml.jinja2 | 60 +++++++++++++ .../components_browser_tests_android.cc | 99 ++++++++++++++++++++++ .../components_browser_tests_android.h | 16 ++++ .../components_browser_tests_jni_onload.cc | 40 +++++++++ .../browsertests_apk/res/layout/test_activity.xml | 16 ++++ .../ComponentsBrowserTestsActivity.java | 75 ++++++++++++++++ .../ComponentsBrowserTestsApplication.java | 32 +++++++ 26 files changed, 635 insertions(+), 68 deletions(-) create mode 100644 components/test/android/OWNERS create mode 100644 components/test/android/browsertests_apk/AndroidManifest.xml.jinja2 create mode 100644 components/test/android/browsertests_apk/components_browser_tests_android.cc create mode 100644 components/test/android/browsertests_apk/components_browser_tests_android.h create mode 100644 components/test/android/browsertests_apk/components_browser_tests_jni_onload.cc create mode 100644 components/test/android/browsertests_apk/res/layout/test_activity.xml create mode 100644 components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java create mode 100644 components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java diff --git a/build/all.gyp b/build/all.gyp index d0cef6c4f4ee..255a35c57eef 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -833,6 +833,7 @@ '../base/base.gyp:base_unittests_apk', '../cc/blink/cc_blink_tests.gyp:cc_blink_unittests_apk', '../cc/cc_tests.gyp:cc_unittests_apk', + '../components/components_tests.gyp:components_browsertests_apk', '../components/components_tests.gyp:components_unittests_apk', '../content/content_shell_and_tests.gyp:content_browsertests_apk', '../content/content_shell_and_tests.gyp:content_gl_tests_apk', diff --git a/build/android/pylib/constants/__init__.py b/build/android/pylib/constants/__init__.py index fb5ce6db2ae6..6e92f6d322de 100644 --- a/build/android/pylib/constants/__init__.py +++ b/build/android/pylib/constants/__init__.py @@ -106,6 +106,13 @@ PACKAGE_INFO = { '/data/local/tmp/chrome-native-tests-command-line', None, None), + 'components_browsertests': PackageInfo( + 'org.chromium.components_browsertests_apk', + ('org.chromium.components_browsertests_apk' + + '.ComponentsBrowserTestsActivity'), + '/data/local/tmp/components-browser-tests-command-line', + None, + None), 'content_browsertests': PackageInfo( 'org.chromium.content_browsertests_apk', 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity', diff --git a/build/android/pylib/gtest/gtest_config.py b/build/android/pylib/gtest/gtest_config.py index 8608ed7004d7..6ce0fb1b1a47 100644 --- a/build/android/pylib/gtest/gtest_config.py +++ b/build/android/pylib/gtest/gtest_config.py @@ -6,6 +6,7 @@ # Add new suites here before upgrading them to the stable list below. EXPERIMENTAL_TEST_SUITES = [ + 'components_browsertests', 'content_gl_tests', 'heap_profiler_unittests', 'devtools_bridge_tests', diff --git a/build/android/pylib/gtest/gtest_test_instance.py b/build/android/pylib/gtest/gtest_test_instance.py index 186b8fcf4c97..b6f83b31b2e9 100644 --- a/build/android/pylib/gtest/gtest_test_instance.py +++ b/build/android/pylib/gtest/gtest_test_instance.py @@ -92,9 +92,10 @@ class GtestTestInstance(test_instance.TestInstance): raise ValueError('Platform mode currently supports only 1 gtest suite') self._suite = args.suite_name[0] - if self._suite == 'content_browsertests': - error_func('content_browsertests are not currently supported ' - 'in platform mode.') + if (self._suite == 'content_browsertests' or + self._suite == 'components_browsertests'): + error_func('%s are not currently supported ' + 'in platform mode.' % self._suite) self._apk_path = os.path.join( constants.GetOutDirectory(), 'apks', '%s.apk' % self._suite) else: diff --git a/build/android/pylib/gtest/local_device_gtest_run.py b/build/android/pylib/gtest/local_device_gtest_run.py index ff12d82ad9c8..fd143d60d58b 100644 --- a/build/android/pylib/gtest/local_device_gtest_run.py +++ b/build/android/pylib/gtest/local_device_gtest_run.py @@ -30,7 +30,8 @@ _MAX_SHARD_SIZE = 256 # TODO(jbudorick): Move this up to the test instance if the net test server is # handled outside of the APK for the remote_device environment. _SUITE_REQUIRES_TEST_SERVER_SPAWNER = [ - 'content_unittests', 'content_browsertests', 'net_unittests', 'unit_tests' + 'components_browsertests', 'content_unittests', 'content_browsertests', + 'net_unittests', 'unit_tests' ] class _ApkDelegate(object): diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py index 1b882caf3ab7..44662d087caa 100644 --- a/build/android/pylib/gtest/setup.py +++ b/build/android/pylib/gtest/setup.py @@ -31,6 +31,7 @@ ISOLATE_FILE_PATHS = { 'third_party/WebKit/Source/platform/heap/BlinkHeapUnitTests.isolate', 'breakpad_unittests': 'breakpad/breakpad_unittests.isolate', 'cc_perftests': 'cc/cc_perftests.isolate', + 'components_browsertests': 'components/components_browsertests.isolate', 'components_unittests': 'components/components_unittests.isolate', 'content_browsertests': 'content/content_browsertests.isolate', 'content_unittests': 'content/content_unittests.isolate', @@ -236,7 +237,8 @@ def Setup(test_options, devices): tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) # Coalesce unit tests into a single test per device - if test_options.suite_name != 'content_browsertests': + if (test_options.suite_name != 'content_browsertests' and + test_options.suite_name != 'components_browsertests'): num_devices = len(devices) tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] tests = [t for t in tests if t] diff --git a/build/android/pylib/gtest/test_package_apk.py b/build/android/pylib/gtest/test_package_apk.py index 3e579d20eb83..8da3c749dbc6 100644 --- a/build/android/pylib/gtest/test_package_apk.py +++ b/build/android/pylib/gtest/test_package_apk.py @@ -34,6 +34,10 @@ class TestPackageApk(TestPackage): self.suite_path = os.path.join( constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) self._package_info = constants.PACKAGE_INFO['content_browsertests'] + elif suite_name == 'components_browsertests': + self.suite_path = os.path.join( + constants.GetOutDirectory(), 'apks', '%s.apk' % suite_name) + self._package_info = constants.PACKAGE_INFO['components_browsertests'] else: self.suite_path = os.path.join( constants.GetOutDirectory(), '%s_apk' % suite_name, @@ -90,6 +94,15 @@ class TestPackageApk(TestPackage): # TODO(jbudorick) Handle this exception appropriately once the # conversions are done. pass + elif self.suite_name == 'components_browsertests': + try: + device.RunShellCommand( + 'rm -r %s/components_shell' % device.GetExternalStoragePath(), + timeout=60 * 2) + except device_errors.CommandFailedError: + # TODO(jbudorick) Handle this exception appropriately once the + # conversions are done. + pass #override def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): diff --git a/build/android/pylib/gtest/test_runner.py b/build/android/pylib/gtest/test_runner.py index b561058d8c80..49263888c34a 100644 --- a/build/android/pylib/gtest/test_runner.py +++ b/build/android/pylib/gtest/test_runner.py @@ -34,6 +34,7 @@ _INFRA_STDOUT_TIMEOUT = 20 * 60 def _TestSuiteRequiresMockTestServer(suite_name): """Returns True if the test suite requires mock test server.""" tests_require_net_test_server = ['unit_tests', 'net_unittests', + 'components_browsertests', 'content_unittests', 'content_browsertests'] return (suite_name in diff --git a/components/BUILD.gn b/components/BUILD.gn index 95761c19b55c..01503dc10791 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn @@ -334,6 +334,17 @@ repack("components_tests_pak") { ] } +if (is_android) { + import("//build/config/android/rules.gni") + + generate_jni("components_browsertests_jni_headers") { + jni_package = "components_browsertests/shell" + sources = [ + "test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java", + ] + } +} + test("components_browsertests") { sources = [ "autofill/content/browser/risk/fingerprint_browsertest.cc", @@ -369,7 +380,18 @@ test("components_browsertests") { data_deps = [ ":components_tests_pak" ] if (is_android) { + sources += [ + "test/android/browsertests_apk/components_browser_tests_android.cc", + "test/android/browsertests_apk/components_browser_tests_android.h", + "test/android/browsertests_apk/components_browser_tests_jni_onload.cc", + ] sources -= [ "autofill/content/browser/risk/fingerprint_browsertest.cc" ] + deps += [ + ":components_browsertests_jni_headers", + "//testing/android/native_test:native_test_util", + ] + + use_launcher = false } if (is_linux) { diff --git a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc index d4b3f455a55b..6971997176fc 100644 --- a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc +++ b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc @@ -105,10 +105,19 @@ class PasswordFormBuilder { DISALLOW_COPY_AND_ASSIGN(PasswordFormBuilder); }; -class PasswordFormConversionUtilsTest : public content::RenderViewTest { +// RenderVIewTest-based tests crash on Android +// http://crbug.com/187500 +#if defined(OS_ANDROID) +#define MAYBE_PasswordFormConversionUtilsTest \ + DISABLED_PasswordFormConversionUtilsTest +#else +#define MAYBE_PasswordFormConversionUtilsTest PasswordFormConversionUtilsTest +#endif // defined(OS_ANDROID) + +class MAYBE_PasswordFormConversionUtilsTest : public content::RenderViewTest { public: - PasswordFormConversionUtilsTest() : content::RenderViewTest() {} - ~PasswordFormConversionUtilsTest() override {} + MAYBE_PasswordFormConversionUtilsTest() : content::RenderViewTest() {} + ~MAYBE_PasswordFormConversionUtilsTest() override {} protected: // Loads the given |html|, retrieves the sole WebFormElement from it, and then @@ -138,12 +147,12 @@ class PasswordFormConversionUtilsTest : public content::RenderViewTest { } private: - DISALLOW_COPY_AND_ASSIGN(PasswordFormConversionUtilsTest); + DISALLOW_COPY_AND_ASSIGN(MAYBE_PasswordFormConversionUtilsTest); }; } // namespace -TEST_F(PasswordFormConversionUtilsTest, BasicFormAttributes) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, BasicFormAttributes) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username", "johnsmith", NULL); builder.AddSubmitButton("inactive_submit", false); @@ -170,7 +179,7 @@ TEST_F(PasswordFormConversionUtilsTest, BasicFormAttributes) { EXPECT_EQ(PasswordForm::TYPE_MANUAL, password_form->type); } -TEST_F(PasswordFormConversionUtilsTest, DisabledFieldsAreIgnored) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, DisabledFieldsAreIgnored) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username", "johnsmith", NULL); builder.AddDisabledUsernameField(); @@ -188,7 +197,7 @@ TEST_F(PasswordFormConversionUtilsTest, DisabledFieldsAreIgnored) { EXPECT_EQ(base::UTF8ToUTF16("secret"), password_form->password_value); } -TEST_F(PasswordFormConversionUtilsTest, IdentifyingUsernameFields) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingUsernameFields) { // Each test case consists of a set of parameters to be plugged into the // PasswordFormBuilder below, plus the corresponding expectations. struct TestCase { @@ -273,7 +282,7 @@ TEST_F(PasswordFormConversionUtilsTest, IdentifyingUsernameFields) { } } -TEST_F(PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { // Each test case consists of a set of parameters to be plugged into the // PasswordFormBuilder below, plus the corresponding expectations. struct TestCase { @@ -328,7 +337,7 @@ TEST_F(PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { } } -TEST_F(PasswordFormConversionUtilsTest, IdentifyingThreePasswordFields) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingThreePasswordFields) { // Each test case consists of a set of parameters to be plugged into the // PasswordFormBuilder below, plus the corresponding expectations. struct TestCase { @@ -389,7 +398,7 @@ TEST_F(PasswordFormConversionUtilsTest, IdentifyingThreePasswordFields) { } } -TEST_F(PasswordFormConversionUtilsTest, +TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingPasswordFieldsWithAutocompleteAttributes) { // Each test case consists of a set of parameters to be plugged into the // PasswordFormBuilder below, plus the corresponding expectations. @@ -527,7 +536,7 @@ TEST_F(PasswordFormConversionUtilsTest, } } -TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToBadActionURL) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, InvalidFormDueToBadActionURL) { PasswordFormBuilder builder("invalid_target"); builder.AddUsernameField("username", "JohnSmith", NULL); builder.AddSubmitButton("submit", true); @@ -539,7 +548,8 @@ TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToBadActionURL) { EXPECT_FALSE(password_form); } -TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToNoPasswordFields) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, + InvalidFormDueToNoPasswordFields) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username1", "John", NULL); builder.AddUsernameField("username2", "Smith", NULL); @@ -551,7 +561,7 @@ TEST_F(PasswordFormConversionUtilsTest, InvalidFormDueToNoPasswordFields) { EXPECT_FALSE(password_form); } -TEST_F(PasswordFormConversionUtilsTest, +TEST_F(MAYBE_PasswordFormConversionUtilsTest, InvalidFormsDueToConfusingPasswordFields) { // Each test case consists of a set of parameters to be plugged into the // PasswordFormBuilder below. @@ -582,7 +592,7 @@ TEST_F(PasswordFormConversionUtilsTest, } } -TEST_F(PasswordFormConversionUtilsTest, +TEST_F(MAYBE_PasswordFormConversionUtilsTest, InvalidFormDueToTooManyPasswordFieldsWithoutAutocompleteAttributes) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username1", "John", NULL); @@ -598,7 +608,7 @@ TEST_F(PasswordFormConversionUtilsTest, EXPECT_FALSE(password_form); } -TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLogin) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationLogin) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddHiddenField(); builder.AddUsernameField("username", "", nullptr); @@ -612,7 +622,7 @@ TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLogin) { EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, login_form->layout); } -TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationSignup) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationSignup) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("someotherfield", "", nullptr); builder.AddUsernameField("username", "", nullptr); @@ -628,7 +638,7 @@ TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationSignup) { EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, signup_form->layout); } -TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationChange) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, LayoutClassificationChange) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username", "", nullptr); builder.AddPasswordField("old_password", "", nullptr); @@ -644,7 +654,8 @@ TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationChange) { EXPECT_EQ(PasswordForm::Layout::LAYOUT_OTHER, change_form->layout); } -TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLoginPlusSignup_A) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, + LayoutClassificationLoginPlusSignup_A) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username", "", nullptr); builder.AddHiddenField(); @@ -665,7 +676,8 @@ TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLoginPlusSignup_A) { login_plus_signup_form->layout); } -TEST_F(PasswordFormConversionUtilsTest, LayoutClassificationLoginPlusSignup_B) { +TEST_F(MAYBE_PasswordFormConversionUtilsTest, + LayoutClassificationLoginPlusSignup_B) { PasswordFormBuilder builder(kTestFormActionURL); builder.AddUsernameField("username", "", nullptr); builder.AddHiddenField(); diff --git a/components/components_browsertests.isolate b/components/components_browsertests.isolate index 2dff53aee441..e60cea1db35a 100644 --- a/components/components_browsertests.isolate +++ b/components/components_browsertests.isolate @@ -34,18 +34,32 @@ ], }, }], + ['OS=="android"', { + 'variables': { + 'files': [ + '<(PRODUCT_DIR)/components_browsertests_apk_shell/assets/components_tests_resources.pak', + '<(PRODUCT_DIR)/components_browsertests_apk_shell/assets/content_shell.pak', + ], + }, + }], ['OS=="linux" or OS=="mac" or OS=="win"', { 'variables': { 'files': [ - 'test/data/', '../testing/test_env.py', - '../third_party/dom_distiller_js/dist/test/data/', '<(PRODUCT_DIR)/components_browsertests<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/components_tests_resources.pak', '<(PRODUCT_DIR)/content_shell.pak', ], }, }], + ['OS=="android" or OS=="linux" or OS=="mac" or OS=="win"', { + 'variables': { + 'files': [ + 'test/data/', + '../third_party/dom_distiller_js/dist/test/data/', + ], + }, + }], ['OS=="linux"', { 'variables': { 'files': [ diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 64cdc9d0a868..f48690f0033e 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -1123,6 +1123,87 @@ }, ], 'conditions': [ + ['OS == "android"', { + 'variables': { + 'components_browsertests_pak_input_resources': [ + '<(PRODUCT_DIR)/components_tests_resources.pak', + '<(PRODUCT_DIR)/content_shell/assets/content_shell.pak', + ], + 'conditions': [ + ['icu_use_data_file_flag==1', { + 'components_browsertests_pak_input_resources': [ + '<(PRODUCT_DIR)/icudtl.dat', + ], + }], + ['v8_use_external_startup_data==1', { + 'components_browsertests_pak_input_resources': [ + '<(PRODUCT_DIR)/natives_blob.bin', + '<(PRODUCT_DIR)/snapshot_blob.bin', + ], + }], + ], + }, + 'targets': [ + { + 'target_name': 'components_browsertests_paks_copy', + 'type': 'none', + 'dependencies': [ + 'components_browsertests', + ], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/components_browsertests_apk_shell/assets', + 'files': [ + '<@(components_browsertests_pak_input_resources)', + ], + } + ], + }, + { + 'target_name': 'components_browsertests_manifest', + 'type': 'none', + 'variables': { + 'jinja_inputs': ['test/android/browsertests_apk/AndroidManifest.xml.jinja2'], + 'jinja_output': '<(SHARED_INTERMEDIATE_DIR)/components_browsertests_manifest/AndroidManifest.xml', + }, + 'includes': [ '../build/android/jinja_template.gypi' ], + }, + { + 'target_name': 'components_browsertests_jni_headers', + 'type': 'none', + 'sources': [ + 'test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java', + ], + 'variables': { + 'jni_gen_package': 'content/shell', + }, + 'includes': [ '../build/jni_generator.gypi' ], + }, + { + # TODO(GN) + 'target_name': 'components_browsertests_apk', + 'type': 'none', + 'dependencies': [ + '../content/content.gyp:content_icudata', + '../content/content.gyp:content_java', + '../content/content.gyp:content_v8_external_data', + '../content/content_shell_and_tests.gyp:content_java_test_support', + '../content/content_shell_and_tests.gyp:content_shell_java', + 'components_browsertests_paks_copy', + 'components_browsertests', + ], + 'variables': { + 'apk_name': 'components_browsertests', + 'java_in_dir': 'test/android/browsertests_apk', + 'android_manifest_path': '<(SHARED_INTERMEDIATE_DIR)/components_browsertests_manifest/AndroidManifest.xml', + 'resource_dir': 'test/android/browsertests_apk/res', + 'native_lib_target': 'libcomponents_browsertests', + 'asset_location': '<(PRODUCT_DIR)/components_browsertests_apk_shell/assets', + }, + 'includes': [ '../build/java_apk.gypi' ], + }, + ], + }], ['OS != "ios"', { 'targets': [ { @@ -1204,9 +1285,18 @@ ], 'conditions': [ ['OS == "android"', { + 'sources' : [ + 'test/android/browsertests_apk/components_browser_tests_android.cc', + 'test/android/browsertests_apk/components_browser_tests_android.h', + 'test/android/browsertests_apk/components_browser_tests_jni_onload.cc', + ], 'sources!': [ 'autofill/content/browser/risk/fingerprint_browsertest.cc', ], + 'dependencies': [ + '../testing/android/native_test.gyp:native_test_util', + 'components_browsertests_jni_headers', + ], }], ['OS == "linux"', { 'sources': [ diff --git a/components/dom_distiller/content/distillable_page_utils_browsertest.cc b/components/dom_distiller/content/distillable_page_utils_browsertest.cc index 952598289d34..c320eedb4a15 100644 --- a/components/dom_distiller/content/distillable_page_utils_browsertest.cc +++ b/components/dom_distiller/content/distillable_page_utils_browsertest.cc @@ -50,7 +50,12 @@ class DomDistillerDistillablePageUtilsTest : public content::ContentBrowserTest, void AddComponentsResources() { base::FilePath pak_file; base::FilePath pak_dir; +#if defined(OS_ANDROID) + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir)); + pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks")); +#else PathService::Get(base::DIR_MODULE, &pak_dir); +#endif // OS_ANDROID pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_tests_resources.pak")); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( diff --git a/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc b/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc index 79d557a896f5..d1d2dffe5cc3 100644 --- a/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc +++ b/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc @@ -104,7 +104,12 @@ class DistillerPageWebContentsTest : public ContentBrowserTest { void AddComponentsResources() { base::FilePath pak_file; base::FilePath pak_dir; +#if defined(OS_ANDROID) + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir)); + pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks")); +#else PathService::Get(base::DIR_MODULE, &pak_dir); +#endif // OS_ANDROID pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_tests_resources.pak")); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( diff --git a/components/dom_distiller/content/test/dom_distiller_js_browsertest.cc b/components/dom_distiller/content/test/dom_distiller_js_browsertest.cc index 53b37b6639d4..6d26962ac934 100644 --- a/components/dom_distiller/content/test/dom_distiller_js_browsertest.cc +++ b/components/dom_distiller/content/test/dom_distiller_js_browsertest.cc @@ -76,8 +76,14 @@ class DomDistillerJsTest : public content::ContentBrowserTest { void AddComponentsResources() { base::FilePath pak_file; base::FilePath pak_dir; +#if defined(OS_ANDROID) + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir)); + pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks")); +#else PathService::Get(base::DIR_MODULE, &pak_dir); - pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); +#endif // OS_ANDROID + pak_file = + pak_dir.Append(FILE_PATH_LITERAL("components_tests_resources.pak")); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( pak_file, ui::SCALE_FACTOR_NONE); } diff --git a/components/printing/renderer/print_web_view_helper.h b/components/printing/renderer/print_web_view_helper.h index d040dbc82096..562b1e0d6756 100644 --- a/components/printing/renderer/print_web_view_helper.h +++ b/components/printing/renderer/print_web_view_helper.h @@ -26,6 +26,17 @@ struct PrintMsg_PrintPage_Params; struct PrintMsg_PrintPages_Params; struct PrintHostMsg_SetOptionsFromDocument_Params; +// RenderVIewTest-based tests crash on Android +// http://crbug.com/187500 +#if defined(OS_ANDROID) +#define MAYBE_PrintWebViewHelperTest DISABLED_PrintWebViewHelperTest +#define MAYBE_PrintWebViewHelperPreviewTest \ + DISABLED_PrintWebViewHelperPreviewTest +#else +#define MAYBE_PrintWebViewHelperTest PrintWebViewHelperTest +#define MAYBE_PrintWebViewHelperPreviewTest PrintWebViewHelperPreviewTest +#endif // defined(OS_ANDROID) + namespace base { class DictionaryValue; } @@ -115,16 +126,16 @@ class PrintWebViewHelper private: friend class PrintWebViewHelperTestBase; - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperPreviewTest, + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting); - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, OnPrintPages); - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperTest, OnPrintPages); + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperTest, BlockScriptInitiatedPrinting); - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperTest, BlockScriptInitiatedPrintingFromPopup); #if defined(OS_WIN) || defined(OS_MACOSX) - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintLayoutTest); - FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperTest, PrintWithIframe); + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperTest, PrintLayoutTest); + FRIEND_TEST_ALL_PREFIXES(MAYBE_PrintWebViewHelperTest, PrintWithIframe); #endif // defined(OS_WIN) || defined(OS_MACOSX) enum PrintingResult { diff --git a/components/printing/test/print_web_view_helper_browsertest.cc b/components/printing/test/print_web_view_helper_browsertest.cc index bfdc311dd9d3..65ecc23ba4c4 100644 --- a/components/printing/test/print_web_view_helper_browsertest.cc +++ b/components/printing/test/print_web_view_helper_browsertest.cc @@ -248,22 +248,30 @@ class PrintWebViewHelperTestBase : public content::RenderViewTest { DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase); }; -class PrintWebViewHelperTest : public PrintWebViewHelperTestBase { +// RenderVIewTest-based tests crash on Android +// http://crbug.com/187500 +#if defined(OS_ANDROID) +#define MAYBE_PrintWebViewHelperTest DISABLED_PrintWebViewHelperTest +#else +#define MAYBE_PrintWebViewHelperTest PrintWebViewHelperTest +#endif // defined(OS_ANDROID) + +class MAYBE_PrintWebViewHelperTest : public PrintWebViewHelperTestBase { public: - PrintWebViewHelperTest() {} - ~PrintWebViewHelperTest() override {} + MAYBE_PrintWebViewHelperTest() {} + ~MAYBE_PrintWebViewHelperTest() override {} void SetUp() override { PrintWebViewHelperTestBase::SetUp(); } protected: - DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); + DISALLOW_COPY_AND_ASSIGN(MAYBE_PrintWebViewHelperTest); }; // This tests only for platforms without print preview. #if !defined(ENABLE_PRINT_PREVIEW) // Tests that the renderer blocks window.print() calls if they occur too // frequently. -TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrinting) { +TEST_F(MAYBE_PrintWebViewHelperTest, BlockScriptInitiatedPrinting) { // Pretend user will cancel printing. print_render_thread_->set_print_dialog_user_response(false); // Try to print with window.print() a few times. @@ -287,7 +295,7 @@ TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrinting) { // Tests that the renderer always allows window.print() calls if they are user // initiated. -TEST_F(PrintWebViewHelperTest, AllowUserOriginatedPrinting) { +TEST_F(MAYBE_PrintWebViewHelperTest, AllowUserOriginatedPrinting) { // Pretend user will cancel printing. print_render_thread_->set_print_dialog_user_response(false); // Try to print with window.print() a few times. @@ -325,7 +333,7 @@ TEST_F(PrintWebViewHelperTest, AllowUserOriginatedPrinting) { } // Duplicate of OnPrintPagesTest only using javascript to print. -TEST_F(PrintWebViewHelperTest, PrintWithJavascript) { +TEST_F(MAYBE_PrintWebViewHelperTest, PrintWithJavascript) { PrintWithJavaScript(); VerifyPageCount(1); @@ -336,7 +344,7 @@ TEST_F(PrintWebViewHelperTest, PrintWithJavascript) { #if defined(ENABLE_BASIC_PRINTING) // Tests that printing pages work and sending and receiving messages through // that channel all works. -TEST_F(PrintWebViewHelperTest, OnPrintPages) { +TEST_F(MAYBE_PrintWebViewHelperTest, OnPrintPages) { LoadHTML(kHelloWorldHTML); OnPrintPages(); @@ -350,7 +358,7 @@ TEST_F(PrintWebViewHelperTest, OnPrintPages) { // to rip out and replace most of the IPC code if we ever plan to improve // printing, and the comment below by sverrir suggests that it doesn't do much // for us anyway. -TEST_F(PrintWebViewHelperTest, PrintWithIframe) { +TEST_F(MAYBE_PrintWebViewHelperTest, PrintWithIframe) { // Document that populates an iframe. const char html[] = "Lorem Ipsum:" @@ -440,7 +448,7 @@ const TestPageData kTestPages[] = { // metafile directly. // Same for printing via PDF on Windows. #if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING) -TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { +TEST_F(MAYBE_PrintWebViewHelperTest, PrintLayoutTest) { bool baseline = false; EXPECT_TRUE(print_render_thread_->printer() != NULL); @@ -496,10 +504,20 @@ TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { // These print preview tests do not work on Chrome OS yet. #if !defined(OS_CHROMEOS) -class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { + +// RenderVIewTest-based tests crash on Android +// http://crbug.com/187500 +#if defined(OS_ANDROID) +#define MAYBE_PrintWebViewHelperPreviewTest \ + DISABLED_PrintWebViewHelperPreviewTest +#else +#define MAYBE_PrintWebViewHelperPreviewTest PrintWebViewHelperPreviewTest +#endif // defined(OS_ANDROID) + +class MAYBE_PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { public: - PrintWebViewHelperPreviewTest() {} - ~PrintWebViewHelperPreviewTest() override {} + MAYBE_PrintWebViewHelperPreviewTest() {} + ~MAYBE_PrintWebViewHelperPreviewTest() override {} protected: void VerifyPrintPreviewCancelled(bool did_cancel) { @@ -591,11 +609,11 @@ class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { } } - DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperPreviewTest); + DISALLOW_COPY_AND_ASSIGN(MAYBE_PrintWebViewHelperPreviewTest); }; #if defined(ENABLE_PRINT_PREVIEW) -TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { +TEST_F(MAYBE_PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { LoadHTML(kHelloWorldHTML); PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); print_web_view_helper->SetScriptedPrintBlocked(true); @@ -607,7 +625,7 @@ TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { VerifyPreviewRequest(true); } -TEST_F(PrintWebViewHelperPreviewTest, PrintWithJavaScript) { +TEST_F(MAYBE_PrintWebViewHelperPreviewTest, PrintWithJavaScript) { LoadHTML(kPrintOnUserAction); gfx::Size new_size(200, 100); Resize(new_size, gfx::Rect(), false); @@ -630,7 +648,7 @@ TEST_F(PrintWebViewHelperPreviewTest, PrintWithJavaScript) { // Tests that print preview work and sending and receiving messages through // that channel all works. -TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreview) { +TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreview) { LoadHTML(kHelloWorldHTML); // Fill in some dummy values. @@ -646,7 +664,8 @@ TEST_F(PrintWebViewHelperPreviewTest, OnPrintPreview) { VerifyPagesPrinted(false); } -TEST_F(PrintWebViewHelperPreviewTest, PrintPreviewHTMLWithPageMarginsCss) { +TEST_F(MAYBE_PrintWebViewHelperPreviewTest, + PrintPreviewHTMLWithPageMarginsCss) { // A simple web page with print margins css. const char kHTMLWithPageMarginsCss[] = "