[PDF Ink Signatures] Handle another missing mouse up event case
In an existing case that has been handled, PdfInkModule does not receive a mouse up event, and then continue to receive mouse move events with no mouse buttons down. In another case, PdfInkModule does not receive a mouse up event, and then crashes during the next mouse down event. Add a test case that simulates this scenario and update PdfInkModule to handle it. Along the way, rename the "RunStrokeMissedEndEventDuringFoo" test cases to "StrokeMissedEndEventThenMouseMoveDuringFoo". Bug: 391472562 Change-Id: Idfead081e29a28985183c9b99a75f94ff041abca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6300053 Reviewed-by: Alan Screen <awscreen@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1424910}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c7a7248d3c
commit
97f30efe13
@ -392,6 +392,17 @@ bool PdfInkModule::OnMouseDown(const blink::WebMouseEvent& event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_drawing_stroke()) {
|
||||
DrawingStrokeState& state = drawing_stroke_state();
|
||||
if (state.start_time.has_value()) {
|
||||
CHECK(state.input_last_event.has_value());
|
||||
const DrawingStrokeState::EventDetails& input_last_event =
|
||||
state.input_last_event.value();
|
||||
bool mouse_up_result = OnMouseUp(GenerateLeftMouseUpEvent(
|
||||
input_last_event.position, input_last_event.timestamp));
|
||||
CHECK(mouse_up_result);
|
||||
}
|
||||
}
|
||||
gfx::PointF position = normalized_event.PositionInWidget();
|
||||
return is_drawing_stroke()
|
||||
? StartStroke(position, event.TimeStamp(),
|
||||
|
@ -919,7 +919,7 @@ class PdfInkModuleStrokeTest : public PdfInkModuleTest {
|
||||
/*expect_stroke_success=*/annotation_mode_enabled);
|
||||
}
|
||||
|
||||
void RunStrokeMissedEndEventCheckTest() {
|
||||
void RunStrokeMissedEndEventThenMouseMoveTest() {
|
||||
{
|
||||
// Start a drawing or erase action.
|
||||
blink::WebMouseEvent mouse_down_event =
|
||||
@ -1812,7 +1812,24 @@ TEST_F(PdfInkModuleStrokeTest, EraseStrokeWithPen) {
|
||||
EXPECT_THAT(updated_ink_thumbnail_page_indices(), ElementsAre(0, 0));
|
||||
}
|
||||
|
||||
TEST_F(PdfInkModuleStrokeTest, RunStrokeMissedEndEventDuringDrawing) {
|
||||
TEST_F(PdfInkModuleStrokeTest, StrokeMissedEndEventThenMouseDown) {
|
||||
EnableAnnotationMode();
|
||||
InitializeSimpleSinglePageBasicLayout();
|
||||
|
||||
blink::WebMouseEvent mouse_down_event =
|
||||
MouseEventBuilder().CreateLeftClickAtPosition(kMouseDownPoint).Build();
|
||||
EXPECT_TRUE(ink_module().HandleInputEvent(mouse_down_event));
|
||||
|
||||
blink::WebMouseEvent mouse_move_event =
|
||||
CreateMouseMoveWithLeftButtonEventAtPoint(kMouseMovePoint);
|
||||
EXPECT_TRUE(ink_module().HandleInputEvent(mouse_move_event));
|
||||
|
||||
// If the mouse up event went missing during stroking, the next mouse down
|
||||
// event should not cause a crash.
|
||||
EXPECT_TRUE(ink_module().HandleInputEvent(mouse_down_event));
|
||||
}
|
||||
|
||||
TEST_F(PdfInkModuleStrokeTest, StrokeMissedEndEventThenMouseMoveDuringDrawing) {
|
||||
EnableAnnotationMode();
|
||||
InitializeSimpleSinglePageBasicLayout();
|
||||
|
||||
@ -1820,16 +1837,16 @@ TEST_F(PdfInkModuleStrokeTest, RunStrokeMissedEndEventDuringDrawing) {
|
||||
EXPECT_TRUE(
|
||||
ink_module().OnMessage(CreateGetAnnotationBrushMessageForTesting("pen")));
|
||||
|
||||
RunStrokeMissedEndEventCheckTest();
|
||||
RunStrokeMissedEndEventThenMouseMoveTest();
|
||||
}
|
||||
|
||||
TEST_F(PdfInkModuleStrokeTest, RunStrokeMissedEndEventDuringErasing) {
|
||||
TEST_F(PdfInkModuleStrokeTest, StrokeMissedEndEventThenMouseMoveDuringErasing) {
|
||||
EnableAnnotationMode();
|
||||
InitializeSimpleSinglePageBasicLayout();
|
||||
|
||||
SelectEraserTool();
|
||||
|
||||
RunStrokeMissedEndEventCheckTest();
|
||||
RunStrokeMissedEndEventThenMouseMoveTest();
|
||||
}
|
||||
|
||||
TEST_F(PdfInkModuleStrokeTest, ChangeBrushColorDuringDrawing) {
|
||||
|
Reference in New Issue
Block a user