Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "views/focus/accelerator_handler.h" | 30 #include "views/focus/accelerator_handler.h" |
| 31 #include "views/focus/view_storage.h" | 31 #include "views/focus/view_storage.h" |
| 32 #include "views/test/views_test_base.h" | 32 #include "views/test/views_test_base.h" |
| 33 #include "views/touchui/gesture_manager.h" | 33 #include "views/touchui/gesture_manager.h" |
| 34 #include "views/view.h" | 34 #include "views/view.h" |
| 35 #include "views/views_delegate.h" | 35 #include "views/views_delegate.h" |
| 36 #include "views/widget/native_widget.h" | 36 #include "views/widget/native_widget.h" |
| 37 #include "views/widget/root_view.h" | 37 #include "views/widget/root_view.h" |
| 38 #include "views/window/dialog_delegate.h" | 38 #include "views/window/dialog_delegate.h" |
| 39 | 39 |
| 40 #if defined(TOUCH_UI) | |
| 41 // TODO(Gajen): This voilates Google coding style but placing this above | |
| 42 // testing/gmock/include/gmock/gmock.h doesn't let gtest to compile. | |
| 43 #include <X11/Xlib.h> | |
|
rjkroege
2011/11/09 02:43:30
I think that the need for this here is a sign of a
Gajen
2011/11/09 18:14:43
This was required to instantiate base::NativeEvent
Gajen
2011/11/10 15:52:55
Deprecated, currently MockGesture is used for GM.
| |
| 44 #endif | |
| 45 | |
| 40 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 41 #include "views/test/test_views_delegate.h" | 47 #include "views/test/test_views_delegate.h" |
| 42 #endif | 48 #endif |
| 43 #if defined(USE_AURA) | 49 #if defined(USE_AURA) |
| 44 #include "ui/aura/desktop.h" | 50 #include "ui/aura/desktop.h" |
| 45 #endif | 51 #endif |
| 52 #if defined(TOUCH_UI) | |
| 53 #include "views/touchui/gesture_recognizer.h" | |
| 54 #endif | |
| 46 | 55 |
| 47 using ::testing::_; | 56 using ::testing::_; |
| 48 | 57 |
| 49 namespace { | 58 namespace { |
| 50 | 59 |
| 51 // Returns true if |ancestor| is an ancestor of |layer|. | 60 // Returns true if |ancestor| is an ancestor of |layer|. |
| 52 bool LayerIsAncestor(const ui::Layer* ancestor, const ui::Layer* layer) { | 61 bool LayerIsAncestor(const ui::Layer* ancestor, const ui::Layer* layer) { |
| 53 while (layer && layer != ancestor) | 62 while (layer && layer != ancestor) |
| 54 layer = layer->parent(); | 63 layer = layer->parent(); |
| 55 return layer == ancestor; | 64 return layer == ancestor; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 TestView() : View(), in_touch_sequence_(false) {} | 206 TestView() : View(), in_touch_sequence_(false) {} |
| 198 virtual ~TestView() {} | 207 virtual ~TestView() {} |
| 199 | 208 |
| 200 // Reset all test state | 209 // Reset all test state |
| 201 void Reset() { | 210 void Reset() { |
| 202 did_change_bounds_ = false; | 211 did_change_bounds_ = false; |
| 203 last_mouse_event_type_ = 0; | 212 last_mouse_event_type_ = 0; |
| 204 location_.SetPoint(0, 0); | 213 location_.SetPoint(0, 0); |
| 205 last_touch_event_type_ = 0; | 214 last_touch_event_type_ = 0; |
| 206 last_touch_event_was_handled_ = false; | 215 last_touch_event_was_handled_ = false; |
| 216 last_gesture_event_type_ = 0; | |
| 217 last_gesture_event_was_handled_ = false; | |
| 207 last_clip_.setEmpty(); | 218 last_clip_.setEmpty(); |
| 208 accelerator_count_map_.clear(); | 219 accelerator_count_map_.clear(); |
| 209 } | 220 } |
| 210 | 221 |
| 211 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 222 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 212 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 223 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
| 213 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 224 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
| 214 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 225 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
| 215 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 226 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 227 | |
| 228 // Ignores GestureEvent by default. | |
| 229 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; | |
| 216 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; | 230 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; |
| 217 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | 231 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; |
| 218 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; | 232 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; |
| 219 | 233 |
| 220 // OnBoundsChanged. | 234 // OnBoundsChanged. |
| 221 bool did_change_bounds_; | 235 bool did_change_bounds_; |
| 222 gfx::Rect new_bounds_; | 236 gfx::Rect new_bounds_; |
| 223 | 237 |
| 224 // MouseEvent. | 238 // MouseEvent. |
| 225 int last_mouse_event_type_; | 239 int last_mouse_event_type_; |
| 226 gfx::Point location_; | 240 gfx::Point location_; |
| 227 | 241 |
| 228 // Painting. | 242 // Painting. |
| 229 std::vector<gfx::Rect> scheduled_paint_rects_; | 243 std::vector<gfx::Rect> scheduled_paint_rects_; |
| 230 | 244 |
| 231 // TouchEvent. | 245 // TouchEvent. |
| 232 int last_touch_event_type_; | 246 int last_touch_event_type_; |
| 233 bool last_touch_event_was_handled_; | 247 bool last_touch_event_was_handled_; |
| 234 bool in_touch_sequence_; | 248 bool in_touch_sequence_; |
| 235 | 249 |
| 250 // GestureEvent | |
| 251 int last_gesture_event_type_; | |
| 252 bool last_gesture_event_was_handled_; | |
| 253 | |
| 236 // Painting. | 254 // Painting. |
| 237 SkRect last_clip_; | 255 SkRect last_clip_; |
| 238 | 256 |
| 239 // Accelerators. | 257 // Accelerators. |
| 240 std::map<Accelerator, int> accelerator_count_map_; | 258 std::map<Accelerator, int> accelerator_count_map_; |
| 241 }; | 259 }; |
| 242 | 260 |
| 243 // Mock instance of the GestureManager for testing. | 261 // Mock instance of the GestureManager for testing. |
| 244 class MockGestureManager : public GestureManager { | 262 class MockGestureManager : public GestureManager { |
| 245 public: | 263 public: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 257 MockGestureManager(); | 275 MockGestureManager(); |
| 258 | 276 |
| 259 bool previously_handled_flag_; | 277 bool previously_handled_flag_; |
| 260 int last_touch_event_; | 278 int last_touch_event_; |
| 261 View *last_view_; | 279 View *last_view_; |
| 262 bool dispatched_synthetic_event_; | 280 bool dispatched_synthetic_event_; |
| 263 | 281 |
| 264 DISALLOW_COPY_AND_ASSIGN(MockGestureManager); | 282 DISALLOW_COPY_AND_ASSIGN(MockGestureManager); |
| 265 }; | 283 }; |
| 266 | 284 |
| 285 // GestureRecognizer for testing. | |
| 286 class TestGestureRecognizer: public GestureRecognizer { | |
| 287 public: | |
| 288 // Reset all test state. | |
| 289 void reset() { | |
| 290 last_touch_event_ = 0; | |
| 291 last_gesture_event_ = 0; | |
| 292 last_view_ = NULL; | |
| 293 previously_handled_flag_ = false; | |
| 294 dispatched_synthetic_event_ = false; | |
| 295 } | |
| 296 | |
| 297 virtual bool ProcessTouchEventForGesture(const TouchEvent& event, | |
| 298 View* source, | |
| 299 ui::TouchStatus status) OVERRIDE; | |
| 300 TestGestureRecognizer(); | |
| 301 | |
| 302 bool previously_handled_flag_; | |
| 303 int last_touch_event_; | |
| 304 int last_gesture_event_; | |
| 305 View *last_view_; | |
| 306 bool dispatched_synthetic_event_; | |
| 307 | |
| 308 DISALLOW_COPY_AND_ASSIGN(TestGestureRecognizer); | |
| 309 }; | |
| 310 | |
| 267 // A view subclass that ignores all touch events for testing purposes. | 311 // A view subclass that ignores all touch events for testing purposes. |
| 268 class TestViewIgnoreTouch : public TestView { | 312 class TestViewIgnoreTouch : public TestView { |
| 269 public: | 313 public: |
| 270 TestViewIgnoreTouch() : TestView() {} | 314 TestViewIgnoreTouch() : TestView() {} |
| 271 virtual ~TestViewIgnoreTouch() {} | 315 virtual ~TestViewIgnoreTouch() {} |
| 272 | 316 |
| 273 private: | 317 private: |
| 274 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 318 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 275 }; | 319 }; |
| 276 | 320 |
| 321 // A view subclass that consumes all Gesture events for testing purposes. | |
| 322 class TestViewConsumeGesture : public TestView { | |
| 323 public: | |
| 324 TestViewConsumeGesture() : TestView() {} | |
| 325 virtual ~TestViewConsumeGesture() {} | |
| 326 | |
| 327 private: | |
| 328 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | |
| 329 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; | |
| 330 }; | |
| 331 | |
| 277 //////////////////////////////////////////////////////////////////////////////// | 332 //////////////////////////////////////////////////////////////////////////////// |
| 278 // OnBoundsChanged | 333 // OnBoundsChanged |
| 279 //////////////////////////////////////////////////////////////////////////////// | 334 //////////////////////////////////////////////////////////////////////////////// |
| 280 | 335 |
| 281 void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 336 void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 282 did_change_bounds_ = true; | 337 did_change_bounds_ = true; |
| 283 new_bounds_ = bounds(); | 338 new_bounds_ = bounds(); |
| 284 } | 339 } |
| 285 | 340 |
| 286 TEST_F(ViewTest, OnBoundsChanged) { | 341 TEST_F(ViewTest, OnBoundsChanged) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 EXPECT_EQ(v1->last_touch_event_type_, 0); | 586 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 532 | 587 |
| 533 EXPECT_EQ(gm.last_touch_event_, 0); | 588 EXPECT_EQ(gm.last_touch_event_, 0); |
| 534 EXPECT_EQ(NULL, gm.last_view_); | 589 EXPECT_EQ(NULL, gm.last_view_); |
| 535 EXPECT_EQ(gm.previously_handled_flag_, false); | 590 EXPECT_EQ(gm.previously_handled_flag_, false); |
| 536 | 591 |
| 537 widget->CloseNow(); | 592 widget->CloseNow(); |
| 538 } | 593 } |
| 539 | 594 |
| 540 //////////////////////////////////////////////////////////////////////////////// | 595 //////////////////////////////////////////////////////////////////////////////// |
| 596 // GestureEvent | |
| 597 //////////////////////////////////////////////////////////////////////////////// | |
| 598 | |
| 599 bool TestGestureRecognizer::ProcessTouchEventForGesture( | |
| 600 const TouchEvent& event, | |
| 601 View* source, | |
| 602 ui::TouchStatus status) { | |
| 603 if (status != ui::TOUCH_STATUS_UNKNOWN) { | |
| 604 dispatched_synthetic_event_ = false; | |
| 605 return false; | |
| 606 } | |
| 607 last_touch_event_ = event.type(); | |
| 608 last_view_ = source; | |
| 609 previously_handled_flag_ = status != ui::TOUCH_STATUS_UNKNOWN; | |
| 610 dispatched_synthetic_event_ = GestureRecognizer::ProcessTouchEventForGesture( | |
| 611 event, source, status); | |
| 612 return true; | |
| 613 } | |
| 614 | |
| 615 TestGestureRecognizer::TestGestureRecognizer() { | |
| 616 } | |
| 617 | |
| 618 ui::GestureStatus TestView::OnGestureEvent(const GestureEvent& event) { | |
| 619 return ui::GESTURE_STATUS_UNKNOWN; | |
| 620 } | |
| 621 | |
| 622 // GestureConsumer view should ignore TouchEvent for testing purposes. | |
| 623 ui::TouchStatus TestViewConsumeGesture::OnTouchEvent( | |
| 624 const TouchEvent& event) { | |
| 625 return ui::TOUCH_STATUS_UNKNOWN; | |
| 626 } | |
| 627 | |
| 628 ui::GestureStatus TestViewConsumeGesture::OnGestureEvent( | |
| 629 const GestureEvent& event) { | |
| 630 last_gesture_event_type_ = event.type(); | |
| 631 location_.SetPoint(event.x(), event.y()); | |
| 632 return ui::GESTURE_STATUS_CONSUMED; | |
| 633 } | |
| 634 | |
| 635 #if defined(TOUCH_UI) | |
| 636 TEST_F(ViewTest, GestureEvent) { | |
| 637 TestGestureRecognizer gm; | |
| 638 | |
| 639 // Views hierarchy for non delivery of GestureEvent. | |
| 640 TestView* v1 = new TestViewConsumeGesture(); | |
| 641 v1->SetBounds(0, 0, 300, 300); | |
| 642 | |
| 643 TestView* v2 = new TestView(); | |
| 644 v2->SetBounds(100, 100, 100, 100); | |
| 645 | |
| 646 TestView* v3 = new TestViewConsumeGesture(); | |
| 647 v3->SetBounds(0, 0, 100, 100); | |
| 648 | |
| 649 // Views hierarchy for delivery of GestureEvent. | |
| 650 TestView* v4 = new TestViewConsumeGesture(); | |
| 651 v4->SetBounds(200, 200, 100, 100); | |
| 652 | |
| 653 scoped_ptr<Widget> widget(new Widget()); | |
| 654 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | |
| 655 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 656 params.bounds = gfx::Rect(50, 50, 650, 650); | |
| 657 widget->Init(params); | |
| 658 View* root = widget->GetRootView(); | |
| 659 | |
| 660 root->AddChildView(v1); | |
| 661 static_cast<internal::RootView*>(root)->SetGestureManagerForTesting(&gm); | |
| 662 v1->AddChildView(v2); | |
| 663 v2->AddChildView(v3); | |
| 664 v1->AddChildView(v4); | |
| 665 | |
| 666 // |v3| completely obscures |v2|, but all the touch events on |v3| should | |
|
rjkroege
2011/11/09 02:43:30
This is testing gesture events? Can you updated th
Gajen
2011/11/10 15:52:55
Done.
| |
| 667 // reach |v2| because |v3| doesn't process any touch events, hence |v3| | |
| 668 // should also not recieve gesture events. | |
| 669 | |
| 670 // Both |v4| and |v1| ignore touch events, hence |v4| should recieve gesture | |
| 671 // events. | |
| 672 | |
| 673 // Make sure if none of the views handle the touch event, the gesture manager | |
| 674 // does. | |
| 675 v1->Reset(); | |
| 676 v2->Reset(); | |
| 677 v3->Reset(); | |
| 678 v4->Reset(); | |
| 679 gm.reset(); | |
| 680 | |
| 681 // Just to pass Touch to Mouse conversion process through | |
| 682 // EventFlagsFromNative(), EventLocationFromNative() in ui/base/x/events_x.cc. | |
| 683 XEvent native_event; | |
| 684 memset(&native_event, 0, sizeof(native_event)); | |
|
rjkroege
2011/11/09 02:43:30
this should not be necessary. You can construct th
Gajen
2011/11/09 18:14:43
Since, TouchEvent generated this way would set to
Gajen
2011/11/10 15:52:55
Deprecated, as new CL http://codereview.chromium.o
| |
| 685 | |
| 686 TouchEvent unhandled(ui::ET_TOUCH_MOVED, | |
| 687 400, | |
| 688 400, | |
| 689 0, /* no flags */ | |
| 690 0, /* first finger touch */ | |
| 691 1.0, 0.0, 1.0, 0.0); | |
| 692 | |
| 693 unhandled.set_native_event(&native_event); | |
| 694 root->OnTouchEvent(unhandled); | |
| 695 | |
| 696 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 697 EXPECT_EQ(v2->last_touch_event_type_, 0); | |
| 698 EXPECT_EQ(v4->last_touch_event_type_, 0); | |
| 699 EXPECT_EQ(v4->last_gesture_event_type_, 0); | |
| 700 | |
| 701 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 702 EXPECT_EQ(gm.last_touch_event_, ui::ET_TOUCH_MOVED); | |
| 703 EXPECT_EQ(gm.last_view_, root); | |
| 704 EXPECT_EQ(gm.dispatched_synthetic_event_, true); | |
| 705 | |
| 706 // Test press, drag, release touch sequence. | |
| 707 v1->Reset(); | |
| 708 v2->Reset(); | |
| 709 v3->Reset(); | |
| 710 v4->Reset(); | |
| 711 gm.reset(); | |
| 712 | |
| 713 TouchEvent pressed(ui::ET_TOUCH_PRESSED, | |
| 714 110, | |
| 715 120, | |
| 716 0, /* no flags */ | |
| 717 0, /* first finger touch */ | |
| 718 1.0, 0.0, 1.0, 0.0); | |
| 719 v2->last_touch_event_was_handled_ = true; | |
| 720 pressed.set_native_event(&native_event); | |
| 721 root->OnTouchEvent(pressed); | |
| 722 | |
| 723 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_PRESSED); | |
| 724 EXPECT_EQ(v2->location_.x(), 10); | |
| 725 EXPECT_EQ(v2->location_.y(), 20); | |
| 726 // Make sure v1 did not receive the event | |
| 727 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 728 | |
| 729 // Since v2 handled the touch-event, the gesture manager should not handle it. | |
| 730 EXPECT_EQ(gm.last_touch_event_, 0); | |
| 731 EXPECT_EQ(NULL, gm.last_view_); | |
| 732 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 733 | |
| 734 // Drag event out of bounds. Should still go to v2 | |
| 735 v1->Reset(); | |
| 736 v2->Reset(); | |
| 737 TouchEvent dragged(ui::ET_TOUCH_MOVED, | |
| 738 50, | |
| 739 40, | |
| 740 0, /* no flags */ | |
| 741 0, /* first finger touch */ | |
| 742 1.0, 0.0, 1.0, 0.0); | |
| 743 dragged.set_native_event(&native_event); | |
| 744 root->OnTouchEvent(dragged); | |
| 745 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_MOVED); | |
| 746 EXPECT_EQ(v2->location_.x(), -50); | |
| 747 EXPECT_EQ(v2->location_.y(), -60); | |
| 748 // Make sure v1 did not receive the event | |
| 749 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 750 | |
| 751 EXPECT_EQ(gm.last_touch_event_, 0); | |
| 752 EXPECT_EQ(NULL, gm.last_view_); | |
| 753 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 754 | |
| 755 // Released event out of bounds. Should still go to v2 | |
| 756 v1->Reset(); | |
| 757 v2->Reset(); | |
| 758 TouchEvent released(ui::ET_TOUCH_RELEASED, 0, 0, 0, 0 /* first finger */, | |
| 759 1.0, 0.0, 1.0, 0.0); | |
| 760 released.set_native_event(&native_event); | |
| 761 v2->last_touch_event_was_handled_ = true; | |
| 762 root->OnTouchEvent(released); | |
| 763 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_RELEASED); | |
| 764 EXPECT_EQ(v2->location_.x(), -100); | |
| 765 EXPECT_EQ(v2->location_.y(), -100); | |
| 766 // Make sure v1 did not receive the event | |
| 767 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 768 | |
| 769 EXPECT_EQ(gm.last_touch_event_, 0); | |
| 770 EXPECT_EQ(NULL, gm.last_view_); | |
| 771 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 772 | |
| 773 // Gesture event handling test. | |
| 774 // 1) Test gesture type ui::ET_GESTURE_TAP_DOWN. | |
| 775 v1->Reset(); | |
| 776 v4->Reset(); | |
| 777 gm.reset(); | |
| 778 | |
| 779 TouchEvent second_pressed(ui::ET_TOUCH_PRESSED, | |
| 780 210, | |
| 781 220, | |
| 782 0, /* no flags */ | |
| 783 0, /* first finger touch */ | |
| 784 1.0, 0.0, 1.0, 0.0); | |
| 785 second_pressed.set_native_event(&native_event); | |
| 786 base::Time pressed_time = second_pressed.time_stamp(); | |
| 787 root->OnTouchEvent(second_pressed); | |
| 788 | |
| 789 // Since v1 and V4 didn't handled touch event, the gesture manager should | |
| 790 // handle it. | |
| 791 EXPECT_EQ(gm.last_touch_event_, ui::ET_TOUCH_PRESSED); | |
| 792 EXPECT_EQ(root, gm.last_view_); | |
| 793 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 794 | |
| 795 // Check v4 should receive gesture event but not v1. | |
| 796 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 797 EXPECT_EQ(v4->last_touch_event_type_, 0); | |
| 798 EXPECT_EQ(v4->last_gesture_event_type_, ui::ET_GESTURE_TAP_DOWN); | |
| 799 EXPECT_EQ(v4->location_.x(), 10); | |
| 800 EXPECT_EQ(v4->location_.y(), 20); | |
| 801 | |
| 802 // Check mouse conversions shouldn't take place. | |
| 803 EXPECT_EQ(gm.dispatched_synthetic_event_, false); | |
| 804 | |
| 805 // 2) Test gesture type ui::ET_GESTURE_TAP. | |
| 806 v1->Reset(); | |
| 807 v4->Reset(); | |
| 808 gm.reset(); | |
| 809 | |
| 810 TouchEvent second_released(ui::ET_TOUCH_RELEASED, | |
| 811 210, | |
| 812 220, | |
| 813 0, /* no flags */ | |
| 814 0, /* first finger touch */ | |
| 815 1.0, 0.0, 1.0, 0.0); | |
| 816 second_released.set_native_event(&native_event); | |
| 817 | |
| 818 // Set touch time with-in click window. | |
| 819 second_released.set_time_stamp(base::Time::FromDoubleT( | |
| 820 pressed_time.ToDoubleT() + 0.7)); | |
| 821 root->OnTouchEvent(second_released); | |
| 822 | |
| 823 // Since v1 and V4 didn't handled touch event, the gesture manager should | |
| 824 // handle it. | |
| 825 EXPECT_EQ(gm.last_touch_event_, ui::ET_TOUCH_RELEASED); | |
| 826 EXPECT_EQ(root, gm.last_view_); | |
| 827 EXPECT_EQ(gm.previously_handled_flag_, false); | |
| 828 | |
| 829 // Check v4 should receive gesture event but not v1. | |
| 830 EXPECT_EQ(v1->last_touch_event_type_, 0); | |
| 831 EXPECT_EQ(v4->last_touch_event_type_, 0); | |
| 832 EXPECT_EQ(v4->last_gesture_event_type_, ui::ET_GESTURE_TAP); | |
| 833 EXPECT_EQ(v4->location_.x(), 10); | |
| 834 EXPECT_EQ(v4->location_.y(), 20); | |
| 835 | |
| 836 // Check mouse conversions shouldn't take place. | |
|
rjkroege
2011/11/09 02:43:30
mouse conversions are in-use in actual code. Pleas
Gajen
2011/11/10 15:52:55
Verified touch to mouse conversion and propagation
| |
| 837 EXPECT_EQ(gm.dispatched_synthetic_event_, false); | |
| 838 widget->CloseNow(); | |
| 839 } | |
| 840 #endif | |
| 841 | |
| 842 //////////////////////////////////////////////////////////////////////////////// | |
| 541 // Painting | 843 // Painting |
| 542 //////////////////////////////////////////////////////////////////////////////// | 844 //////////////////////////////////////////////////////////////////////////////// |
| 543 | 845 |
| 544 void TestView::Paint(gfx::Canvas* canvas) { | 846 void TestView::Paint(gfx::Canvas* canvas) { |
| 545 canvas->GetSkCanvas()->getClipBounds(&last_clip_); | 847 canvas->GetSkCanvas()->getClipBounds(&last_clip_); |
| 546 } | 848 } |
| 547 | 849 |
| 548 void TestView::SchedulePaintInRect(const gfx::Rect& rect) { | 850 void TestView::SchedulePaintInRect(const gfx::Rect& rect) { |
| 549 scheduled_paint_rects_.push_back(rect); | 851 scheduled_paint_rects_.push_back(rect); |
| 550 View::SchedulePaintInRect(rect); | 852 View::SchedulePaintInRect(rect); |
| (...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3096 ScrambleTree(content); | 3398 ScrambleTree(content); |
| 3097 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3399 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
| 3098 | 3400 |
| 3099 ScrambleTree(content); | 3401 ScrambleTree(content); |
| 3100 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3402 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
| 3101 } | 3403 } |
| 3102 | 3404 |
| 3103 #endif // VIEWS_COMPOSITOR | 3405 #endif // VIEWS_COMPOSITOR |
| 3104 | 3406 |
| 3105 } // namespace views | 3407 } // namespace views |
| OLD | NEW |