Commit b1681c58 authored by erikchen's avatar erikchen Committed by Commit Bot

Fix extension browsertests to correctly use ShellCrApplication.

If NSApp is used prior to instantiation of the NSApplication subclass, then the
subclass will never be instantiated.

This CL adds a CHECK to confirm that the subclass is correctly instantiated.

This CL found several tests which were unnecessarily instantiating a UI Message
Loop early in the lifetime gtest subclass, which ends up calling NSApp prior to
NSApplication subclass instantiation.

Change-Id: I8868d253b6ec6eff4f8ecdda3176d839aa1826a5
Reviewed-on: https://chromium-review.googlesource.com/1246861Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594436}
parent 3f1cecfb
......@@ -28,14 +28,6 @@ class SystemMemoryApiTest : public ShellApiTest {
public:
SystemMemoryApiTest() {}
~SystemMemoryApiTest() override {}
void SetUpInProcessBrowserTestFixture() override {
ShellApiTest::SetUpInProcessBrowserTestFixture();
message_loop_.reset(new base::MessageLoopForUI);
}
private:
std::unique_ptr<base::MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemMemoryApiTest, Memory) {
......
......@@ -78,11 +78,6 @@ class SystemStorageApiTest : public extensions::ShellApiTest {
TestStorageMonitor::CreateForBrowserTests();
}
void SetUpInProcessBrowserTestFixture() override {
ShellApiTest::SetUpInProcessBrowserTestFixture();
message_loop_.reset(new base::MessageLoopForUI);
}
void SetUpAllMockStorageDevices() {
for (size_t i = 0; i < arraysize(kTestingData); ++i) {
AttachRemovableStorage(kTestingData[i]);
......@@ -99,9 +94,6 @@ class SystemStorageApiTest : public extensions::ShellApiTest {
void DetachRemovableStorage(const std::string& id) {
StorageMonitor::GetInstance()->receiver()->ProcessDetach(id);
}
private:
std::unique_ptr<base::MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) {
......
......@@ -11,6 +11,11 @@ namespace extensions {
void ShellMainDelegate::PreCreateMainMessageLoop() {
// Force the NSApplication subclass to be used.
[ShellCrApplication sharedApplication];
// If there was an invocation to NSApp prior to this method, then the NSApp
// will not be a ShellCrApplication, but will instead be an NSApplication.
// This is undesirable and we must enforce that this doesn't happen.
CHECK([NSApp isKindOfClass:[ShellCrApplication class]]);
}
} // 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