Commit d344e1dd authored by Takumi Fujimoto's avatar Takumi Fujimoto Committed by Commit Bot

[Harmony Cast Dialog] Disable the Cast button when all sinks disappear

Clicking on the Cast button when there are no sinks causes a crash.
This CL disables the button when the dialog goes from having sinks to
empty.

Bug: 857224
Change-Id: I8040aef278d28fbc6e6b03c04e9ff9103156ea44
Reviewed-on: https://chromium-review.googlesource.com/1119531Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572304}
parent 0e6fbdf8
......@@ -159,6 +159,8 @@ void CastDialogView::OnModelUpdated(const CastDialogModel& model) {
}
dialog_title_ = model.dialog_header();
MaybeSizeToContents();
// Update the main action button.
DialogModelChanged();
}
void CastDialogView::OnControllerInvalidated() {
......
......@@ -26,6 +26,7 @@
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_client_view.h"
using testing::_;
using testing::Invoke;
......@@ -289,4 +290,19 @@ TEST_F(CastDialogViewTest, ShowNoDeviceView) {
EXPECT_TRUE(scroll_view()->visible());
}
TEST_F(CastDialogViewTest, SwitchToNoDeviceView) {
// Start with one sink. The main button should be enabled.
CastDialogModel model = CreateModelWithSinks({CreateAvailableSink()});
InitializeDialogWithModel(model);
EXPECT_TRUE(dialog_->GetDialogClientView()->ok_button()->enabled());
// Remove the sink. The no-device view should be shown, and the main button
// should be disabled.
model.set_media_sinks({});
dialog_->OnModelUpdated(model);
EXPECT_TRUE(no_sinks_view()->visible());
EXPECT_FALSE(scroll_view());
EXPECT_FALSE(dialog_->GetDialogClientView()->ok_button()->enabled());
}
} // namespace media_router
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