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 "content/browser/renderer_host/input/stylus_text_selector.h" | 5 #include "content/browser/renderer_host/input/stylus_text_selector.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ss << "Begin(" << x0 << ", " << y0 << ", " << x1 << ", " << y1 << ")"; | 43 ss << "Begin(" << x0 << ", " << y0 << ", " << x1 << ", " << y1 << ")"; |
44 event_log_.push_back(ss.str()); | 44 event_log_.push_back(ss.str()); |
45 } | 45 } |
46 | 46 |
47 void OnStylusSelectUpdate(float x, float y) override { | 47 void OnStylusSelectUpdate(float x, float y) override { |
48 std::stringstream ss; | 48 std::stringstream ss; |
49 ss << "Update(" << x << ", " << y << ")"; | 49 ss << "Update(" << x << ", " << y << ")"; |
50 event_log_.push_back(ss.str()); | 50 event_log_.push_back(ss.str()); |
51 } | 51 } |
52 | 52 |
53 void OnStylusSelectEnd() override { event_log_.push_back("End"); } | |
54 | |
55 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override { | 53 void OnStylusSelectTap(base::TimeTicks time, float x, float y) override { |
56 event_log_.push_back("Tap"); | 54 event_log_.push_back("Tap"); |
57 } | 55 } |
58 | 56 |
59 protected: | 57 protected: |
60 std::unique_ptr<StylusTextSelector> selector_; | 58 std::unique_ptr<StylusTextSelector> selector_; |
61 std::vector<std::string> event_log_; | 59 std::vector<std::string> event_log_; |
62 }; | 60 }; |
63 | 61 |
64 TEST_F(StylusTextSelectorTest, ShouldStartTextSelection) { | 62 TEST_F(StylusTextSelectorTest, ShouldStartTextSelection) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 event_time += base::TimeDelta::FromMilliseconds(1); | 237 event_time += base::TimeDelta::FromMilliseconds(1); |
240 MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x2, y2); | 238 MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x2, y2); |
241 action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 239 action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
242 action_up.set_button_state(0); | 240 action_up.set_button_state(0); |
243 EXPECT_TRUE(selector_->OnTouchEvent(action_up)); | 241 EXPECT_TRUE(selector_->OnTouchEvent(action_up)); |
244 ASSERT_EQ(1u, event_log_.size()); | 242 ASSERT_EQ(1u, event_log_.size()); |
245 EXPECT_STREQ("Tap", event_log_.back().c_str()); | 243 EXPECT_STREQ("Tap", event_log_.back().c_str()); |
246 } | 244 } |
247 | 245 |
248 } // namespace content | 246 } // namespace content |
OLD | NEW |