Skip to content

Commit

Permalink
[Zenith] Handle StartPresentationContext error callback
Browse files Browse the repository at this point in the history
This is a fix for the regression caused by crrev.com/c/2762550, which
deleted the code to handle StartPresentationContext's error callback
when the dialog is closed.

Bug: 1219663
Change-Id: I9829799b8c9380cf06b9eb718d0e78f5938720b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2961675
Reviewed-by: Tommy Steimel <[email protected]>
Reviewed-by: Takumi Fujimoto <[email protected]>
Commit-Queue: Muyao Xu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#894020}
  • Loading branch information
muyao-xu authored and Chromium LUCI CQ committed Jun 18, 2021
1 parent 2a98528 commit a7194e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class PresentationRequestNotificationItem final
}

const std::string& id() const { return id_; }
media_router::StartPresentationContext* context() const {
return context_.get();
}
bool is_default_presentation_request() const {
return is_default_presentation_request_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ void PresentationRequestNotificationProducer::DeleteItemForPresentationRequest(
const std::string& message) {
if (!item_)
return;
if (item_->context()) {
item_->context()->InvokeErrorCallback(blink::mojom::PresentationError(
blink::mojom::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED,
message));
}
const auto id{item_->id()};
item_.reset();
presentation_request_observer_.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/ui/global_media_controls/presentation_request_notification_producer.h"

#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/media/router/media_router_feature.h"
Expand Down Expand Up @@ -248,3 +249,18 @@ TEST_F(PresentationRequestNotificationProducerTest,
EXPECT_FALSE(notification_producer_->GetNotificationItem());
SimulateDialogClosedAndWait(&delegate);
}

TEST_F(PresentationRequestNotificationProducerTest,
InvokeCallbackOnDialogClosed) {
MockMediaDialogDelegate delegate;

// PRNP should invoke |mock_error_cb| after the media dialog is closed.
base::MockCallback<content::PresentationConnectionErrorCallback>
mock_error_cb;
EXPECT_CALL(mock_error_cb, Run);
auto context = std::make_unique<media_router::StartPresentationContext>(
CreatePresentationRequest(), base::DoNothing(), mock_error_cb.Get());
notification_service_->OnStartPresentationContextCreated(std::move(context));
SimulateDialogOpenedAndWait(&delegate);
SimulateDialogClosedAndWait(&delegate);
}

0 comments on commit a7194e8

Please sign in to comment.