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

Unified Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 386043002: Added wrapper test class for touch_exploration_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a possible fix Created 6 years, 5 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
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/chromeos/touch_exploration_controller_unittest.cc
diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc
index 6b1f3dea84621539f4b272c9c94ed4bd714e37d3..70bac63e756ee6fb2fd0954e6db0c243400f5534 100644
--- a/ui/chromeos/touch_exploration_controller_unittest.cc
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc
@@ -22,6 +22,7 @@
namespace ui {
namespace {
+
// Records all mouse, touch, gesture, and key events.
class EventCapturer : public ui::EventHandler {
public:
@@ -73,6 +74,54 @@ int Factorial(int n) {
} // namespace
+class TouchExplorationControllerTestApi {
+ public:
+ TouchExplorationControllerTestApi(
+ TouchExplorationController* touch_exploration_controller) {
+ touch_exploration_controller_.reset(touch_exploration_controller);
+ }
+
+ void CallTapTimerNowForTesting() {
+ DCHECK(touch_exploration_controller_->tap_timer_.IsRunning());
+ touch_exploration_controller_->tap_timer_.Stop();
+ touch_exploration_controller_->OnTapTimerFired();
+ }
+
+ void CallTapTimerNowIfRunningForTesting() {
+ if (touch_exploration_controller_->tap_timer_.IsRunning()) {
+ touch_exploration_controller_->tap_timer_.Stop();
+ touch_exploration_controller_->OnTapTimerFired();
+ }
+ }
+
+ void SetEventHandlerForTesting(
+ ui::EventHandler* event_handler_for_testing) {
+ touch_exploration_controller_->event_handler_for_testing_ =
+ event_handler_for_testing;
+ }
+
+ bool IsInNoFingersDownStateForTesting() const {
+ return touch_exploration_controller_->state_ ==
+ touch_exploration_controller_->NO_FINGERS_DOWN;
+ }
+
+ bool IsInGestureInProgressStateForTesting() const {
+ return touch_exploration_controller_->state_ ==
+ touch_exploration_controller_->GESTURE_IN_PROGRESS;
+ }
+
+ // VLOGs should be suppressed in tests that generate a lot of logs,
+ // for example permutations of nine touch events.
+ void SuppressVLOGsForTesting(bool suppress) {
+ touch_exploration_controller_->VLOG_on_ = !suppress;
+ }
+
+ private:
+ scoped_ptr<TouchExplorationController> touch_exploration_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
+};
+
class TouchExplorationTest : public aura::test::AuraTestBase {
public:
TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
@@ -163,8 +212,8 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
if (!on && touch_exploration_controller_.get()) {
touch_exploration_controller_.reset();
} else if (on && !touch_exploration_controller_.get()) {
- touch_exploration_controller_.reset(
- new ui::TouchExplorationController(root_window()));
+ touch_exploration_controller_.reset(new TouchExplorationControllerTestApi(
+ new ui::TouchExplorationController(root_window())));
touch_exploration_controller_->SetEventHandlerForTesting(
&event_capturer_);
cursor_client()->ShowCursor();
@@ -221,7 +270,8 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
private:
EventCapturer event_capturer_;
- scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_;
+ scoped_ptr<TouchExplorationControllerTestApi>
+ touch_exploration_controller_;
scoped_ptr<aura::test::TestCursorClient> cursor_client_;
DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest);
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698