| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/renderer_host/input/gesture_text_selector.h" | 10 #include "content/browser/renderer_host/input/gesture_text_selector.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
| 13 #include "ui/events/gesture_detection/motion_event.h" | 13 #include "ui/events/gesture_detection/motion_event.h" |
| 14 #include "ui/events/test/motion_event_test_utils.h" | 14 #include "ui/events/test/motion_event_test_utils.h" |
| 15 #include "ui/gfx/geometry/rect_f.h" | 15 #include "ui/gfx/geometry/rect_f.h" |
| 16 | 16 |
| 17 using ui::MotionEvent; | 17 using ui::MotionEvent; |
| 18 using ui::test::MockMotionEvent; | 18 using ui::test::MockMotionEvent; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class GestureTextSelectorTest : public testing::Test, | 22 class GestureTextSelectorTest : public testing::Test, |
| 23 public GestureTextSelectorClient { | 23 public GestureTextSelectorClient { |
| 24 public: | 24 public: |
| 25 GestureTextSelectorTest() {} | 25 GestureTextSelectorTest() {} |
| 26 virtual ~GestureTextSelectorTest() {} | 26 ~GestureTextSelectorTest() override {} |
| 27 | 27 |
| 28 // Test implementation. | 28 // Test implementation. |
| 29 virtual void SetUp() override { | 29 void SetUp() override { |
| 30 selector_.reset(new GestureTextSelector(this)); | 30 selector_.reset(new GestureTextSelector(this)); |
| 31 event_log_.clear(); | 31 event_log_.clear(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void TearDown() override { | 34 void TearDown() override { |
| 35 selector_.reset(); | 35 selector_.reset(); |
| 36 event_log_.clear(); | 36 event_log_.clear(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // GestureTextSelectorClient implementation. | 39 // GestureTextSelectorClient implementation. |
| 40 void ShowSelectionHandlesAutomatically() override { | 40 void ShowSelectionHandlesAutomatically() override { |
| 41 event_log_.push_back("Show"); | 41 event_log_.push_back("Show"); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SelectRange(float x1, float y1, float x2, float y2) override { | 44 void SelectRange(float x1, float y1, float x2, float y2) override { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 event_time += base::TimeDelta::FromMilliseconds(1); | 214 event_time += base::TimeDelta::FromMilliseconds(1); |
| 215 MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x2, y2); | 215 MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x2, y2); |
| 216 action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 216 action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
| 217 action_up.set_button_state(0); | 217 action_up.set_button_state(0); |
| 218 EXPECT_TRUE(selector_->OnTouchEvent(action_up)); | 218 EXPECT_TRUE(selector_->OnTouchEvent(action_up)); |
| 219 ASSERT_EQ(1u, event_log_.size()); | 219 ASSERT_EQ(1u, event_log_.size()); |
| 220 EXPECT_STREQ("LongPress", event_log_.back().c_str()); | 220 EXPECT_STREQ("LongPress", event_log_.back().c_str()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace content | 223 } // namespace content |
| OLD | NEW |