Commit aa81ccc3 authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Refactor //ios/web_view sources into its own source_set target

- This avoids rebuilding the same sources for the framework and test.
- Created a stub implementation of ios_web_view::InitializeGlobalState
  to avoid multiple AtExitManagers in unit tests.

Change-Id: Ia1a839f2be06d8a9e2974d2e8edb9cf399e849cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2121035
Commit-Queue: John Wu <jzw@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756028}
parent 0c490696
......@@ -100,7 +100,9 @@ if (ios_web_view_enable_autofill) {
]
}
ios_web_view_sources = [
source_set("web_view_sources") {
sources = ios_web_view_public_headers
sources += [
"internal/app/application_context.h",
"internal/app/application_context.mm",
"internal/app/web_view_io_thread.h",
......@@ -216,7 +218,6 @@ ios_web_view_sources = [
"internal/web_view_early_page_script_provider.h",
"internal/web_view_early_page_script_provider.mm",
"internal/web_view_global_state_util.h",
"internal/web_view_global_state_util.mm",
"internal/web_view_java_script_dialog_presenter.h",
"internal/web_view_java_script_dialog_presenter.mm",
"internal/web_view_url_request_context_getter.h",
......@@ -231,17 +232,16 @@ ios_web_view_sources = [
"internal/web_view_web_state_policy_decider.mm",
"internal/webdata_services/web_view_web_data_service_wrapper_factory.h",
"internal/webdata_services/web_view_web_data_service_wrapper_factory.mm",
]
ios_web_view_sources += ios_web_view_public_headers
if (ios_web_view_enable_sync) {
ios_web_view_sources += [
]
if (ios_web_view_enable_sync) {
sources += [
"internal/signin/cwv_identity.mm",
"internal/sync/cwv_sync_controller.mm",
"internal/sync/cwv_sync_controller_internal.h",
]
}
if (ios_web_view_enable_autofill) {
ios_web_view_sources += [
}
if (ios_web_view_enable_autofill) {
sources += [
"internal/autofill/cwv_autofill_client_ios_bridge.h",
"internal/autofill/cwv_autofill_controller.mm",
"internal/autofill/cwv_autofill_controller_internal.h",
......@@ -268,9 +268,9 @@ if (ios_web_view_enable_autofill) {
"internal/passwords/cwv_password_controller.mm",
"internal/passwords/cwv_password_internal.h",
]
}
}
ios_web_view_deps = [
public_deps = [
":web_view_all_frames",
":web_view_buildflags",
":web_view_main_frame",
......@@ -341,7 +341,13 @@ ios_web_view_deps = [
"//services/network:network_service",
"//ui/base",
"//url",
]
]
configs += [
":config",
"//build/config/compiler:enable_arc",
]
}
# Generate the umbrella header to exclude headers for disabled features.
# This is preferable to guarding header imports using flags defined in
......@@ -375,13 +381,16 @@ ios_framework_bundle("web_view") {
public_headers += cronet_native_public_headers
}
sources = ios_web_view_sources
sources = [ "internal/web_view_global_state_util.mm" ]
if (ios_web_view_include_cronet) {
sources += [ "//components/cronet/ios/Cronet.h" ]
}
deps = ios_web_view_deps
deps += [ ":web_view_umbrella_header" ]
deps = [
":web_view_sources",
":web_view_umbrella_header",
"//ios/web/public/init",
]
if (ios_web_view_include_cronet) {
deps += [ "//components/cronet/ios:cronet_sources" ]
}
......@@ -396,13 +405,6 @@ ios_framework_bundle("web_view") {
}
}
ios_web_view_test_sources = [
"internal/passwords/cwv_password_controller_fake.h",
"internal/passwords/cwv_password_controller_fake.mm",
"internal/translate/fake_web_view_translate_client.h",
"internal/translate/fake_web_view_translate_client.mm",
]
source_set("run_all_unittests") {
testonly = true
sources = [ "test/run_all_unittests.cc" ]
......@@ -435,19 +437,23 @@ test("ios_web_view_unittests") {
"internal/cwv_scroll_view_unittest.mm",
"internal/cwv_ssl_status_unittest.mm",
"internal/cwv_web_view_configuration_unittest.mm",
"internal/passwords/cwv_password_controller_fake.h",
"internal/passwords/cwv_password_controller_fake.mm",
"internal/passwords/cwv_password_unittest.mm",
"internal/signin/cwv_identity_unittest.mm",
"internal/sync/cwv_sync_controller_unittest.mm",
"internal/translate/cwv_translation_controller_unittest.mm",
"internal/translate/cwv_translation_language_unittest.mm",
"internal/translate/cwv_translation_policy_unittest.mm",
"internal/translate/fake_web_view_translate_client.h",
"internal/translate/fake_web_view_translate_client.mm",
"internal/web_view_global_state_util_stub.mm",
"internal/web_view_web_client_unittest.mm",
]
sources += ios_web_view_sources
sources += ios_web_view_test_sources
deps = [
":run_all_unittests",
":web_view_sources",
"test:test_support",
"//base/test:test_support",
"//components/autofill/core/browser:test_support",
......@@ -467,7 +473,6 @@ test("ios_web_view_unittests") {
"//testing/gtest",
"//third_party/ocmock",
]
deps += ios_web_view_deps
configs += [ "//build/config/compiler:enable_arc" ]
......
......@@ -18,11 +18,6 @@
namespace ios_web_view {
void InitializeGlobalState() {
// Do not perform global state initialization in an unit test environment.
// 1. Not needed when unit testing.
// 2. The globals below will try to create other already created globals like
// AtExitManagers. This causes DCHECKs and prevents tests from completing.
#if !defined(UNIT_TEST)
static std::unique_ptr<ios_web_view::WebViewWebClient> web_client;
static std::unique_ptr<ios_web_view::WebViewWebMainDelegate>
web_main_delegate;
......@@ -49,7 +44,6 @@ void InitializeGlobalState() {
web_client.reset();
}];
});
#endif // defined(UNIT_TEST)
}
} // namespace ios_web_view
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/web_view/internal/web_view_global_state_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios_web_view {
void InitializeGlobalState() {
// Do not perform global state initialization in an unit test environment.
// It's not needed and also avoids the issue of multiple AtExitManagers.
}
} // namespace ios_web_view
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment