Commit 8861a325 authored by Xi Han's avatar Xi Han Committed by Commit Bot

extension_browsertest's WebViewAPITest.CloseOnLoadcommit failing on ToTMac

The test failure is due to NSApplication isn't set in
extensions::TestShellMainDelegate. This CL also did a clean up of CL:
https://crrev.com/c/1072387.

Bug: 853172
Change-Id: Id42649427b659a2b97cd0236e0d1d4d815ba4158
Reviewed-on: https://chromium-review.googlesource.com/1105194Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568525}
parent 0a95f773
......@@ -82,6 +82,7 @@
#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
#include "chrome/app/chrome_main_mac.h"
#include "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/mac/relauncher.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/mac/cfbundle_blocker.h"
......@@ -1141,6 +1142,15 @@ service_manager::ProcessType ChromeMainDelegate::OverrideProcessType() {
void ChromeMainDelegate::PreContentInitialization() {
#if defined(OS_MACOSX)
RegisterBrowserCrApp();
// Tell Cocoa to finish its initialization, which we want to do manually
// instead of calling NSApplicationMain(). The primary reason is that NSAM()
// never returns, which would leave all the objects currently on the stack
// in scoped_ptrs hanging and never cleaned up. We then load the main nib
// directly. The main event loop is run from common code using the
// MessageLoop API, which works out ok for us because it's a wrapper around
// CFRunLoop.
// Initialize NSApplication using the custom subclass.
chrome_browser_application_mac::RegisterBrowserCrApp();
#endif
}
......@@ -20,7 +20,4 @@ void CheckUserDataDirPolicy(base::FilePath* user_data_dir);
// process.
void SetUpBundleOverrides();
// Initialize NSApplication.
void RegisterBrowserCrApp();
#endif // CHROME_APP_CHROME_MAIN_MAC_H_
......@@ -14,7 +14,6 @@
#import "base/mac/foundation_util.h"
#import "base/mac/scoped_nsautorelease_pool.h"
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/common/chrome_paths_internal.h"
void SetUpBundleOverrides() {
......@@ -25,16 +24,3 @@ void SetUpBundleOverrides() {
NSBundle* base_bundle = chrome::OuterAppBundle();
base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]);
}
void RegisterBrowserCrApp() {
// Tell Cocoa to finish its initialization, which we want to do manually
// instead of calling NSApplicationMain(). The primary reason is that NSAM()
// never returns, which would leave all the objects currently on the stack
// in scoped_ptrs hanging and never cleaned up. We then load the main nib
// directly. The main event loop is run from common code using the
// MessageLoop API, which works out ok for us because it's a wrapper around
// CFRunLoop.
// Initialize NSApplication using the custom subclass.
chrome_browser_application_mac::RegisterBrowserCrApp();
}
......@@ -524,6 +524,10 @@ source_set("browser_tests") {
sources += [ "browser/shell_desktop_controller_aura_browsertest.cc" ]
deps += [ "//ui/aura" ]
}
if (is_mac) {
sources += [ "test/test_shell_main_delegate_mac.mm" ]
}
}
source_set("unit_tests") {
......
include_rules = [
"+content/public/browser",
"+content/shell/common",
"+content/shell/browser/shell_application_mac.h",
"+content/public/utility",
"+services/service_manager/embedder",
......
......@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
#include "build/build_config.h"
#include "extensions/shell/app/shell_main_delegate.h"
namespace content {
......@@ -24,6 +25,9 @@ class TestShellMainDelegate : public extensions::ShellMainDelegate {
protected:
// content::ContentMainDelegate implementation:
content::ContentUtilityClient* CreateContentUtilityClient() override;
#if defined(OS_MACOSX)
void PreContentInitialization() override;
#endif
private:
std::unique_ptr<content::ContentUtilityClient> utility_client_;
......
// Copyright 2018 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 "extensions/shell/test/test_shell_main_delegate.h"
#include "content/shell/browser/shell_application_mac.h"
namespace extensions {
void TestShellMainDelegate::PreContentInitialization() {
// Force the NSApplication subclass to be used.
[ShellCrApplication sharedApplication];
}
} // namespace extensions
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