xref: /aosp_15_r20/external/libchrome-gestures/src/interpreter_unittest.cc (revision aed3e5085e770be5b69ce25295ecf6ddf906af95)
1*aed3e508SAndroid Build Coastguard Worker // Copyright 2012 The ChromiumOS Authors
2*aed3e508SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*aed3e508SAndroid Build Coastguard Worker // found in the LICENSE file.
4*aed3e508SAndroid Build Coastguard Worker 
5*aed3e508SAndroid Build Coastguard Worker #include <string>
6*aed3e508SAndroid Build Coastguard Worker 
7*aed3e508SAndroid Build Coastguard Worker #include <gtest/gtest.h>
8*aed3e508SAndroid Build Coastguard Worker 
9*aed3e508SAndroid Build Coastguard Worker #include "include/activity_replay.h"
10*aed3e508SAndroid Build Coastguard Worker #include "include/gestures.h"
11*aed3e508SAndroid Build Coastguard Worker #include "include/interpreter.h"
12*aed3e508SAndroid Build Coastguard Worker #include "include/prop_registry.h"
13*aed3e508SAndroid Build Coastguard Worker #include "include/unittest_util.h"
14*aed3e508SAndroid Build Coastguard Worker #include "include/util.h"
15*aed3e508SAndroid Build Coastguard Worker 
16*aed3e508SAndroid Build Coastguard Worker using std::string;
17*aed3e508SAndroid Build Coastguard Worker 
18*aed3e508SAndroid Build Coastguard Worker namespace gestures {
19*aed3e508SAndroid Build Coastguard Worker 
20*aed3e508SAndroid Build Coastguard Worker class InterpreterTest : public ::testing::Test {};
21*aed3e508SAndroid Build Coastguard Worker 
22*aed3e508SAndroid Build Coastguard Worker class InterpreterTestInterpreter : public Interpreter {
23*aed3e508SAndroid Build Coastguard Worker  public:
InterpreterTestInterpreter(PropRegistry * prop_reg)24*aed3e508SAndroid Build Coastguard Worker   explicit InterpreterTestInterpreter(PropRegistry* prop_reg)
25*aed3e508SAndroid Build Coastguard Worker       : Interpreter(prop_reg, nullptr, true),
26*aed3e508SAndroid Build Coastguard Worker         expected_hwstate_(nullptr),
27*aed3e508SAndroid Build Coastguard Worker         interpret_call_count_(0),
28*aed3e508SAndroid Build Coastguard Worker         handle_timer_call_count_(0),
29*aed3e508SAndroid Build Coastguard Worker         bool_prop_(prop_reg, "BoolProp", 0),
30*aed3e508SAndroid Build Coastguard Worker         double_prop_(prop_reg, "DoubleProp", 0),
31*aed3e508SAndroid Build Coastguard Worker         int_prop_(prop_reg, "IntProp", 0),
32*aed3e508SAndroid Build Coastguard Worker         string_prop_(prop_reg, "StringProp", "") {
33*aed3e508SAndroid Build Coastguard Worker     InitName();
34*aed3e508SAndroid Build Coastguard Worker     log_.reset(new ActivityLog(prop_reg));
35*aed3e508SAndroid Build Coastguard Worker   }
36*aed3e508SAndroid Build Coastguard Worker 
37*aed3e508SAndroid Build Coastguard Worker   Gesture return_value_;
38*aed3e508SAndroid Build Coastguard Worker   HardwareState* expected_hwstate_;
39*aed3e508SAndroid Build Coastguard Worker   int interpret_call_count_;
40*aed3e508SAndroid Build Coastguard Worker   int handle_timer_call_count_;
41*aed3e508SAndroid Build Coastguard Worker   BoolProperty bool_prop_;
42*aed3e508SAndroid Build Coastguard Worker   DoubleProperty double_prop_;
43*aed3e508SAndroid Build Coastguard Worker   IntProperty int_prop_;
44*aed3e508SAndroid Build Coastguard Worker   StringProperty string_prop_;
45*aed3e508SAndroid Build Coastguard Worker   char* expected_interpreter_name_;
46*aed3e508SAndroid Build Coastguard Worker 
47*aed3e508SAndroid Build Coastguard Worker  protected:
SyncInterpretImpl(HardwareState & hwstate,stime_t * timeout)48*aed3e508SAndroid Build Coastguard Worker   virtual void SyncInterpretImpl(HardwareState& hwstate, stime_t* timeout) {
49*aed3e508SAndroid Build Coastguard Worker     interpret_call_count_++;
50*aed3e508SAndroid Build Coastguard Worker     EXPECT_STREQ(expected_interpreter_name_, name());
51*aed3e508SAndroid Build Coastguard Worker     EXPECT_NE(0, bool_prop_.val_);
52*aed3e508SAndroid Build Coastguard Worker     EXPECT_NE(0, double_prop_.val_);
53*aed3e508SAndroid Build Coastguard Worker     EXPECT_NE(0, int_prop_.val_);
54*aed3e508SAndroid Build Coastguard Worker     EXPECT_NE("", string_prop_.val_);
55*aed3e508SAndroid Build Coastguard Worker     EXPECT_TRUE(expected_hwstate_);
56*aed3e508SAndroid Build Coastguard Worker     EXPECT_DOUBLE_EQ(expected_hwstate_->timestamp, hwstate.timestamp);
57*aed3e508SAndroid Build Coastguard Worker     EXPECT_EQ(expected_hwstate_->buttons_down, hwstate.buttons_down);
58*aed3e508SAndroid Build Coastguard Worker     EXPECT_EQ(expected_hwstate_->finger_cnt, hwstate.finger_cnt);
59*aed3e508SAndroid Build Coastguard Worker     EXPECT_EQ(expected_hwstate_->touch_cnt, hwstate.touch_cnt);
60*aed3e508SAndroid Build Coastguard Worker     if (expected_hwstate_->finger_cnt == hwstate.finger_cnt) {
61*aed3e508SAndroid Build Coastguard Worker       for (size_t i = 0; i < expected_hwstate_->finger_cnt; i++)
62*aed3e508SAndroid Build Coastguard Worker         EXPECT_TRUE(expected_hwstate_->fingers[i] == hwstate.fingers[i]);
63*aed3e508SAndroid Build Coastguard Worker     }
64*aed3e508SAndroid Build Coastguard Worker     *timeout = 0.01;
65*aed3e508SAndroid Build Coastguard Worker     ProduceGesture(return_value_);
66*aed3e508SAndroid Build Coastguard Worker   }
67*aed3e508SAndroid Build Coastguard Worker 
HandleTimerImpl(stime_t now,stime_t * timeout)68*aed3e508SAndroid Build Coastguard Worker   virtual void HandleTimerImpl(stime_t now, stime_t* timeout) {
69*aed3e508SAndroid Build Coastguard Worker     handle_timer_call_count_++;
70*aed3e508SAndroid Build Coastguard Worker     Interpreter::HandleTimerImpl(now, timeout);
71*aed3e508SAndroid Build Coastguard Worker     ProduceGesture(return_value_);
72*aed3e508SAndroid Build Coastguard Worker   }
73*aed3e508SAndroid Build Coastguard Worker };
74*aed3e508SAndroid Build Coastguard Worker 
75*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,SimpleTest)76*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, SimpleTest) {
77*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
78*aed3e508SAndroid Build Coastguard Worker   InterpreterTestInterpreter base_interpreter(&prop_reg);
79*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(true);
80*aed3e508SAndroid Build Coastguard Worker   MetricsProperties mprops(&prop_reg);
81*aed3e508SAndroid Build Coastguard Worker 
82*aed3e508SAndroid Build Coastguard Worker   HardwareProperties hwprops = {
83*aed3e508SAndroid Build Coastguard Worker     .right = 100, .bottom = 100,
84*aed3e508SAndroid Build Coastguard Worker     .res_x = 10,
85*aed3e508SAndroid Build Coastguard Worker     .res_y = 10,
86*aed3e508SAndroid Build Coastguard Worker     .orientation_minimum = 1,
87*aed3e508SAndroid Build Coastguard Worker     .orientation_maximum = 2,
88*aed3e508SAndroid Build Coastguard Worker     .max_finger_cnt = 2, .max_touch_cnt = 5,
89*aed3e508SAndroid Build Coastguard Worker     .supports_t5r2 = 1, .support_semi_mt = 0, .is_button_pad = 0,
90*aed3e508SAndroid Build Coastguard Worker     .has_wheel = 0, .wheel_is_hi_res = 0,
91*aed3e508SAndroid Build Coastguard Worker     .is_haptic_pad = 0,
92*aed3e508SAndroid Build Coastguard Worker   };
93*aed3e508SAndroid Build Coastguard Worker 
94*aed3e508SAndroid Build Coastguard Worker   TestInterpreterWrapper wrapper(&base_interpreter, &hwprops);
95*aed3e508SAndroid Build Coastguard Worker 
96*aed3e508SAndroid Build Coastguard Worker   base_interpreter.bool_prop_.val_ = 1;
97*aed3e508SAndroid Build Coastguard Worker   base_interpreter.double_prop_.val_ = 1;
98*aed3e508SAndroid Build Coastguard Worker   base_interpreter.int_prop_.val_ = 1;
99*aed3e508SAndroid Build Coastguard Worker   base_interpreter.string_prop_.val_ = "x";
100*aed3e508SAndroid Build Coastguard Worker 
101*aed3e508SAndroid Build Coastguard Worker   //if (prop_reg)
102*aed3e508SAndroid Build Coastguard Worker   //  prop_reg->set_activity_log(&(base_interpreter.log_));
103*aed3e508SAndroid Build Coastguard Worker 
104*aed3e508SAndroid Build Coastguard Worker   char interpreter_name[] = "InterpreterTestInterpreter";
105*aed3e508SAndroid Build Coastguard Worker   base_interpreter.expected_interpreter_name_ = interpreter_name;
106*aed3e508SAndroid Build Coastguard Worker   base_interpreter.return_value_ = Gesture(kGestureMove,
107*aed3e508SAndroid Build Coastguard Worker                                             0,  // start time
108*aed3e508SAndroid Build Coastguard Worker                                             1,  // end time
109*aed3e508SAndroid Build Coastguard Worker                                             -4,  // dx
110*aed3e508SAndroid Build Coastguard Worker                                             2.8);  // dy
111*aed3e508SAndroid Build Coastguard Worker 
112*aed3e508SAndroid Build Coastguard Worker   FingerState finger_state = {
113*aed3e508SAndroid Build Coastguard Worker     // TM, Tm, WM, Wm, Press, Orientation, X, Y, TrID
114*aed3e508SAndroid Build Coastguard Worker     0, 0, 0, 0, 10, 0, 50, 50, 1, 0
115*aed3e508SAndroid Build Coastguard Worker   };
116*aed3e508SAndroid Build Coastguard Worker   HardwareState hardware_state = make_hwstate(200000, 0, 1, 1, &finger_state);
117*aed3e508SAndroid Build Coastguard Worker 
118*aed3e508SAndroid Build Coastguard Worker   stime_t timeout = NO_DEADLINE;
119*aed3e508SAndroid Build Coastguard Worker   base_interpreter.expected_hwstate_ = &hardware_state;
120*aed3e508SAndroid Build Coastguard Worker   Gesture* result = wrapper.SyncInterpret(hardware_state, &timeout);
121*aed3e508SAndroid Build Coastguard Worker   EXPECT_TRUE(base_interpreter.return_value_ == *result);
122*aed3e508SAndroid Build Coastguard Worker   ASSERT_GT(timeout, 0);
123*aed3e508SAndroid Build Coastguard Worker   stime_t now = hardware_state.timestamp + timeout;
124*aed3e508SAndroid Build Coastguard Worker   timeout = NO_DEADLINE;
125*aed3e508SAndroid Build Coastguard Worker   result = wrapper.HandleTimer(now, &timeout);
126*aed3e508SAndroid Build Coastguard Worker   EXPECT_TRUE(base_interpreter.return_value_ == *result);
127*aed3e508SAndroid Build Coastguard Worker   ASSERT_LT(timeout, 0);
128*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(1, base_interpreter.interpret_call_count_);
129*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(1, base_interpreter.handle_timer_call_count_);
130*aed3e508SAndroid Build Coastguard Worker 
131*aed3e508SAndroid Build Coastguard Worker   // Now, get the log
132*aed3e508SAndroid Build Coastguard Worker   string initial_log = base_interpreter.Encode();
133*aed3e508SAndroid Build Coastguard Worker   // Make a new interpreter and push the log through it
134*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg2;
135*aed3e508SAndroid Build Coastguard Worker   InterpreterTestInterpreter base_interpreter2(&prop_reg2);
136*aed3e508SAndroid Build Coastguard Worker   base_interpreter2.SetEventLoggingEnabled(true);
137*aed3e508SAndroid Build Coastguard Worker   base_interpreter2.return_value_ = base_interpreter.return_value_;
138*aed3e508SAndroid Build Coastguard Worker   base_interpreter2.expected_interpreter_name_ = interpreter_name;
139*aed3e508SAndroid Build Coastguard Worker   MetricsProperties mprops2(&prop_reg2);
140*aed3e508SAndroid Build Coastguard Worker 
141*aed3e508SAndroid Build Coastguard Worker   ActivityReplay replay(&prop_reg2);
142*aed3e508SAndroid Build Coastguard Worker   replay.Parse(initial_log);
143*aed3e508SAndroid Build Coastguard Worker 
144*aed3e508SAndroid Build Coastguard Worker   base_interpreter2.expected_hwstate_ = &hardware_state;
145*aed3e508SAndroid Build Coastguard Worker 
146*aed3e508SAndroid Build Coastguard Worker   replay.Replay(&base_interpreter2, &mprops2);
147*aed3e508SAndroid Build Coastguard Worker   string final_log = base_interpreter2.Encode();
148*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(initial_log, final_log);
149*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(1, base_interpreter2.interpret_call_count_);
150*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(1, base_interpreter2.handle_timer_call_count_);
151*aed3e508SAndroid Build Coastguard Worker }
152*aed3e508SAndroid Build Coastguard Worker 
153*aed3e508SAndroid Build Coastguard Worker class InterpreterResetLogTestInterpreter : public Interpreter {
154*aed3e508SAndroid Build Coastguard Worker  public:
InterpreterResetLogTestInterpreter()155*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter() : Interpreter(nullptr, nullptr, true) {
156*aed3e508SAndroid Build Coastguard Worker     log_.reset(new ActivityLog(nullptr));
157*aed3e508SAndroid Build Coastguard Worker   }
158*aed3e508SAndroid Build Coastguard Worker  protected:
SyncInterpretImpl(HardwareState & hwstate,stime_t * timeout)159*aed3e508SAndroid Build Coastguard Worker   virtual void SyncInterpretImpl(HardwareState& hwstate,
160*aed3e508SAndroid Build Coastguard Worker                                      stime_t* timeout) {}
161*aed3e508SAndroid Build Coastguard Worker 
HandleTimerImpl(stime_t now,stime_t * timeout)162*aed3e508SAndroid Build Coastguard Worker   virtual void HandleTimerImpl(stime_t now, stime_t* timeout) {}
163*aed3e508SAndroid Build Coastguard Worker };
164*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,ResetLogTest)165*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, ResetLogTest) {
166*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
167*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
168*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(true);
169*aed3e508SAndroid Build Coastguard Worker   TestInterpreterWrapper wrapper(&base_interpreter);
170*aed3e508SAndroid Build Coastguard Worker 
171*aed3e508SAndroid Build Coastguard Worker   FingerState finger_state = {
172*aed3e508SAndroid Build Coastguard Worker     // TM, Tm, WM, Wm, Press, Orientation, X, Y, TrID
173*aed3e508SAndroid Build Coastguard Worker     0, 0, 0, 0, 10, 0, 50, 50, 1, 0
174*aed3e508SAndroid Build Coastguard Worker   };
175*aed3e508SAndroid Build Coastguard Worker   HardwareState hardware_state = make_hwstate(200000, 0, 1, 1, &finger_state);
176*aed3e508SAndroid Build Coastguard Worker   stime_t timeout = NO_DEADLINE;
177*aed3e508SAndroid Build Coastguard Worker   wrapper.SyncInterpret(hardware_state, &timeout);
178*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 1);
179*aed3e508SAndroid Build Coastguard Worker 
180*aed3e508SAndroid Build Coastguard Worker   wrapper.SyncInterpret(hardware_state, &timeout);
181*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 2);
182*aed3e508SAndroid Build Coastguard Worker 
183*aed3e508SAndroid Build Coastguard Worker   // Assume the ResetLog property is set.
184*aed3e508SAndroid Build Coastguard Worker   base_interpreter.Clear();
185*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
186*aed3e508SAndroid Build Coastguard Worker 
187*aed3e508SAndroid Build Coastguard Worker   wrapper.SyncInterpret(hardware_state, &timeout);
188*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 1);
189*aed3e508SAndroid Build Coastguard Worker }
190*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,LoggingDisabledByDefault)191*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, LoggingDisabledByDefault) {
192*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
193*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
194*aed3e508SAndroid Build Coastguard Worker   TestInterpreterWrapper wrapper(&base_interpreter);
195*aed3e508SAndroid Build Coastguard Worker 
196*aed3e508SAndroid Build Coastguard Worker   FingerState finger_state = {
197*aed3e508SAndroid Build Coastguard Worker     // TM, Tm, WM, Wm, Press, Orientation, X, Y, TrID
198*aed3e508SAndroid Build Coastguard Worker     0, 0, 0, 0, 10, 0, 50, 50, 1, 0
199*aed3e508SAndroid Build Coastguard Worker   };
200*aed3e508SAndroid Build Coastguard Worker   HardwareState hardware_state = make_hwstate(200000, 0, 1, 1, &finger_state);
201*aed3e508SAndroid Build Coastguard Worker   stime_t timeout = NO_DEADLINE;
202*aed3e508SAndroid Build Coastguard Worker   wrapper.SyncInterpret(hardware_state, &timeout);
203*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
204*aed3e508SAndroid Build Coastguard Worker 
205*aed3e508SAndroid Build Coastguard Worker   wrapper.SyncInterpret(hardware_state, &timeout);
206*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
207*aed3e508SAndroid Build Coastguard Worker }
208*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,EventDebugLoggingEnableTest)209*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, EventDebugLoggingEnableTest) {
210*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
211*aed3e508SAndroid Build Coastguard Worker 
212*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventDebugLoggingEnabled(0);
213*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.GetEventDebugLoggingEnabled(), 0);
214*aed3e508SAndroid Build Coastguard Worker 
215*aed3e508SAndroid Build Coastguard Worker   using EventDebug = ActivityLog::EventDebug;
216*aed3e508SAndroid Build Coastguard Worker   base_interpreter.EventDebugLoggingEnable(EventDebug::HardwareState);
217*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.GetEventDebugLoggingEnabled(),
218*aed3e508SAndroid Build Coastguard Worker             1 << static_cast<int>(EventDebug::HardwareState));
219*aed3e508SAndroid Build Coastguard Worker 
220*aed3e508SAndroid Build Coastguard Worker   base_interpreter.EventDebugLoggingDisable(EventDebug::HardwareState);
221*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.GetEventDebugLoggingEnabled(), 0);
222*aed3e508SAndroid Build Coastguard Worker }
223*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,LogHardwareStateTest)224*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, LogHardwareStateTest) {
225*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
226*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
227*aed3e508SAndroid Build Coastguard Worker 
228*aed3e508SAndroid Build Coastguard Worker   FingerState fs = { 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 3.0, 4.0, 22, 0 };
229*aed3e508SAndroid Build Coastguard Worker   HardwareState hs = make_hwstate(1.0, 0, 1, 1, &fs);
230*aed3e508SAndroid Build Coastguard Worker 
231*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(false);
232*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventDebugLoggingEnabled(0);
233*aed3e508SAndroid Build Coastguard Worker 
234*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHardwareStatePre(
235*aed3e508SAndroid Build Coastguard Worker       "InterpreterTest_LogHardwareStateTest", hs);
236*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
237*aed3e508SAndroid Build Coastguard Worker 
238*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHardwareStatePost(
239*aed3e508SAndroid Build Coastguard Worker       "InterpreterTest_LogHardwareStateTest", hs);
240*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
241*aed3e508SAndroid Build Coastguard Worker 
242*aed3e508SAndroid Build Coastguard Worker   using EventDebug = ActivityLog::EventDebug;
243*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(true);
244*aed3e508SAndroid Build Coastguard Worker   base_interpreter.EventDebugLoggingEnable(EventDebug::HardwareState);
245*aed3e508SAndroid Build Coastguard Worker 
246*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHardwareStatePre(
247*aed3e508SAndroid Build Coastguard Worker       "InterpreterTest_LogHardwareStateTest", hs);
248*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 1);
249*aed3e508SAndroid Build Coastguard Worker 
250*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHardwareStatePost(
251*aed3e508SAndroid Build Coastguard Worker       "InterpreterTest_LogHardwareStateTest", hs);
252*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 2);
253*aed3e508SAndroid Build Coastguard Worker }
254*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,LogGestureTest)255*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, LogGestureTest) {
256*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
257*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
258*aed3e508SAndroid Build Coastguard Worker 
259*aed3e508SAndroid Build Coastguard Worker   Gesture move(kGestureMove, 1.0, 2.0, 773, 4.0);
260*aed3e508SAndroid Build Coastguard Worker 
261*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(false);
262*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventDebugLoggingEnabled(0);
263*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogGestureConsume("InterpreterTest_LogGestureTest", move);
264*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
265*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogGestureProduce("InterpreterTest_LogGestureTest", move);
266*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 0);
267*aed3e508SAndroid Build Coastguard Worker 
268*aed3e508SAndroid Build Coastguard Worker 
269*aed3e508SAndroid Build Coastguard Worker   using EventDebug = ActivityLog::EventDebug;
270*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(true);
271*aed3e508SAndroid Build Coastguard Worker   base_interpreter.EventDebugLoggingEnable(EventDebug::Gesture);
272*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogGestureConsume("InterpreterTest_LogGestureTest", move);
273*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 1);
274*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogGestureProduce("InterpreterTest_LogGestureTest", move);
275*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 2);
276*aed3e508SAndroid Build Coastguard Worker }
277*aed3e508SAndroid Build Coastguard Worker 
TEST(InterpreterTest,LogHandleTimerTest)278*aed3e508SAndroid Build Coastguard Worker TEST(InterpreterTest, LogHandleTimerTest) {
279*aed3e508SAndroid Build Coastguard Worker   PropRegistry prop_reg;
280*aed3e508SAndroid Build Coastguard Worker   InterpreterResetLogTestInterpreter base_interpreter;
281*aed3e508SAndroid Build Coastguard Worker 
282*aed3e508SAndroid Build Coastguard Worker   using EventDebug = ActivityLog::EventDebug;
283*aed3e508SAndroid Build Coastguard Worker   base_interpreter.SetEventLoggingEnabled(true);
284*aed3e508SAndroid Build Coastguard Worker   base_interpreter.EventDebugLoggingEnable(EventDebug::HandleTimer);
285*aed3e508SAndroid Build Coastguard Worker 
286*aed3e508SAndroid Build Coastguard Worker   stime_t timeout = 10;
287*aed3e508SAndroid Build Coastguard Worker 
288*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHandleTimerPre("InterpreterTest_LogHandleTimerTest",
289*aed3e508SAndroid Build Coastguard Worker         0, &timeout);
290*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 1);
291*aed3e508SAndroid Build Coastguard Worker 
292*aed3e508SAndroid Build Coastguard Worker   base_interpreter.LogHandleTimerPost("InterpreterTest_LogHandleTimerTest",
293*aed3e508SAndroid Build Coastguard Worker         0, &timeout);
294*aed3e508SAndroid Build Coastguard Worker   EXPECT_EQ(base_interpreter.log_->size(), 2);
295*aed3e508SAndroid Build Coastguard Worker }
296*aed3e508SAndroid Build Coastguard Worker 
297*aed3e508SAndroid Build Coastguard Worker }  // namespace gestures
298