summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2023-08-09 14:39:25 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-09-20 15:57:54 +0000
commitc7fa96258975f3b9ffa7cf732a3521f1baba630d (patch)
treed1745963fd557e435a442aa9d64920470417c455 /src
parentc7da335217d09db49044d85eb3a550d247c23209 (diff)
downloadlibchrome-gestures-c7fa96258975f3b9ffa7cf732a3521f1baba630d.tar.gz
FlingStopFilterInterpreter instrument event debug
BUG=b:286851905 TEST=USE="coverage" FEATURES="test noclean" emerge-brya chromeos-base/gesture Change-Id: Ie4fcd9c8078de86ed7c2484a3035998761d9cc8c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/4765973 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Sean O'Brien <seobrien@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'src')
-rw-r--r--src/fling_stop_filter_interpreter.cc40
-rw-r--r--src/fling_stop_filter_interpreter_unittest.cc44
2 files changed, 74 insertions, 10 deletions
diff --git a/src/fling_stop_filter_interpreter.cc b/src/fling_stop_filter_interpreter.cc
index 2ce44f6..5cf3c78 100644
--- a/src/fling_stop_filter_interpreter.cc
+++ b/src/fling_stop_filter_interpreter.cc
@@ -25,6 +25,9 @@ FlingStopFilterInterpreter::FlingStopFilterInterpreter(
void FlingStopFilterInterpreter::SyncInterpretImpl(HardwareState& hwstate,
stime_t* timeout) {
+ const char name[] = "FlingStopFilterInterpreter::SyncInterpretImpl";
+ LogHardwareStatePre(name, hwstate);
+
fingers_of_last_hwstate_.clear();
for (int i = 0; i < hwstate.finger_cnt; i++)
fingers_of_last_hwstate_.insert(hwstate.fingers[i].tracking_id);
@@ -37,15 +40,19 @@ void FlingStopFilterInterpreter::SyncInterpretImpl(HardwareState& hwstate,
}
if (hwstate.timestamp > fling_stop_deadline_) {
// sub in a fling before processing other interpreters
- ProduceGesture(Gesture(kGestureFling, prev_timestamp_,
- hwstate.timestamp, 0.0, 0.0,
- GESTURES_FLING_TAP_DOWN));
+ auto fling_tap_down = Gesture(kGestureFling, prev_timestamp_,
+ hwstate.timestamp, 0.0, 0.0,
+ GESTURES_FLING_TAP_DOWN);
+ LogGestureProduce(name, fling_tap_down);
+ ProduceGesture(fling_tap_down);
+
fling_stop_already_sent_ = true;
fling_stop_deadline_ = NO_DEADLINE;
}
}
stime_t next_timeout = NO_DEADLINE;
+ LogHardwareStatePost(name, hwstate);
next_->SyncInterpret(hwstate, &next_timeout);
*timeout = SetNextDeadlineAndReturnTimeoutVal(hwstate.timestamp,
@@ -62,7 +69,6 @@ bool FlingStopFilterInterpreter::NeedsExtraTime(
num_new_fingers++;
}
}
-
return (num_new_fingers >= 2);
}
@@ -80,6 +86,9 @@ bool FlingStopFilterInterpreter::FlingStopNeeded(const Gesture& gesture) const {
}
void FlingStopFilterInterpreter::ConsumeGesture(const Gesture& gesture) {
+ const char name[] = "FlingStopFilterInterpreter::ConsumeGesture";
+ LogGestureConsume(name, gesture);
+
if (gesture.type == kGestureTypeFling) {
fingers_present_for_last_fling_ = fingers_of_last_hwstate_;
already_extended_ = false;
@@ -87,11 +96,15 @@ void FlingStopFilterInterpreter::ConsumeGesture(const Gesture& gesture) {
if (FlingStopNeeded(gesture)) {
// sub in a fling before a new gesture
- ProduceGesture(Gesture(kGestureFling, gesture.start_time,
- gesture.start_time, 0.0, 0.0,
- GESTURES_FLING_TAP_DOWN));
+ auto fling_tap_down = Gesture(kGestureFling, gesture.start_time,
+ gesture.start_time, 0.0, 0.0,
+ GESTURES_FLING_TAP_DOWN);
+ LogGestureProduce(name, fling_tap_down);
+ ProduceGesture(fling_tap_down);
}
+ LogGestureProduce(name, gesture);
ProduceGesture(gesture);
+
fling_stop_deadline_ = NO_DEADLINE;
prev_gesture_type_ = gesture.type;
fling_stop_already_sent_ = false;
@@ -117,6 +130,9 @@ void FlingStopFilterInterpreter::UpdateFlingStopDeadline(
void FlingStopFilterInterpreter::HandleTimerImpl(stime_t now,
stime_t* timeout) {
+ const char name[] = "FlingStopFilterInterpreter::HandleTimerImpl";
+ LogHandleTimerPre(name, now, timeout);
+
stime_t next_timeout;
if (ShouldCallNextTimer(fling_stop_deadline_)) {
if (next_timer_deadline_ > now) {
@@ -133,9 +149,12 @@ void FlingStopFilterInterpreter::HandleTimerImpl(stime_t now,
return;
}
fling_stop_deadline_ = NO_DEADLINE;
- ProduceGesture(Gesture(kGestureFling, prev_timestamp_,
- now, 0.0, 0.0,
- GESTURES_FLING_TAP_DOWN));
+ auto fling_tap_down = Gesture(kGestureFling, prev_timestamp_,
+ now, 0.0, 0.0,
+ GESTURES_FLING_TAP_DOWN);
+ LogGestureProduce(name, fling_tap_down);
+ ProduceGesture(fling_tap_down);
+
fling_stop_already_sent_ = true;
next_timeout = next_timer_deadline_ == NO_DEADLINE ||
next_timer_deadline_ <= now
@@ -144,6 +163,7 @@ void FlingStopFilterInterpreter::HandleTimerImpl(stime_t now,
}
*timeout = SetNextDeadlineAndReturnTimeoutVal(now, fling_stop_deadline_,
next_timeout);
+ LogHandleTimerPost(name, now, timeout);
}
} // namespace gestures
diff --git a/src/fling_stop_filter_interpreter_unittest.cc b/src/fling_stop_filter_interpreter_unittest.cc
index 6410d2f..8637cf9 100644
--- a/src/fling_stop_filter_interpreter_unittest.cc
+++ b/src/fling_stop_filter_interpreter_unittest.cc
@@ -142,4 +142,48 @@ TEST(FlingStopFilterInterpreterTest, SimpleTest) {
}
}
+TEST(FlingStopFilterInterpreterTest, FlingGestureTest) {
+ FlingStopFilterInterpreterTestInterpreter* base_interpreter =
+ new FlingStopFilterInterpreterTestInterpreter;
+ FlingStopFilterInterpreter interpreter(nullptr, base_interpreter, nullptr,
+ GESTURES_DEVCLASS_TOUCHPAD);
+
+ Gesture fling(kGestureFling, 0.0, 1.0, 0.0, 0.0, GESTURES_FLING_TAP_DOWN);
+ Gesture swipelift(kGestureSwipeLift, 1.0, 2.0);
+ Gesture swipe4flift(kGestureFourFingerSwipeLift, 1.0, 2.0);
+ Gesture move(kGestureMove, 1.0, 2.0, 3.0, 4.0);
+
+ interpreter.fling_stop_already_sent_ = true;
+ interpreter.ConsumeGesture(fling);
+ interpreter.ConsumeGesture(fling);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeFling);
+ interpreter.ConsumeGesture(swipelift);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeSwipeLift);
+ interpreter.ConsumeGesture(swipe4flift);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeFourFingerSwipeLift);
+
+ interpreter.fling_stop_already_sent_ = false;
+ interpreter.ConsumeGesture(fling);
+ interpreter.ConsumeGesture(fling);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeFling);
+ interpreter.ConsumeGesture(swipelift);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeSwipeLift);
+ interpreter.ConsumeGesture(swipe4flift);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeFourFingerSwipeLift);
+
+ interpreter.ConsumeGesture(move);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeMove);
+}
+
+TEST(FlingStopFilterInterpreterTest, FlingStopMultimouseMoveTest) {
+ FlingStopFilterInterpreterTestInterpreter* base_interpreter =
+ new FlingStopFilterInterpreterTestInterpreter;
+ FlingStopFilterInterpreter interpreter(nullptr, base_interpreter, nullptr,
+ GESTURES_DEVCLASS_MULTITOUCH_MOUSE);
+
+ Gesture move(kGestureMove, 1.0, 2.0, 3.0, 4.0);
+ interpreter.ConsumeGesture(move);
+ EXPECT_EQ(interpreter.prev_gesture_type_, kGestureTypeMove);
+}
+
} // namespace gestures