[Telemetry] Add touchscreen events implementation
Add implementation for detecting touchscreen events (touch & connected event) in Telemetry Extension. Bug: b/294331196 Test: unit_tests --gtest_filter="*Telemetry*Event*" Test: extensions_unittests --gtest_filter="*TelemetryExtension*" Test: browser_tests --gtest_filter="*TelemetryExtensionEventsApi*" Change-Id: If106909c6a66b269d3e543a1ae9e8c9d9a5d1495 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4777738 Reviewed-by: Tim <tjudkins@chromium.org> Reviewed-by: Roland Bock <rbock@google.com> Reviewed-by: Byron Lee <byronlee@chromium.org> Commit-Queue: Denny Huang <dennyh@google.com> Cr-Commit-Position: refs/heads/main@{#1185652}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1e57913727
commit
84c7ddc436
chrome
browser
ash
telemetry_extension
chromeos
common
chromeos
extensions
chromeos/crosapi/mojom
docs/telemetry_extension
extensions/browser
tools/metrics/histograms
@ -65,6 +65,18 @@ void CrosHealthdEventForwarder::OnEvent(
|
||||
}
|
||||
return;
|
||||
}
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenTouch: {
|
||||
if (event->is_touchscreen_touch_event_info()) {
|
||||
crosapi_observer_->OnEvent(std::move(event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenConnected: {
|
||||
if (event->is_touchscreen_connected_event_info()) {
|
||||
crosapi_observer_->OnEvent(std::move(event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kStylusTouch: {
|
||||
if (event->is_stylus_touch_event_info()) {
|
||||
crosapi_observer_->OnEvent(std::move(event));
|
||||
|
@ -145,6 +145,23 @@ crosapi::mojom::TelemetryTouchpadConnectedEventInfoPtr UncheckedConvertPtr(
|
||||
std::move(converted_touch_buttons));
|
||||
}
|
||||
|
||||
crosapi::mojom::TelemetryTouchscreenTouchEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::TouchscreenTouchEventPtr input) {
|
||||
std::vector<crosapi::mojom::TelemetryTouchPointInfoPtr>
|
||||
converted_touch_points;
|
||||
for (auto& touch_point : input->touch_points) {
|
||||
converted_touch_points.push_back(ConvertStructPtr(std::move(touch_point)));
|
||||
}
|
||||
return crosapi::mojom::TelemetryTouchscreenTouchEventInfo::New(
|
||||
std::move(converted_touch_points));
|
||||
}
|
||||
|
||||
crosapi::mojom::TelemetryTouchscreenConnectedEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::TouchscreenConnectedEventPtr input) {
|
||||
return crosapi::mojom::TelemetryTouchscreenConnectedEventInfo::New(
|
||||
input->max_x, input->max_y, input->max_pressure);
|
||||
}
|
||||
|
||||
crosapi::mojom::TelemetryStylusTouchEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::StylusTouchEventPtr input) {
|
||||
return crosapi::mojom::TelemetryStylusTouchEventInfo::New(
|
||||
@ -210,6 +227,22 @@ crosapi::mojom::TelemetryEventInfoPtr UncheckedConvertPtr(
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
case cros_healthd::mojom::EventInfo::Tag::kTouchscreenEventInfo: {
|
||||
auto info = std::move(input->get_touchscreen_event_info());
|
||||
switch (info->which()) {
|
||||
case cros_healthd::mojom::TouchscreenEventInfo::Tag::kTouchEvent:
|
||||
return crosapi::mojom::TelemetryEventInfo::
|
||||
NewTouchscreenTouchEventInfo(
|
||||
ConvertStructPtr(std::move(info->get_touch_event())));
|
||||
case cros_healthd::mojom::TouchscreenEventInfo::Tag::kConnectedEvent:
|
||||
return crosapi::mojom::TelemetryEventInfo::
|
||||
NewTouchscreenConnectedEventInfo(
|
||||
ConvertStructPtr(std::move(info->get_connected_event())));
|
||||
case cros_healthd::mojom::TouchscreenEventInfo::Tag::kDefaultType:
|
||||
LOG(WARNING) << "Got unsupported touchscreen event";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
case cros_healthd::mojom::EventInfo::Tag::kStylusEventInfo: {
|
||||
auto info = std::move(input->get_stylus_event_info());
|
||||
switch (info->which()) {
|
||||
@ -532,6 +565,10 @@ cros_healthd::mojom::EventCategoryEnum Convert(
|
||||
return cros_healthd::mojom::EventCategoryEnum::kTouchpad;
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kTouchpadConnected:
|
||||
return cros_healthd::mojom::EventCategoryEnum::kTouchpad;
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenTouch:
|
||||
return cros_healthd::mojom::EventCategoryEnum::kTouchscreen;
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenConnected:
|
||||
return cros_healthd::mojom::EventCategoryEnum::kTouchscreen;
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kExternalDisplay:
|
||||
return cros_healthd::mojom::EventCategoryEnum::kExternalDisplay;
|
||||
case crosapi::mojom::TelemetryEventCategoryEnum::kStylusTouch:
|
||||
|
@ -67,6 +67,12 @@ crosapi::mojom::TelemetryTouchpadTouchEventInfoPtr UncheckedConvertPtr(
|
||||
crosapi::mojom::TelemetryTouchpadConnectedEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::TouchpadConnectedEventPtr input);
|
||||
|
||||
crosapi::mojom::TelemetryTouchscreenTouchEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::TouchscreenTouchEventPtr input);
|
||||
|
||||
crosapi::mojom::TelemetryTouchscreenConnectedEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::TouchscreenConnectedEventPtr input);
|
||||
|
||||
crosapi::mojom::TelemetryStylusTouchEventInfoPtr UncheckedConvertPtr(
|
||||
cros_healthd::mojom::StylusTouchEventPtr input);
|
||||
|
||||
|
@ -414,6 +414,15 @@ TEST(TelemetryEventServiceConvertersTest, ConvertTelemetryEventCategoryEnum) {
|
||||
Convert(crosapi::mojom::TelemetryEventCategoryEnum::kTouchpadConnected),
|
||||
cros_healthd::mojom::EventCategoryEnum::kTouchpad);
|
||||
|
||||
EXPECT_EQ(
|
||||
Convert(crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenTouch),
|
||||
cros_healthd::mojom::EventCategoryEnum::kTouchscreen);
|
||||
|
||||
EXPECT_EQ(
|
||||
Convert(
|
||||
crosapi::mojom::TelemetryEventCategoryEnum::kTouchscreenConnected),
|
||||
cros_healthd::mojom::EventCategoryEnum::kTouchscreen);
|
||||
|
||||
EXPECT_EQ(Convert(crosapi::mojom::TelemetryEventCategoryEnum::kStylusTouch),
|
||||
cros_healthd::mojom::EventCategoryEnum::kStylus);
|
||||
|
||||
@ -755,6 +764,56 @@ TEST(TelemetryEventServiceConvertersTest,
|
||||
EXPECT_EQ(connected_event_output->buttons, expected_buttons);
|
||||
}
|
||||
|
||||
TEST(TelemetryEventServiceConvertersTest,
|
||||
ConvertTouchscreenEventInfoTouchEvent) {
|
||||
std::vector<cros_healthd::mojom::TouchPointInfoPtr> touch_points;
|
||||
touch_points.push_back(cros_healthd::mojom::TouchPointInfo::New(
|
||||
1, 2, 3, nullptr, nullptr, nullptr));
|
||||
touch_points.push_back(cros_healthd::mojom::TouchPointInfo::New(
|
||||
4, 5, 6, cros_healthd::mojom::NullableUint32::New(7),
|
||||
cros_healthd::mojom::NullableUint32::New(8),
|
||||
cros_healthd::mojom::NullableUint32::New(9)));
|
||||
|
||||
auto touch_event_input =
|
||||
cros_healthd::mojom::TouchscreenTouchEvent::New(std::move(touch_points));
|
||||
auto input = cros_healthd::mojom::EventInfo::NewTouchscreenEventInfo(
|
||||
cros_healthd::mojom::TouchscreenEventInfo::NewTouchEvent(
|
||||
std::move(touch_event_input)));
|
||||
|
||||
auto result = ConvertStructPtr(std::move(input));
|
||||
|
||||
EXPECT_TRUE(result->is_touchscreen_touch_event_info());
|
||||
const auto& touch_event_output = result->get_touchscreen_touch_event_info();
|
||||
EXPECT_EQ(touch_event_output->touch_points.size(), 2UL);
|
||||
EXPECT_EQ(touch_event_output->touch_points[0],
|
||||
crosapi::mojom::TelemetryTouchPointInfo::New(1, 2, 3, nullptr,
|
||||
nullptr, nullptr));
|
||||
|
||||
EXPECT_EQ(touch_event_output->touch_points[1],
|
||||
crosapi::mojom::TelemetryTouchPointInfo::New(
|
||||
4, 5, 6, crosapi::mojom::UInt32Value::New(7),
|
||||
crosapi::mojom::UInt32Value::New(8),
|
||||
crosapi::mojom::UInt32Value::New(9)));
|
||||
}
|
||||
|
||||
TEST(TelemetryEventServiceConvertersTest,
|
||||
ConvertTouchscreenEventInfoConnectedEvent) {
|
||||
auto connected_event_input =
|
||||
cros_healthd::mojom::TouchscreenConnectedEvent::New(1, 2, 3);
|
||||
auto input = cros_healthd::mojom::EventInfo::NewTouchscreenEventInfo(
|
||||
cros_healthd::mojom::TouchscreenEventInfo::NewConnectedEvent(
|
||||
std::move(connected_event_input)));
|
||||
|
||||
auto result = ConvertStructPtr(std::move(input));
|
||||
EXPECT_TRUE(result->is_touchscreen_connected_event_info());
|
||||
const auto& connected_event_output =
|
||||
result->get_touchscreen_connected_event_info();
|
||||
|
||||
EXPECT_EQ(connected_event_output->max_x, 1UL);
|
||||
EXPECT_EQ(connected_event_output->max_y, 2UL);
|
||||
EXPECT_EQ(connected_event_output->max_pressure, 3UL);
|
||||
}
|
||||
|
||||
TEST(TelemetryEventServiceConvertersTest, ConvertStylusEventInfoTouchEvent) {
|
||||
constexpr int kX = 1;
|
||||
constexpr int kY = 2;
|
||||
|
@ -172,6 +172,30 @@ class DefaultEventDelegate : public EventObservationCrosapi::Delegate {
|
||||
browser_context_);
|
||||
break;
|
||||
}
|
||||
case crosapi::internal::TelemetryEventInfo_Data::TelemetryEventInfo_Tag::
|
||||
kTouchscreenTouchEventInfo: {
|
||||
event = std::make_unique<extensions::Event>(
|
||||
extensions::events::OS_EVENTS_ON_TOUCHSCREEN_TOUCH_EVENT,
|
||||
api::os_events::OnTouchscreenTouchEvent::kEventName,
|
||||
base::Value::List().Append(
|
||||
converters::events::ConvertStructPtr(
|
||||
std::move(info->get_touchscreen_touch_event_info()))
|
||||
.ToValue()),
|
||||
browser_context_);
|
||||
break;
|
||||
}
|
||||
case crosapi::internal::TelemetryEventInfo_Data::TelemetryEventInfo_Tag::
|
||||
kTouchscreenConnectedEventInfo: {
|
||||
event = std::make_unique<extensions::Event>(
|
||||
extensions::events::OS_EVENTS_ON_TOUCHSCREEN_CONNECTED_EVENT,
|
||||
api::os_events::OnTouchscreenConnectedEvent::kEventName,
|
||||
base::Value::List().Append(
|
||||
converters::events::ConvertStructPtr(
|
||||
std::move(info->get_touchscreen_connected_event_info()))
|
||||
.ToValue()),
|
||||
browser_context_);
|
||||
break;
|
||||
}
|
||||
case crosapi::internal::TelemetryEventInfo_Data::TelemetryEventInfo_Tag::
|
||||
kStylusTouchEventInfo: {
|
||||
event = std::make_unique<extensions::Event>(
|
||||
|
@ -655,6 +655,49 @@ IN_PROC_BROWSER_TEST_F(TelemetryExtensionEventsApiBrowserTest,
|
||||
)");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(TelemetryExtensionEventsApiBrowserTest,
|
||||
CheckTouchscreenTouchEventApiWithoutFeatureFlagFail) {
|
||||
OpenAppUiAndMakeItSecure();
|
||||
|
||||
CreateExtensionAndRunServiceWorker(R"(
|
||||
chrome.test.runTests([
|
||||
function touchscreenTouchEventNotWorking() {
|
||||
chrome.test.assertThrows(() => {
|
||||
chrome.os.events.onTouchscreenTouchEvent.addListener((event) => {
|
||||
// unreachable.
|
||||
});
|
||||
}, [],
|
||||
'Cannot read properties of undefined (reading \'addListener\')'
|
||||
);
|
||||
|
||||
chrome.test.succeed();
|
||||
}
|
||||
]);
|
||||
)");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(
|
||||
TelemetryExtensionEventsApiBrowserTest,
|
||||
CheckTouchscreenConnectedEventApiWithoutFeatureFlagFail) {
|
||||
OpenAppUiAndMakeItSecure();
|
||||
|
||||
CreateExtensionAndRunServiceWorker(R"(
|
||||
chrome.test.runTests([
|
||||
function touchscreenConnectedEventNotWorking() {
|
||||
chrome.test.assertThrows(() => {
|
||||
chrome.os.events.onTouchscreenConnectedEvent.addListener((event) => {
|
||||
// unreachable.
|
||||
});
|
||||
}, [],
|
||||
'Cannot read properties of undefined (reading \'addListener\')'
|
||||
);
|
||||
|
||||
chrome.test.succeed();
|
||||
}
|
||||
]);
|
||||
)");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(TelemetryExtensionEventsApiBrowserTest,
|
||||
OnExternalDisplayEvent_Success) {
|
||||
OpenAppUiAndMakeItSecure();
|
||||
@ -895,4 +938,88 @@ IN_PROC_BROWSER_TEST_F(PendingApprovalTelemetryExtensionEventsApiBrowserTest,
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(PendingApprovalTelemetryExtensionEventsApiBrowserTest,
|
||||
CheckTouchscreenTouchEventApiWithFeatureFlagWork) {
|
||||
OpenAppUiAndMakeItSecure();
|
||||
|
||||
GetFakeService()->SetOnSubscriptionChange(
|
||||
base::BindLambdaForTesting([this]() {
|
||||
std::vector<crosapi::TelemetryTouchPointInfoPtr> touch_points;
|
||||
touch_points.push_back(crosapi::TelemetryTouchPointInfo::New(
|
||||
1, 2, 3, crosapi::UInt32Value::New(4), crosapi::UInt32Value::New(5),
|
||||
crosapi::UInt32Value::New(6)));
|
||||
touch_points.push_back(crosapi::TelemetryTouchPointInfo::New(
|
||||
7, 8, 9, nullptr, nullptr, nullptr));
|
||||
|
||||
auto touch_event = crosapi::TelemetryTouchscreenTouchEventInfo::New(
|
||||
std::move(touch_points));
|
||||
|
||||
GetFakeService()->EmitEventForCategory(
|
||||
crosapi::TelemetryEventCategoryEnum::kTouchscreenTouch,
|
||||
crosapi::TelemetryEventInfo::NewTouchscreenTouchEventInfo(
|
||||
std::move(touch_event)));
|
||||
}));
|
||||
|
||||
CreateExtensionAndRunServiceWorker(R"(
|
||||
chrome.test.runTests([
|
||||
async function startCapturingEvents() {
|
||||
chrome.os.events.onTouchscreenTouchEvent.addListener((event) => {
|
||||
chrome.test.assertEq(event, {
|
||||
touchPoints: [{
|
||||
trackingId: 1,
|
||||
x: 2,
|
||||
y: 3,
|
||||
pressure: 4,
|
||||
touchMajor: 5,
|
||||
touchMinor: 6
|
||||
},{
|
||||
trackingId: 7,
|
||||
x: 8,
|
||||
y: 9,
|
||||
}]
|
||||
});
|
||||
|
||||
chrome.test.succeed();
|
||||
});
|
||||
|
||||
await chrome.os.events.startCapturingEvents("touchscreen_touch");
|
||||
}
|
||||
]);
|
||||
)");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(PendingApprovalTelemetryExtensionEventsApiBrowserTest,
|
||||
CheckTouchscreenConnectedEventApiWithFeatureFlagWork) {
|
||||
OpenAppUiAndMakeItSecure();
|
||||
|
||||
GetFakeService()->SetOnSubscriptionChange(
|
||||
base::BindLambdaForTesting([this]() {
|
||||
auto connected_event =
|
||||
crosapi::TelemetryTouchscreenConnectedEventInfo::New(1, 2, 3);
|
||||
|
||||
GetFakeService()->EmitEventForCategory(
|
||||
crosapi::TelemetryEventCategoryEnum::kTouchscreenConnected,
|
||||
crosapi::TelemetryEventInfo::NewTouchscreenConnectedEventInfo(
|
||||
std::move(connected_event)));
|
||||
}));
|
||||
|
||||
CreateExtensionAndRunServiceWorker(R"(
|
||||
chrome.test.runTests([
|
||||
async function startCapturingEvents() {
|
||||
chrome.os.events.onTouchscreenConnectedEvent.addListener((event) => {
|
||||
chrome.test.assertEq(event, {
|
||||
maxX: 1,
|
||||
maxY: 2,
|
||||
maxPressure: 3
|
||||
});
|
||||
|
||||
chrome.test.succeed();
|
||||
});
|
||||
|
||||
await chrome.os.events.startCapturingEvents("touchscreen_connected");
|
||||
}
|
||||
]);
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace chromeos
|
||||
|
@ -190,6 +190,25 @@ cx_events::TouchpadConnectedEventInfo UncheckedConvertPtr(
|
||||
return result;
|
||||
}
|
||||
|
||||
cx_events::TouchscreenTouchEventInfo UncheckedConvertPtr(
|
||||
crosapi::TelemetryTouchscreenTouchEventInfoPtr ptr) {
|
||||
cx_events::TouchscreenTouchEventInfo result;
|
||||
std::vector<cx_events::TouchPointInfo> converted_touch_points =
|
||||
ConvertStructPtrVector<cx_events::TouchPointInfo>(
|
||||
std::move(ptr->touch_points));
|
||||
result.touch_points = std::move(converted_touch_points);
|
||||
return result;
|
||||
}
|
||||
|
||||
cx_events::TouchscreenConnectedEventInfo UncheckedConvertPtr(
|
||||
crosapi::TelemetryTouchscreenConnectedEventInfoPtr ptr) {
|
||||
cx_events::TouchscreenConnectedEventInfo result;
|
||||
result.max_x = ptr->max_x;
|
||||
result.max_y = ptr->max_y;
|
||||
result.max_pressure = ptr->max_pressure;
|
||||
return result;
|
||||
}
|
||||
|
||||
cx_events::TouchPointInfo UncheckedConvertPtr(
|
||||
crosapi::TelemetryTouchPointInfoPtr ptr) {
|
||||
cx_events::TouchPointInfo result;
|
||||
@ -510,6 +529,10 @@ crosapi::TelemetryEventCategoryEnum Convert(cx_events::EventCategory input) {
|
||||
return crosapi::TelemetryEventCategoryEnum::kTouchpadTouch;
|
||||
case cx_events::EventCategory::kTouchpadConnected:
|
||||
return crosapi::TelemetryEventCategoryEnum::kTouchpadConnected;
|
||||
case cx_events::EventCategory::kTouchscreenTouch:
|
||||
return crosapi::TelemetryEventCategoryEnum::kTouchscreenTouch;
|
||||
case cx_events::EventCategory::kTouchscreenConnected:
|
||||
return crosapi::TelemetryEventCategoryEnum::kTouchscreenConnected;
|
||||
case cx_events::EventCategory::kStylusTouch:
|
||||
return crosapi::TelemetryEventCategoryEnum::kStylusTouch;
|
||||
case cx_events::EventCategory::kStylusConnected:
|
||||
|
@ -62,6 +62,12 @@ api::os_events::TouchpadTouchEventInfo UncheckedConvertPtr(
|
||||
api::os_events::TouchpadConnectedEventInfo UncheckedConvertPtr(
|
||||
crosapi::mojom::TelemetryTouchpadConnectedEventInfoPtr ptr);
|
||||
|
||||
api::os_events::TouchscreenTouchEventInfo UncheckedConvertPtr(
|
||||
crosapi::mojom::TelemetryTouchscreenTouchEventInfoPtr ptr);
|
||||
|
||||
api::os_events::TouchscreenConnectedEventInfo UncheckedConvertPtr(
|
||||
crosapi::mojom::TelemetryTouchscreenConnectedEventInfoPtr ptr);
|
||||
|
||||
api::os_events::TouchPointInfo UncheckedConvertPtr(
|
||||
crosapi::mojom::TelemetryTouchPointInfoPtr ptr);
|
||||
|
||||
|
@ -365,6 +365,12 @@ TEST(TelemetryExtensionEventsApiConvertersUnitTest, ConvertEventCategoryEnum) {
|
||||
EXPECT_EQ(Convert(cx_events::EventCategory::kTouchpadConnected),
|
||||
crosapi::TelemetryEventCategoryEnum::kTouchpadConnected);
|
||||
|
||||
EXPECT_EQ(Convert(cx_events::EventCategory::kTouchscreenTouch),
|
||||
crosapi::TelemetryEventCategoryEnum::kTouchscreenTouch);
|
||||
|
||||
EXPECT_EQ(Convert(cx_events::EventCategory::kTouchscreenConnected),
|
||||
crosapi::TelemetryEventCategoryEnum::kTouchscreenConnected);
|
||||
|
||||
EXPECT_EQ(Convert(cx_events::EventCategory::kStylusTouch),
|
||||
crosapi::TelemetryEventCategoryEnum::kStylusTouch);
|
||||
|
||||
@ -710,6 +716,64 @@ TEST(TelemetryExtensionEventsApiConvertersUnitTest,
|
||||
EXPECT_EQ(result.buttons[2], cx_events::InputTouchButton::kRight);
|
||||
}
|
||||
|
||||
TEST(TelemetryExtensionEventsApiConvertersUnitTest,
|
||||
ConvertTouchscreenEventInfoTouchEvent) {
|
||||
constexpr int32_t kTrackingId1 = 1;
|
||||
constexpr int32_t kX1 = 2;
|
||||
constexpr int32_t kY1 = 3;
|
||||
constexpr int32_t kPressure1 = 4;
|
||||
constexpr int32_t kTouchMajor1 = 5;
|
||||
constexpr int32_t kTouchMinor1 = 6;
|
||||
constexpr int32_t kTrackingId2 = 7;
|
||||
constexpr int32_t kX2 = 8;
|
||||
constexpr int32_t kY2 = 9;
|
||||
|
||||
std::vector<crosapi::TelemetryTouchPointInfoPtr> touch_points;
|
||||
touch_points.push_back(crosapi::TelemetryTouchPointInfo::New(
|
||||
kTrackingId1, kX1, kY1, crosapi::UInt32Value::New(kPressure1),
|
||||
crosapi::UInt32Value::New(kTouchMajor1),
|
||||
crosapi::UInt32Value::New(kTouchMinor1)));
|
||||
touch_points.push_back(crosapi::TelemetryTouchPointInfo::New(
|
||||
kTrackingId2, kX2, kY2, nullptr, nullptr, nullptr));
|
||||
|
||||
auto touch_event =
|
||||
crosapi::TelemetryTouchscreenTouchEventInfo::New(std::move(touch_points));
|
||||
|
||||
auto result = ConvertStructPtr(std::move(touch_event));
|
||||
|
||||
EXPECT_EQ(result.touch_points.size(), static_cast<size_t>(2));
|
||||
|
||||
EXPECT_EQ(result.touch_points[0].tracking_id, kTrackingId1);
|
||||
EXPECT_EQ(result.touch_points[0].x, kX1);
|
||||
EXPECT_EQ(result.touch_points[0].y, kY1);
|
||||
EXPECT_EQ(result.touch_points[0].pressure, kPressure1);
|
||||
EXPECT_EQ(result.touch_points[0].touch_major, kTouchMajor1);
|
||||
EXPECT_EQ(result.touch_points[0].touch_minor, kTouchMinor1);
|
||||
|
||||
EXPECT_EQ(result.touch_points[1].tracking_id, kTrackingId2);
|
||||
EXPECT_EQ(result.touch_points[1].x, kX2);
|
||||
EXPECT_EQ(result.touch_points[1].y, kY2);
|
||||
EXPECT_EQ(result.touch_points[1].pressure, absl::nullopt);
|
||||
EXPECT_EQ(result.touch_points[1].touch_major, absl::nullopt);
|
||||
EXPECT_EQ(result.touch_points[1].touch_minor, absl::nullopt);
|
||||
}
|
||||
|
||||
TEST(TelemetryExtensionEventsApiConvertersUnitTest,
|
||||
ConvertTouchscreenEventInfoConnectedEvent) {
|
||||
constexpr int32_t kMaxX = 1;
|
||||
constexpr int32_t kMaxY = 2;
|
||||
constexpr int32_t kMaxPressure = 3;
|
||||
|
||||
auto connected_event = crosapi::TelemetryTouchscreenConnectedEventInfo::New(
|
||||
kMaxX, kMaxY, kMaxPressure);
|
||||
|
||||
auto result = ConvertStructPtr(std::move(connected_event));
|
||||
|
||||
EXPECT_EQ(result.max_x, kMaxX);
|
||||
EXPECT_EQ(result.max_y, kMaxY);
|
||||
EXPECT_EQ(result.max_pressure, kMaxPressure);
|
||||
}
|
||||
|
||||
TEST(TelemetryExtensionEventsApiConvertersUnitTest, ConvertNullableInt) {
|
||||
auto output = ConvertStructPtr(crosapi::UInt32Value::New(10));
|
||||
EXPECT_EQ(output, uint32_t{10});
|
||||
|
@ -156,6 +156,34 @@
|
||||
],
|
||||
"channel": "stable"
|
||||
},
|
||||
"os.events.onTouchscreenTouchEvent": {
|
||||
"dependencies": [
|
||||
"permission:os.events"
|
||||
],
|
||||
"contexts": [
|
||||
"blessed_extension"
|
||||
],
|
||||
"platforms": [
|
||||
"chromeos",
|
||||
"lacros"
|
||||
],
|
||||
"channel": "stable",
|
||||
"feature_flag": "TelemetryExtensionPendingApprovalApi"
|
||||
},
|
||||
"os.events.onTouchscreenConnectedEvent": {
|
||||
"dependencies": [
|
||||
"permission:os.events"
|
||||
],
|
||||
"contexts": [
|
||||
"blessed_extension"
|
||||
],
|
||||
"platforms": [
|
||||
"chromeos",
|
||||
"lacros"
|
||||
],
|
||||
"channel": "stable",
|
||||
"feature_flag": "TelemetryExtensionPendingApprovalApi"
|
||||
},
|
||||
"os.telemetry": {
|
||||
"dependencies": [
|
||||
"permission:os.telemetry"
|
||||
|
@ -20,6 +20,8 @@ namespace os.events {
|
||||
touchpad_button,
|
||||
touchpad_touch,
|
||||
touchpad_connected,
|
||||
touchscreen_touch,
|
||||
touchscreen_connected,
|
||||
external_display,
|
||||
stylus_touch,
|
||||
stylus_connected
|
||||
@ -345,6 +347,21 @@ namespace os.events {
|
||||
InputTouchButton[] buttons;
|
||||
};
|
||||
|
||||
dictionary TouchscreenTouchEventInfo {
|
||||
// The touch points reported by the touchscreen.
|
||||
TouchPointInfo[] touchPoints;
|
||||
};
|
||||
|
||||
dictionary TouchscreenConnectedEventInfo {
|
||||
// The maximum possible x position of touch points.
|
||||
long? maxX;
|
||||
// The maximum possible y position of touch points.
|
||||
long? maxY;
|
||||
// The maximum possible pressure of touch points, or 0 if pressure is not
|
||||
// supported.
|
||||
long? maxPressure;
|
||||
};
|
||||
|
||||
dictionary StylusTouchPointInfo {
|
||||
// The x position. The value ranges from 0 to |max_x| as defined in
|
||||
// StylusConnectedEventInfo.
|
||||
@ -432,6 +449,14 @@ namespace os.events {
|
||||
static void onTouchpadConnectedEvent(
|
||||
TouchpadConnectedEventInfo event_info);
|
||||
|
||||
// Informs the extension that a `Touchscreen Touch` event occured.
|
||||
static void onTouchscreenTouchEvent(
|
||||
TouchscreenTouchEventInfo event_info);
|
||||
|
||||
// Informs the extension that a `Touchscreen Connected` event occured.
|
||||
static void onTouchscreenConnectedEvent(
|
||||
TouchscreenConnectedEventInfo event_info);
|
||||
|
||||
// Informs the extension that a `Stylus Touch` event occured.
|
||||
static void onStylusTouchEvent(StylusTouchEventInfo event_info);
|
||||
|
||||
|
@ -275,6 +275,30 @@ struct TelemetryTouchpadConnectedEventInfo {
|
||||
array<TelemetryInputTouchButton> buttons@3;
|
||||
};
|
||||
|
||||
// Emitted when new touch points are updated.
|
||||
//
|
||||
// NextMinVersion: 1, NextIndex: 1
|
||||
[Stable]
|
||||
struct TelemetryTouchscreenTouchEventInfo {
|
||||
// The touch points reported by the touchscreen.
|
||||
array<TelemetryTouchPointInfo> touch_points@0;
|
||||
};
|
||||
|
||||
// Emitted once the observer get connected to the touchscreen events. This will
|
||||
// be the first event from the touchscreen.
|
||||
//
|
||||
// NextMinVersion: 1, NextIndex: 3
|
||||
[Stable]
|
||||
struct TelemetryTouchscreenConnectedEventInfo {
|
||||
// The maximum possible x position of touch points.
|
||||
uint32? max_x@0;
|
||||
// The maximum possible y position of touch points.
|
||||
uint32? max_y@1;
|
||||
// The maximum possible pressure of touch points, or 0 if pressure is not
|
||||
// supported.
|
||||
uint32? max_pressure@2;
|
||||
};
|
||||
|
||||
// Stylus touch point info.
|
||||
//
|
||||
// NextMinVersion: 1, NextIndex: 3
|
||||
@ -318,7 +342,7 @@ struct TelemetryStylusConnectedEventInfo {
|
||||
|
||||
// Union of event info.
|
||||
//
|
||||
// NextMinVersion: 10, NextIndex: 14
|
||||
// NextMinVersion: 11, NextIndex: 16
|
||||
[Stable, Extensible]
|
||||
union TelemetryEventInfo {
|
||||
// The default value for forward compatibility. All the unknown type will be
|
||||
@ -354,11 +378,17 @@ union TelemetryEventInfo {
|
||||
// Stylus connected event info.
|
||||
[MinVersion=9] TelemetryStylusConnectedEventInfo
|
||||
stylus_connected_event_info@13;
|
||||
// Touchscreen Touch event info.
|
||||
[MinVersion=10] TelemetryTouchscreenTouchEventInfo
|
||||
touchscreen_touch_event_info@14;
|
||||
// Touchscreen Connected event info.
|
||||
[MinVersion=10] TelemetryTouchscreenConnectedEventInfo
|
||||
touchscreen_connected_event_info@15;
|
||||
};
|
||||
|
||||
// An enumeration of event categories.
|
||||
//
|
||||
// NextMinVersion: 10, NextIndex: 14
|
||||
// NextMinVersion: 11, NextIndex: 16
|
||||
[Stable, Extensible]
|
||||
enum TelemetryEventCategoryEnum {
|
||||
// This is required for backwards compatibility, should not be used.
|
||||
@ -376,6 +406,8 @@ enum TelemetryEventCategoryEnum {
|
||||
[MinVersion=8] kExternalDisplay = 11,
|
||||
[MinVersion=9] kStylusTouch = 12,
|
||||
[MinVersion=9] kStylusConnected = 13,
|
||||
[MinVersion=10] kTouchscreenTouch = 14,
|
||||
[MinVersion=10] kTouchscreenConnected = 15,
|
||||
};
|
||||
|
||||
// Implemented by clients who desire events.
|
||||
|
@ -430,7 +430,7 @@ and **events**.
|
||||
| trackingId | number | An id to track an initiated contact throughout its life cycle |
|
||||
| x | number | The x position |
|
||||
| y | number | The y position |
|
||||
| pressure | number | The pressure applied to the touch contact. The value ranges from 0 to `max_pressure` as defined in `TouchpadConnectedEventInfo` |
|
||||
| pressure | number | The pressure applied to the touch contact. The value ranges from 0 to `max_pressure` as defined in `TouchpadConnectedEventInfo` and `TouchscreenConnectedEventInfo` |
|
||||
| touchMajor | number | The length of the longer dimension of the touch contact |
|
||||
| touchMinor | number | The length of the shorter dimension of the touch contact |
|
||||
|
||||
@ -447,6 +447,18 @@ and **events**.
|
||||
| maxPressure | number | The maximum possible pressure of touch points, or 0 if pressure is not supported |
|
||||
| buttons | Array<InputTouchButton\> | The supported buttons |
|
||||
|
||||
### TouchscreenTouchEventInfo
|
||||
| Property Name | Type | Description |
|
||||
------------ | ------- | ----------- |
|
||||
| touchPoints | Array<TouchPointInfo\> | The touch points reported by the touchscreen |
|
||||
|
||||
### TouchscreenConnectedEventInfo
|
||||
| Property Name | Type | Description |
|
||||
------------ | ------- | ----------- |
|
||||
| maxX | number | The maximum possible x position of touch points |
|
||||
| maxY | number | The maximum possible y position of touch points |
|
||||
| maxPressure | number | The maximum possible pressure of touch points, or 0 if pressure is not supported |
|
||||
|
||||
### StylusTouchPointInfo
|
||||
| Property Name | Type | Description |
|
||||
------------ | ------- | ----------- |
|
||||
@ -489,6 +501,8 @@ and **events**.
|
||||
| onTouchpadButtonEvent | function(TouchpadButtonEventInfo) | `os.events` | M117 | Informs the extension that a `Touchpad Button` event occurred |
|
||||
| onTouchpadTouchEvent | function(TouchpadTouchEventInfo) | `os.events` | M117 | Informs the extension that a `Touchpad Touch` event occurred |
|
||||
| onTouchpadConnectedEvent | function(TouchpadConnectedEventInfo) | `os.events` | M117 | Informs the extension that a `Touchpad Connected` event occurred |
|
||||
| onTouchscreenTouchEvent | function(TouchscreenTouchEventInfo) | `os.events` | M118 | Informs the extension that a `Touchscreen Touch` event occurred |
|
||||
| onTouchscreenConnectedEvent | function(TouchscreenConnectedEventInfo) | `os.events` | M118 | Informs the extension that a `Touchscreen Connected` event occurred |
|
||||
| onStylusTouchEvent | function(StylusTouchEventInfo) | `os.events` | M117 | Informs the extension that a `Stylus Touch` event occurred |
|
||||
| onStylusConnectedEvent | function(StylusConnectedEventInfo) | `os.events` | M117 | Informs the extension that a `Stylus Connected` event occurred |
|
||||
|
||||
|
@ -562,6 +562,8 @@ enum HistogramValue {
|
||||
OS_DIAGNOSTICS_ON_ROUTINE_RUNNING = 540,
|
||||
OS_DIAGNOSTICS_ON_ROUTINE_WAITING = 541,
|
||||
OS_DIAGNOSTICS_ON_MEMORY_ROUTINE_FINISHED = 542,
|
||||
OS_EVENTS_ON_TOUCHSCREEN_TOUCH_EVENT = 543,
|
||||
OS_EVENTS_ON_TOUCHSCREEN_CONNECTED_EVENT = 544,
|
||||
// Last entry: Add new entries above, then run:
|
||||
// tools/metrics/histograms/update_extension_histograms.py
|
||||
ENUM_BOUNDARY
|
||||
|
@ -35650,6 +35650,8 @@ Called by update_extension_histograms.py.-->
|
||||
<int value="540" label="OS_DIAGNOSTICS_ON_ROUTINE_RUNNING"/>
|
||||
<int value="541" label="OS_DIAGNOSTICS_ON_ROUTINE_WAITING"/>
|
||||
<int value="542" label="OS_DIAGNOSTICS_ON_MEMORY_ROUTINE_FINISHED"/>
|
||||
<int value="543" label="OS_EVENTS_ON_TOUCHSCREEN_TOUCH_EVENT"/>
|
||||
<int value="544" label="OS_EVENTS_ON_TOUCHSCREEN_CONNECTED_EVENT"/>
|
||||
</enum>
|
||||
|
||||
<enum name="ExtensionFileWriteResult">
|
||||
|
Reference in New Issue
Block a user