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