Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[fuchsia][input] Delete legacy pointer handler #36857

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions shell/platform/fuchsia/flutter/gfx_platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,6 @@ void GfxPlatformView::OnScenicEvent(
break;
}
break;
case fuchsia::ui::scenic::Event::Tag::kInput:
switch (event.input().Which()) {
case fuchsia::ui::input::InputEvent::Tag::kFocus:
break; // Focus handled elsewhere.
case fuchsia::ui::input::InputEvent::Tag::kPointer: {
// Only received when TouchSource not plugged in.
OnHandlePointerEvent(event.input().pointer());
break;
}
case fuchsia::ui::input::InputEvent::Tag::kKeyboard: {
// All devices should receive key events via input3.KeyboardListener
// instead.
FML_LOG(WARNING) << "Keyboard event from Scenic: ignored";
break;
}
case fuchsia::ui::input::InputEvent::Tag::Invalid: {
FML_DCHECK(false)
<< "Flutter PlatformView::OnScenicEvent: Got an invalid INPUT "
"event.";
}
}
break;
default: {
break;
}
Expand Down
112 changes: 0 additions & 112 deletions shell/platform/fuchsia/flutter/platform_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1496,116 +1496,4 @@ TEST_F(PlatformViewTests, TouchSourceLogicalToPhysicalConversion) {
EXPECT_EQ(flutter_events[1].physical_y, 20.f);
}

TEST_F(PlatformViewTests, DownPointerNumericNudge) {
constexpr float kSmallDiscrepancy = -0.00003f;

fuchsia::ui::scenic::SessionListenerPtr session_listener;
MockPlatformViewDelegate delegate;
flutter::TaskRunners task_runners("test_runners", nullptr, nullptr, nullptr,
nullptr);
flutter_runner::GfxPlatformView platform_view =
PlatformViewBuilder(delegate, std::move(task_runners))
.SetSessionListenerRequest(session_listener.NewRequest())
.Build();
RunLoopUntilIdle();
EXPECT_EQ(delegate.pointer_packets().size(), 0u);

std::vector<fuchsia::ui::scenic::Event> events;
events.emplace_back(
fuchsia::ui::scenic::Event::WithGfx(
fuchsia::ui::gfx::Event::WithViewPropertiesChanged(
fuchsia::ui::gfx::ViewPropertiesChangedEvent{
.view_id = 0,
.properties =
fuchsia::ui::gfx::ViewProperties{
.bounding_box =
fuchsia::ui::gfx::BoundingBox{
.min =
fuchsia::ui::gfx::vec3{
.x = 0.f,
.y = 0.f,
.z = 0.f,
},
.max =
fuchsia::ui::gfx::vec3{
.x = 100.f,
.y = 100.f,
.z = 100.f,
},
},
},
})));
events.emplace_back(fuchsia::ui::scenic::Event::WithGfx(
fuchsia::ui::gfx::Event::WithMetrics(fuchsia::ui::gfx::MetricsEvent{
.node_id = 0,
.metrics =
fuchsia::ui::gfx::Metrics{
.scale_x = 1.f,
.scale_y = 1.f,
.scale_z = 1.f,
},
})));
events.emplace_back(fuchsia::ui::scenic::Event::WithInput(
fuchsia::ui::input::InputEvent::WithPointer(
fuchsia::ui::input::PointerEvent{
.event_time = 1111,
.device_id = 2222,
.pointer_id = 3333,
.type = fuchsia::ui::input::PointerEventType::TOUCH,
.phase = fuchsia::ui::input::PointerEventPhase::ADD,
.x = 50.f,
.y = kSmallDiscrepancy, // floating point inaccuracy
.radius_major = 0.f,
.radius_minor = 0.f,
.buttons = 0u,
})));
events.emplace_back(fuchsia::ui::scenic::Event::WithInput(
fuchsia::ui::input::InputEvent::WithPointer(
fuchsia::ui::input::PointerEvent{
.event_time = 1111,
.device_id = 2222,
.pointer_id = 3333,
.type = fuchsia::ui::input::PointerEventType::TOUCH,
.phase = fuchsia::ui::input::PointerEventPhase::DOWN,
.x = 50.f,
.y = kSmallDiscrepancy, // floating point inaccuracy
.radius_major = 0.f,
.radius_minor = 0.f,
.buttons = 0u,
})));
events.emplace_back(fuchsia::ui::scenic::Event::WithInput(
fuchsia::ui::input::InputEvent::WithPointer(
fuchsia::ui::input::PointerEvent{
.event_time = 1111,
.device_id = 2222,
.pointer_id = 3333,
.type = fuchsia::ui::input::PointerEventType::TOUCH,
.phase = fuchsia::ui::input::PointerEventPhase::MOVE,
.x = 50.f,
.y = kSmallDiscrepancy, // floating point inaccuracy
.radius_major = 0.f,
.radius_minor = 0.f,
.buttons = 0u,
})));
session_listener->OnScenicEvent(std::move(events));
RunLoopUntilIdle();
ASSERT_EQ(delegate.pointer_packets().size(), 3u);

// Embedder issues pointer data in a bytestream format, PointerDataPacket.
// Use this handy utility to recover data as a C struct, PointerData.
std::vector<std::unique_ptr<flutter::PointerDataPacket>> packets =
delegate.TakePointerDataPackets();
std::vector<flutter::PointerData> add, down, move;
UnpackPointerPacket(add, std::move(packets[0]));
UnpackPointerPacket(down, std::move(packets[1]));
UnpackPointerPacket(move, std::move(packets[2]));

EXPECT_EQ(add[0].physical_x, 50.f);
EXPECT_EQ(add[0].physical_y, kSmallDiscrepancy);
EXPECT_EQ(down[0].physical_x, 50.f);
EXPECT_EQ(down[0].physical_y, 0.f); // clamping happened
EXPECT_EQ(move[0].physical_x, 50.f);
EXPECT_EQ(move[0].physical_y, kSmallDiscrepancy);
}

} // namespace flutter_runner::testing