Skip to content

Commit

Permalink
Merge pull request #19169 from brave/explicitly-initialize-testing-ptrs
Browse files Browse the repository at this point in the history
Explicitly initialize test ptrs to nullptr
  • Loading branch information
antonok-edm authored Jul 8, 2023
2 parents e29428b + 4dc47b9 commit f7dafff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
15 changes: 6 additions & 9 deletions browser/brave_shields/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ void AdBlockServiceTest::PreRunTestOnMainThread() {
WaitForAdBlockServiceThreads();
}

void AdBlockServiceTest::TearDownOnMainThread() {
// Unset the host resolver so as not to interfere with later tests.
brave::SetAdblockCnameHostResolverForTesting(nullptr);
ExtensionBrowserTest::TearDownOnMainThread();
}

content::WebContents* AdBlockServiceTest::web_contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
Expand Down Expand Up @@ -1042,9 +1048,6 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
bad_resource_url.spec().c_str())));
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 3ULL);
ASSERT_EQ(4ULL, inner_resolver->num_resolve());

// Unset the host resolver so as not to interfere with later tests.
brave::SetAdblockCnameHostResolverForTesting(nullptr);
}

// Make sure that an exception for a URL can apply to a blocking decision made
Expand Down Expand Up @@ -1130,9 +1133,6 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
bad_resource_url.spec().c_str())));
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 3ULL);
ASSERT_EQ(4ULL, inner_resolver->num_resolve());

// Unset the host resolver so as not to interfere with later tests.
brave::SetAdblockCnameHostResolverForTesting(nullptr);
}

class CnameUncloakingFlagDisabledTest : public AdBlockServiceTest {
Expand Down Expand Up @@ -1223,9 +1223,6 @@ IN_PROC_BROWSER_TEST_F(CnameUncloakingFlagDisabledTest, NoDnsQueriesIssued) {
bad_resource_url.spec().c_str())));
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 1ULL);
ASSERT_EQ(0ULL, inner_resolver->num_resolve());

// Unset the host resolver so as not to interfere with later tests.
brave::SetAdblockCnameHostResolverForTesting(nullptr);
}

// Load an image from a specific subdomain, and make sure it is blocked.
Expand Down
1 change: 1 addition & 0 deletions browser/brave_shields/ad_block_service_browsertest.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AdBlockServiceTest : public extensions::ExtensionBrowserTest {
void SetUpOnMainThread() override;
void SetUp() override;
void PreRunTestOnMainThread() override;
void TearDownOnMainThread() override;

protected:
content::ContentMockCertVerifier mock_cert_verifier_;
Expand Down
2 changes: 1 addition & 1 deletion browser/net/brave_ad_block_tp_network_delegate_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const std::string& GetCanonicalName(

} // namespace

network::HostResolver* g_testing_host_resolver;
network::HostResolver* g_testing_host_resolver = nullptr;

void SetAdblockCnameHostResolverForTesting(
network::HostResolver* host_resolver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace brave_shields {

base::TimeDelta* g_testing_subscription_retry_interval;
base::TimeDelta* g_testing_subscription_retry_interval = nullptr;

namespace {

Expand Down

0 comments on commit f7dafff

Please sign in to comment.