Commit c160c86f authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

capture_mode: do not handle events during countdown animation.

Bug: 1142940
Change-Id: I79d58fcd6ac037b2fec36e33402e45943a644f4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508150
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823264}
parent cd470979
...@@ -394,7 +394,8 @@ void CaptureModeSession::OnKeyEvent(ui::KeyEvent* event) { ...@@ -394,7 +394,8 @@ void CaptureModeSession::OnKeyEvent(ui::KeyEvent* event) {
if (event->key_code() == ui::VKEY_RETURN) { if (event->key_code() == ui::VKEY_RETURN) {
event->StopPropagation(); event->StopPropagation();
controller_->PerformCapture(); // |this| is destroyed here. if (!IsInCountDownAnimation())
controller_->PerformCapture(); // |this| is destroyed here.
return; return;
} }
} }
...@@ -534,6 +535,14 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) { ...@@ -534,6 +535,14 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) {
void CaptureModeSession::OnLocatedEvent(ui::LocatedEvent* event, void CaptureModeSession::OnLocatedEvent(ui::LocatedEvent* event,
bool is_touch) { bool is_touch) {
// If we're currently in countdown animation, don't further handle any
// located events. However we should stop the event propagation here to
// prevent other event handlers from handling this event.
if (IsInCountDownAnimation()) {
event->StopPropagation();
return;
}
// No need to handle events if the current source is kFullscreen. // No need to handle events if the current source is kFullscreen.
const CaptureModeSource capture_source = controller_->source(); const CaptureModeSource capture_source = controller_->source();
if (capture_source == CaptureModeSource::kFullscreen) if (capture_source == CaptureModeSource::kFullscreen)
...@@ -1154,4 +1163,10 @@ void CaptureModeSession::UpdateRootWindowDimmers() { ...@@ -1154,4 +1163,10 @@ void CaptureModeSession::UpdateRootWindowDimmers() {
} }
} }
bool CaptureModeSession::IsInCountDownAnimation() const {
CaptureLabelView* label_view =
static_cast<CaptureLabelView*>(capture_label_widget_->GetContentsView());
return label_view->IsInCountDownAnimation();
}
} // namespace ash } // namespace ash
...@@ -184,6 +184,9 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner, ...@@ -184,6 +184,9 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner,
// Updates |root_window_dimmers_| to dim the correct root windows. // Updates |root_window_dimmers_| to dim the correct root windows.
void UpdateRootWindowDimmers(); void UpdateRootWindowDimmers();
// Returns true if we are currently in video recording countdown animation.
bool IsInCountDownAnimation() const;
CaptureModeController* const controller_; CaptureModeController* const controller_;
// The current root window on which the capture session is active, which may // The current root window on which the capture session is active, which may
......
...@@ -995,4 +995,40 @@ TEST_F(CaptureModeTest, RegionDragCursorCompositing) { ...@@ -995,4 +995,40 @@ TEST_F(CaptureModeTest, RegionDragCursorCompositing) {
} }
} }
// Test that during countdown, capture mode session should not handle any
// incoming input events.
TEST_F(CaptureModeTest, DoNotHandleEventDuringCountDown) {
// We need a non-zero duration to avoid infinite loop on countdown.
ui::ScopedAnimationDurationScaleMode animatin_scale(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Create 2 windows that overlap with each other.
std::unique_ptr<aura::Window> window1(CreateTestWindow(gfx::Rect(200, 200)));
std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(150, 150, 200, 200)));
auto* controller = CaptureModeController::Get();
controller->SetSource(CaptureModeSource::kWindow);
controller->SetType(CaptureModeType::kVideo);
controller->Start();
EXPECT_TRUE(controller->IsActive());
auto* event_generator = GetEventGenerator();
event_generator->MoveMouseToCenterOf(window1.get());
auto* capture_mode_session = controller->capture_mode_session();
EXPECT_EQ(capture_mode_session->GetSelectedWindow(), window1.get());
// Start video recording. Countdown should start at this moment.
event_generator->ClickLeftButton();
// Now move the mouse onto the other window, we should not change the captured
// window during countdown.
event_generator->MoveMouseToCenterOf(window2.get());
EXPECT_EQ(capture_mode_session->GetSelectedWindow(), window1.get());
EXPECT_NE(capture_mode_session->GetSelectedWindow(), window2.get());
WaitForCountDownToFinish();
controller->Stop();
}
} // namespace ash } // namespace ash
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