Commit 36088764 authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Stop Running Firewall Checks for MediaRouterMojoExtensionTest

The firewall checks weren't running before, and with the upcoming COM
initialization change for TestBrowserThreadBundle, they'll suddenly
start running, changing all of the assumptions for the
MediaRouterMojoExtensionTest.

This change disables firewall checking for tests.

BUG=735725

Change-Id: I6e6760ab42cf9d5180cfa33028fb3fb973a45f1f
Reviewed-on: https://chromium-review.googlesource.com/544900Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481741}
parent b9da01ce
...@@ -62,7 +62,8 @@ MediaRouterMojoImpl::MediaSinksQuery::~MediaSinksQuery() = default; ...@@ -62,7 +62,8 @@ MediaRouterMojoImpl::MediaSinksQuery::~MediaSinksQuery() = default;
MediaRouterMojoImpl::MediaRouterMojoImpl( MediaRouterMojoImpl::MediaRouterMojoImpl(
extensions::EventPageTracker* event_page_tracker, extensions::EventPageTracker* event_page_tracker,
content::BrowserContext* context) content::BrowserContext* context,
FirewallCheck check_firewall)
: event_page_tracker_(event_page_tracker), : event_page_tracker_(event_page_tracker),
instance_id_(base::GenerateGUID()), instance_id_(base::GenerateGUID()),
availability_(mojom::MediaRouter::SinkAvailability::UNAVAILABLE), availability_(mojom::MediaRouter::SinkAvailability::UNAVAILABLE),
...@@ -72,9 +73,11 @@ MediaRouterMojoImpl::MediaRouterMojoImpl( ...@@ -72,9 +73,11 @@ MediaRouterMojoImpl::MediaRouterMojoImpl(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(event_page_tracker_); DCHECK(event_page_tracker_);
#if defined(OS_WIN) #if defined(OS_WIN)
CanFirewallUseLocalPorts( if (check_firewall == FirewallCheck::RUN) {
base::Bind(&MediaRouterMojoImpl::OnFirewallCheckComplete, CanFirewallUseLocalPorts(
weak_factory_.GetWeakPtr())); base::Bind(&MediaRouterMojoImpl::OnFirewallCheckComplete,
weak_factory_.GetWeakPtr()));
}
#endif #endif
} }
......
...@@ -211,10 +211,19 @@ class MediaRouterMojoImpl : public MediaRouterBase, ...@@ -211,10 +211,19 @@ class MediaRouterMojoImpl : public MediaRouterBase,
DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery);
}; };
enum class FirewallCheck {
// Skips the firewall check for the benefit of unit tests so they do not
// have to depend on the system's firewall configuration.
SKIP_FOR_TESTING,
// Perform the firewall check (default).
RUN,
};
// Standard constructor, used by // Standard constructor, used by
// MediaRouterMojoImplFactory::GetApiForBrowserContext. // MediaRouterMojoImplFactory::GetApiForBrowserContext.
MediaRouterMojoImpl(extensions::EventPageTracker* event_page_tracker, MediaRouterMojoImpl(extensions::EventPageTracker* event_page_tracker,
content::BrowserContext* context); content::BrowserContext* context,
FirewallCheck check_firewall = FirewallCheck::RUN);
// Binds |this| to a Mojo interface request, so that clients can acquire a // Binds |this| to a Mojo interface request, so that clients can acquire a
// handle to a MediaRouterMojoImpl instance via the Mojo service connector. // handle to a MediaRouterMojoImpl instance via the Mojo service connector.
......
...@@ -1427,8 +1427,9 @@ class MediaRouterMojoExtensionTest : public ::testing::Test { ...@@ -1427,8 +1427,9 @@ class MediaRouterMojoExtensionTest : public ::testing::Test {
DCHECK(process_manager_); DCHECK(process_manager_);
// Create MR and its proxy, so that it can be accessed through Mojo. // Create MR and its proxy, so that it can be accessed through Mojo.
media_router_.reset( media_router_.reset(new MediaRouterMojoImpl(
new MediaRouterMojoImpl(process_manager_, profile_.get())); process_manager_, profile_.get(),
MediaRouterMojoImpl::FirewallCheck::SKIP_FOR_TESTING));
ProcessEventLoop(); ProcessEventLoop();
} }
...@@ -1570,6 +1571,7 @@ TEST_F(MediaRouterMojoExtensionTest, AttemptedWakeupTooManyTimes) { ...@@ -1570,6 +1571,7 @@ TEST_F(MediaRouterMojoExtensionTest, AttemptedWakeupTooManyTimes) {
.WillOnce(Return(true)); .WillOnce(Return(true));
EXPECT_CALL(*process_manager_, WakeEventPage(extension_->id(), _)) EXPECT_CALL(*process_manager_, WakeEventPage(extension_->id(), _))
.WillOnce(testing::DoAll(media::RunCallback<1>(true), Return(true))); .WillOnce(testing::DoAll(media::RunCallback<1>(true), Return(true)));
ASSERT_TRUE(media_router_->pending_requests_.empty());
media_router_->DetachRoute(kRouteId); media_router_->DetachRoute(kRouteId);
EXPECT_EQ(1u, media_router_->pending_requests_.size()); EXPECT_EQ(1u, media_router_->pending_requests_.size());
ExpectWakeReasonBucketCount(MediaRouteProviderWakeReason::DETACH_ROUTE, 1); ExpectWakeReasonBucketCount(MediaRouteProviderWakeReason::DETACH_ROUTE, 1);
......
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