Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: ui/chromeos/touch_exploration_controller.cc

Issue 358693004: Added touch event permutations test to touch_exploration_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_passthrough
Patch Set: permutations doesn't run VLOGS and doesn't break the DCHECK anymore Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/chromeos/touch_exploration_controller.cc
diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc
index 1a77b971aa9b0c7ad59f56d2004267541b4592dc..004a96ece03ac599a4aef7044ada989c9f90b78d 100644
--- a/ui/chromeos/touch_exploration_controller.cc
+++ b/ui/chromeos/touch_exploration_controller.cc
@@ -23,7 +23,8 @@ TouchExplorationController::TouchExplorationController(
: root_window_(root_window),
state_(NO_FINGERS_DOWN),
event_handler_for_testing_(NULL),
- prev_state_(NO_FINGERS_DOWN) {
+ prev_state_(NO_FINGERS_DOWN),
+ VLOG_on_(true) {
CHECK(root_window);
root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
}
@@ -39,6 +40,20 @@ void TouchExplorationController::CallTapTimerNowForTesting() {
OnTapTimerFired();
}
+void TouchExplorationController::CallTapTimerNowIfRunningForTesting() {
+ if (tap_timer_.IsRunning()) {
+ tap_timer_.Stop();
+ OnTapTimerFired();
+ }
+}
+
+void TouchExplorationController::SwitchVLOG(bool turn_on) {
+ if (turn_on)
dmazzoni 2014/07/02 23:05:57 You can just say VLOG_on_ = turn_on, no "if" neede
evy 2014/07/02 23:16:03 Done.
+ VLOG_on_ = true;
+ else
+ VLOG_on_ = false;
+}
+
void TouchExplorationController::SetEventHandlerForTesting(
ui::EventHandler* event_handler_for_testing) {
event_handler_for_testing_ = event_handler_for_testing;
@@ -54,8 +69,8 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
if (!event.IsTouchEvent()) {
if (event.IsKeyEvent()) {
const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event);
- VLOG(0) << "\nKeyboard event: " << key_event.name() << "\n"
- << " Key code: " << key_event.key_code()
+ VLOG(0) << "\nKeyboard event: " << key_event.name()
+ << "\n Key code: " << key_event.key_code()
<< ", Flags: " << key_event.flags()
<< ", Is char: " << key_event.is_char();
}
@@ -156,7 +171,7 @@ ui::EventRewriteStatus TouchExplorationController::InNoFingersDown(
VLOG_STATE();
return ui::EVENT_REWRITE_DISCARD;
}
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();;
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -196,7 +211,7 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
}
return EVENT_REWRITE_DISCARD;
}
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();;
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -228,8 +243,10 @@ TouchExplorationController::InSingleTapOrTouchExploreReleased(
ResetToNoFingersDown();
}
return ui::EVENT_REWRITE_DISCARD;
+ } else if (type == ui::ET_TOUCH_MOVED){
+ return ui::EVENT_REWRITE_DISCARD;
}
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -255,7 +272,7 @@ ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed(
} else if (type == ui::ET_TOUCH_MOVED) {
return ui::EVENT_REWRITE_DISCARD;
}
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -286,7 +303,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
state_ = TOUCH_EXPLORE_RELEASED;
VLOG_STATE();
} else if (type != ui::ET_TOUCH_MOVED) {
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -296,7 +313,6 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
return ui::EVENT_REWRITE_REWRITTEN;
}
-
ui::EventRewriteStatus TouchExplorationController::InTwoToOneFinger(
const ui::TouchEvent& event,
scoped_ptr<ui::Event>* rewritten_event) {
@@ -355,7 +371,7 @@ ui::EventRewriteStatus TouchExplorationController::InTwoToOneFinger(
return ui::EVENT_REWRITE_REWRITTEN;
}
}
- NOTREACHED() << "Unexpected event type received";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -366,7 +382,7 @@ ui::EventRewriteStatus TouchExplorationController::InPassthrough(
if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED ||
type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) {
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -418,7 +434,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress(
VLOG_STATE();
return ui::EVENT_REWRITE_REWRITTEN;
}
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
@@ -428,7 +444,7 @@ ui::EventRewriteStatus TouchExplorationController::InWaitForRelease(
ui::EventType type = event.type();
if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED ||
type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) {
- NOTREACHED() << "Unexpected event type received.";
+ NOTREACHED() << "Unexpected event type received: " << event.name();
return ui::EVENT_REWRITE_CONTINUE;
}
if (current_touch_ids_.size() == 0) {
@@ -500,6 +516,8 @@ void TouchExplorationController::ResetToNoFingersDown() {
}
void TouchExplorationController::VlogState(const char* function_name) {
+ if (!VLOG_on_)
+ return;
if (prev_state_ == state_)
return;
prev_state_ = state_;
@@ -510,6 +528,9 @@ void TouchExplorationController::VlogState(const char* function_name) {
void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event,
const char* function_name) {
+ if (!VLOG_on_)
+ return;
+
CHECK(touch_event.IsTouchEvent());
if (prev_event_ != NULL &&
prev_event_->type() == touch_event.type() &&

Powered by Google App Engine
This is Rietveld 408576698