Commit 1eedc01c authored by David Bertoni's avatar David Bertoni Committed by Commit Bot

[Extensions] Fix calls to parent SetUp functions in test classes.

A number of SetUp overrides were calling the parent override
before doing the setup for that class. This doesn't work because
any code following the call to the parent override is executed
after the current test fixture executes.

The code in WebrtcLoggingPrivateApiTest to set up the extension_
data member was also moved to SetUpOnMainThread. Building the
extension in SetUp crashes because the global ExtensionsClient
instance is not yet created.

Bug: 1117287
Change-Id: Ifd82c782b7f012cd0225766030fac2574ef68937
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2361004
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799817}
parent c3c31de6
......@@ -30,8 +30,7 @@ using ContextType = ExtensionApiTest::ContextType;
class BookmarksApiTest : public ExtensionApiTest,
public testing::WithParamInterface<ContextType> {
public:
void SetUp() override {
ExtensionApiTest::SetUp();
BookmarksApiTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if (GetParam() == ContextType::kServiceWorker)
......
......@@ -268,8 +268,7 @@ class ExtensionContentSettingsApiLazyTest
: public ExtensionContentSettingsApiTest,
public testing::WithParamInterface<ContextType> {
public:
void SetUp() override {
ExtensionContentSettingsApiTest::SetUp();
ExtensionContentSettingsApiLazyTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if (GetParam() == ContextType::kServiceWorker)
......
......@@ -22,8 +22,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ReadFromDocument) {
class CookiesApiTest : public ExtensionApiTest,
public testing::WithParamInterface<ContextType> {
public:
void SetUp() override {
ExtensionApiTest::SetUp();
CookiesApiTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if (GetParam() == ContextType::kServiceWorker)
......
......@@ -144,7 +144,7 @@ class BrowserActionApiCanvasTest : public BrowserActionApiTest {
public:
void SetUp() override {
EnablePixelOutput();
ExtensionApiTest::SetUp();
BrowserActionApiTest::SetUp();
}
};
......@@ -157,14 +157,11 @@ enum TestFlags {
class BrowserActionApiLazyTest : public BrowserActionApiTest,
public testing::WithParamInterface<int> {
public:
void SetUp() override {
BrowserActionApiTest::SetUp();
BrowserActionApiLazyTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if ((GetParam() & kUseServiceWorker) != 0) {
current_channel_ =
std::make_unique<extensions::ScopedWorkerBasedExtensionsChannel>();
}
if ((GetParam() & kUseServiceWorker) != 0)
current_channel_ = std::make_unique<ScopedWorkerBasedExtensionsChannel>();
if ((GetParam() & kUseExtensionsMenuUi) != 0) {
feature_list_.InitAndEnableFeature(features::kExtensionsToolbarMenu);
......
......@@ -254,7 +254,7 @@ class MultiActionAPICanvasTest : public MultiActionAPITest {
public:
void SetUp() override {
EnablePixelOutput();
ExtensionActionAPITest::SetUp();
MultiActionAPITest::SetUp();
}
};
......
......@@ -45,7 +45,7 @@ class FeedbackTest : public ExtensionBrowserTest {
public:
void SetUp() override {
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
InProcessBrowserTest::SetUp();
ExtensionBrowserTest::SetUp();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
......
......@@ -52,8 +52,7 @@ class NativeMessagingLazyApiTest
: public NativeMessagingApiTest,
public testing::WithParamInterface<ContextType> {
public:
void SetUp() override {
NativeMessagingApiTest::SetUp();
NativeMessagingLazyApiTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if (GetParam() == ContextType::kServiceWorker)
......
......@@ -44,12 +44,6 @@ class PasswordsPrivateApiTest : public ExtensionApiTest {
PasswordsPrivateApiTest() = default;
~PasswordsPrivateApiTest() override = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
ExtensionApiTest::SetUpCommandLine(command_line);
}
void SetUp() override { ExtensionApiTest::SetUp(); }
void SetUpOnMainThread() override {
ExtensionApiTest::SetUpOnMainThread();
s_test_delegate_ = static_cast<TestPasswordsPrivateDelegate*>(
......
......@@ -109,10 +109,6 @@ class ExtensionPreferenceApiTest : public extensions::ExtensionApiTest {
EXPECT_EQ(expected_controlled, pref->IsExtensionControlled());
}
void SetUp() override {
extensions::ExtensionApiTest::SetUp();
}
void SetUpOnMainThread() override {
extensions::ExtensionApiTest::SetUpOnMainThread();
......
......@@ -102,8 +102,8 @@ void InitializeTestMetaData(base::ListValue* parameters) {
class WebrtcLoggingPrivateApiTest : public extensions::ExtensionApiTest {
protected:
void SetUp() override {
extensions::ExtensionApiTest::SetUp();
void SetUpOnMainThread() override {
ExtensionApiTest::SetUpOnMainThread();
extension_ = extensions::ExtensionBuilder("Test").Build();
}
......
......@@ -198,8 +198,7 @@ class ExtensionContextMenuLazyTest
: public ExtensionContextMenuBrowserTest,
public testing::WithParamInterface<ContextType> {
public:
void SetUp() override {
ExtensionContextMenuBrowserTest::SetUp();
ExtensionContextMenuLazyTest() {
// Service Workers are currently only available on certain channels, so set
// the channel for those tests.
if (GetParam() == ContextType::kServiceWorker) {
......
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