| OLD | NEW | 
|    1 // Copyright 2013 The Chromium Authors. All rights reserved. |    1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "base/basictypes.h" |    5 #include "base/basictypes.h" | 
|    6 #include "base/logging.h" |    6 #include "base/logging.h" | 
|    7 #include "base/memory/scoped_ptr.h" |    7 #include "base/memory/scoped_ptr.h" | 
|    8 #include "content/browser/renderer_host/input/mock_web_input_event_builders.h" |    8 #include "content/browser/renderer_host/input/mock_web_input_event_builders.h" | 
|    9 #include "content/browser/renderer_host/input/touch_event_queue.h" |    9 #include "content/browser/renderer_host/input/touch_event_queue.h" | 
|   10 #include "testing/gtest/include/gtest/gtest.h" |   10 #include "testing/gtest/include/gtest/gtest.h" | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  111   } |  111   } | 
|  112  |  112  | 
|  113   const WebTouchEvent& acked_event() const { |  113   const WebTouchEvent& acked_event() const { | 
|  114     return last_acked_event_; |  114     return last_acked_event_; | 
|  115   } |  115   } | 
|  116  |  116  | 
|  117   InputEventAckState acked_event_state() const { |  117   InputEventAckState acked_event_state() const { | 
|  118     return last_acked_event_state_; |  118     return last_acked_event_state_; | 
|  119   } |  119   } | 
|  120  |  120  | 
|  121   void set_no_touch_move_to_renderer(bool no_touch_move) { |  121   void set_no_touch_to_renderer(bool no_touch) { | 
|  122     queue_->set_no_touch_move_to_renderer(no_touch_move); |  122     queue_->no_touch_to_renderer_ = no_touch; | 
|  123   } |  123   } | 
|  124  |  124  | 
|  125   bool no_touch_move_to_renderer() const { |  125   bool no_touch_to_renderer() const { | 
|  126     return queue_->no_touch_move_to_renderer_; |  126     return queue_->no_touch_to_renderer_; | 
|  127   } |  127   } | 
|  128  |  128  | 
|  129  private: |  129  private: | 
|  130   scoped_ptr<TouchEventQueue> queue_; |  130   scoped_ptr<TouchEventQueue> queue_; | 
|  131   size_t sent_event_count_; |  131   size_t sent_event_count_; | 
|  132   size_t acked_event_count_; |  132   size_t acked_event_count_; | 
|  133   WebTouchEvent last_sent_event_; |  133   WebTouchEvent last_sent_event_; | 
|  134   WebTouchEvent last_acked_event_; |  134   WebTouchEvent last_acked_event_; | 
|  135   InputEventAckState last_acked_event_state_; |  135   InputEventAckState last_acked_event_state_; | 
|  136   MockWebTouchEvent touch_event_; |  136   MockWebTouchEvent touch_event_; | 
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  634   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  634   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  635  |  635  | 
|  636   // Touch moves may trigger scroll. |  636   // Touch moves may trigger scroll. | 
|  637   MoveTouchPoint(0, 20, 5); |  637   MoveTouchPoint(0, 20, 5); | 
|  638   SendTouchEvent(); |  638   SendTouchEvent(); | 
|  639   EXPECT_EQ(1U, GetAndResetSentEventCount()); |  639   EXPECT_EQ(1U, GetAndResetSentEventCount()); | 
|  640   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |  640   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
|  641   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  641   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  642  |  642  | 
|  643   // Touch move should not be sent to renderer (e.g., when scrolling starts). |  643   // Touch move should not be sent to renderer (e.g., when scrolling starts). | 
|  644   set_no_touch_move_to_renderer(true); |  644   set_no_touch_to_renderer(true); | 
|  645   MoveTouchPoint(0, 30, 5); |  645   MoveTouchPoint(0, 30, 5); | 
|  646   SendTouchEvent(); |  646   SendTouchEvent(); | 
|  647   EXPECT_EQ(0U, GetAndResetSentEventCount()); |  647   EXPECT_EQ(0U, GetAndResetSentEventCount()); | 
|  648   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  648   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  649  |  649  | 
|  650   // Touch move should not be sent to renderer. |  650   // Touch move should not be sent to renderer. | 
|  651   MoveTouchPoint(0, 65, 10); |  651   MoveTouchPoint(0, 65, 10); | 
|  652   SendTouchEvent(); |  652   SendTouchEvent(); | 
|  653   EXPECT_EQ(0U, GetAndResetSentEventCount()); |  653   EXPECT_EQ(0U, GetAndResetSentEventCount()); | 
|  654   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  654   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  655  |  655  | 
|  656   // Touch end should still be sent to renderer. |  656   // Touch end should not be sent to renderer. | 
|  657   ReleaseTouchPoint(0); |  657   ReleaseTouchPoint(0); | 
|  658   SendTouchEvent(); |  658   SendTouchEvent(); | 
|  659   EXPECT_EQ(1U, GetAndResetSentEventCount()); |  659   EXPECT_EQ(0U, GetAndResetSentEventCount()); | 
|  660   EXPECT_EQ(0U, GetAndResetAckedEventCount()); |  660   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  661  |  661  | 
|  662   // Resume sending touch moves to renderer (e.g., when scrolling ends). |  662   // Resume sending touch moves to renderer (e.g., when scrolling ends). | 
|  663   set_no_touch_move_to_renderer(false); |  663   set_no_touch_to_renderer(false); | 
|  664   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |  | 
|  665   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  | 
|  666  |  664  | 
|  667   // Now touch events should come through to renderer. |  665   // Now touch events should come through to renderer. | 
|  668   PressTouchPoint(80, 10); |  666   PressTouchPoint(80, 10); | 
|  669   SendTouchEvent(); |  667   SendTouchEvent(); | 
|  670   EXPECT_EQ(1U, GetAndResetSentEventCount()); |  668   EXPECT_EQ(1U, GetAndResetSentEventCount()); | 
|  671   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |  669   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
|  672   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  670   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  673  |  671  | 
|  674   MoveTouchPoint(0, 80, 20); |  672   MoveTouchPoint(0, 80, 20); | 
|  675   SendTouchEvent(); |  673   SendTouchEvent(); | 
|  676   EXPECT_EQ(1U, GetAndResetSentEventCount()); |  674   EXPECT_EQ(1U, GetAndResetSentEventCount()); | 
|  677   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |  675   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
|  678   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  676   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  679  |  677  | 
|  680   ReleaseTouchPoint(0); |  678   ReleaseTouchPoint(0); | 
|  681   SendTouchEvent(); |  679   SendTouchEvent(); | 
|  682   EXPECT_EQ(1U, GetAndResetSentEventCount()); |  680   EXPECT_EQ(1U, GetAndResetSentEventCount()); | 
|  683   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |  681   SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
|  684   EXPECT_EQ(1U, GetAndResetAckedEventCount()); |  682   EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 
|  685 } |  683 } | 
|  686  |  684  | 
|  687 }  // namespace content |  685 }  // namespace content | 
| OLD | NEW |