OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 const gfx::Rect& bounding_box() const { return bounding_box_; } | 169 const gfx::Rect& bounding_box() const { return bounding_box_; } |
170 int tap_count() const { return tap_count_; } | 170 int tap_count() const { return tap_count_; } |
171 | 171 |
172 void WaitUntilReceivedGesture(ui::EventType type) { | 172 void WaitUntilReceivedGesture(ui::EventType type) { |
173 wait_until_event_ = type; | 173 wait_until_event_ = type; |
174 run_loop_.reset(new base::RunLoop( | 174 run_loop_.reset(new base::RunLoop( |
175 Env::GetInstance()->GetDispatcher())); | 175 Env::GetInstance()->GetDispatcher())); |
176 run_loop_->Run(); | 176 run_loop_->Run(); |
177 } | 177 } |
178 | 178 |
179 virtual ui::EventResult OnGestureEvent( | 179 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { |
180 ui::GestureEvent* gesture) OVERRIDE { | |
181 events_.push_back(gesture->type()); | 180 events_.push_back(gesture->type()); |
182 bounding_box_ = gesture->details().bounding_box(); | 181 bounding_box_ = gesture->details().bounding_box(); |
183 switch (gesture->type()) { | 182 switch (gesture->type()) { |
184 case ui::ET_GESTURE_TAP: | 183 case ui::ET_GESTURE_TAP: |
185 tap_location_ = gesture->location(); | 184 tap_location_ = gesture->location(); |
186 tap_count_ = gesture->details().tap_count(); | 185 tap_count_ = gesture->details().tap_count(); |
187 tap_ = true; | 186 tap_ = true; |
188 break; | 187 break; |
189 case ui::ET_GESTURE_TAP_DOWN: | 188 case ui::ET_GESTURE_TAP_DOWN: |
190 tap_down_ = true; | 189 tap_down_ = true; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 swipe_up_ = gesture->details().swipe_up(); | 248 swipe_up_ = gesture->details().swipe_up(); |
250 swipe_down_ = gesture->details().swipe_down(); | 249 swipe_down_ = gesture->details().swipe_down(); |
251 break; | 250 break; |
252 default: | 251 default: |
253 NOTREACHED(); | 252 NOTREACHED(); |
254 } | 253 } |
255 if (wait_until_event_ == gesture->type() && run_loop_.get()) { | 254 if (wait_until_event_ == gesture->type() && run_loop_.get()) { |
256 run_loop_->Quit(); | 255 run_loop_->Quit(); |
257 wait_until_event_ = ui::ET_UNKNOWN; | 256 wait_until_event_ = ui::ET_UNKNOWN; |
258 } | 257 } |
259 return ui::ER_CONSUMED; | 258 gesture->StopPropagation(); |
260 } | 259 } |
261 | 260 |
262 private: | 261 private: |
263 scoped_ptr<base::RunLoop> run_loop_; | 262 scoped_ptr<base::RunLoop> run_loop_; |
264 std::vector<ui::EventType> events_; | 263 std::vector<ui::EventType> events_; |
265 | 264 |
266 bool tap_; | 265 bool tap_; |
267 bool tap_down_; | 266 bool tap_down_; |
268 bool tap_cancel_; | 267 bool tap_cancel_; |
269 bool begin_; | 268 bool begin_; |
(...skipping 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); | 3015 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
3017 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 3016 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
3018 EXPECT_TRUE(delegate->scroll_update()); | 3017 EXPECT_TRUE(delegate->scroll_update()); |
3019 EXPECT_EQ(-1, delegate->scroll_y()); | 3018 EXPECT_EQ(-1, delegate->scroll_y()); |
3020 | 3019 |
3021 delegate->Reset(); | 3020 delegate->Reset(); |
3022 } | 3021 } |
3023 | 3022 |
3024 } // namespace test | 3023 } // namespace test |
3025 } // namespace aura | 3024 } // namespace aura |
OLD | NEW |