| 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 <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 12 matching lines...) Expand all Loading... |
| 23 #include "ui/views/controls/button/button_dropdown.h" | 23 #include "ui/views/controls/button/button_dropdown.h" |
| 24 #include "ui/views/controls/button/checkbox.h" | 24 #include "ui/views/controls/button/checkbox.h" |
| 25 #include "ui/views/controls/native/native_view_host.h" | 25 #include "ui/views/controls/native/native_view_host.h" |
| 26 #include "ui/views/controls/scroll_view.h" | 26 #include "ui/views/controls/scroll_view.h" |
| 27 #include "ui/views/controls/textfield/textfield.h" | 27 #include "ui/views/controls/textfield/textfield.h" |
| 28 #include "ui/views/events/event.h" | 28 #include "ui/views/events/event.h" |
| 29 #include "ui/views/focus/accelerator_handler.h" | 29 #include "ui/views/focus/accelerator_handler.h" |
| 30 #include "ui/views/focus/view_storage.h" | 30 #include "ui/views/focus/view_storage.h" |
| 31 #include "ui/views/test/views_test_base.h" | 31 #include "ui/views/test/views_test_base.h" |
| 32 #include "ui/views/touchui/gesture_manager.h" | 32 #include "ui/views/touchui/gesture_manager.h" |
| 33 #include "ui/views/touchui/gesture_recognizer.h" |
| 33 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
| 34 #include "ui/views/views_delegate.h" | 35 #include "ui/views/views_delegate.h" |
| 35 #include "ui/views/widget/native_widget.h" | 36 #include "ui/views/widget/native_widget.h" |
| 36 #include "ui/views/widget/root_view.h" | 37 #include "ui/views/widget/root_view.h" |
| 37 #include "ui/views/window/dialog_delegate.h" | 38 #include "ui/views/window/dialog_delegate.h" |
| 38 | 39 |
| 39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
| 40 #include "ui/views/test/test_views_delegate.h" | 41 #include "ui/views/test/test_views_delegate.h" |
| 41 #endif | 42 #endif |
| 42 #if defined(USE_AURA) | 43 #if defined(USE_AURA) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 TestView() : View(), in_touch_sequence_(false) {} | 200 TestView() : View(), in_touch_sequence_(false) {} |
| 200 virtual ~TestView() {} | 201 virtual ~TestView() {} |
| 201 | 202 |
| 202 // Reset all test state | 203 // Reset all test state |
| 203 void Reset() { | 204 void Reset() { |
| 204 did_change_bounds_ = false; | 205 did_change_bounds_ = false; |
| 205 last_mouse_event_type_ = 0; | 206 last_mouse_event_type_ = 0; |
| 206 location_.SetPoint(0, 0); | 207 location_.SetPoint(0, 0); |
| 207 last_touch_event_type_ = 0; | 208 last_touch_event_type_ = 0; |
| 208 last_touch_event_was_handled_ = false; | 209 last_touch_event_was_handled_ = false; |
| 210 last_gesture_event_type_ = 0; |
| 211 last_gesture_event_was_handled_ = false; |
| 209 last_clip_.setEmpty(); | 212 last_clip_.setEmpty(); |
| 210 accelerator_count_map_.clear(); | 213 accelerator_count_map_.clear(); |
| 211 } | 214 } |
| 212 | 215 |
| 213 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 216 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 214 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 217 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
| 215 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 218 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
| 216 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 219 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
| 217 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 220 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 221 // Ignores GestureEvent by default. |
| 222 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
| 218 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; | 223 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; |
| 219 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | 224 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; |
| 220 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 225 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 221 | 226 |
| 222 // OnBoundsChanged. | 227 // OnBoundsChanged. |
| 223 bool did_change_bounds_; | 228 bool did_change_bounds_; |
| 224 gfx::Rect new_bounds_; | 229 gfx::Rect new_bounds_; |
| 225 | 230 |
| 226 // MouseEvent. | 231 // MouseEvent. |
| 227 int last_mouse_event_type_; | 232 int last_mouse_event_type_; |
| 228 gfx::Point location_; | 233 gfx::Point location_; |
| 229 | 234 |
| 230 // Painting. | 235 // Painting. |
| 231 std::vector<gfx::Rect> scheduled_paint_rects_; | 236 std::vector<gfx::Rect> scheduled_paint_rects_; |
| 232 | 237 |
| 238 // GestureEvent |
| 239 int last_gesture_event_type_; |
| 240 bool last_gesture_event_was_handled_; |
| 241 |
| 233 // TouchEvent. | 242 // TouchEvent. |
| 234 int last_touch_event_type_; | 243 int last_touch_event_type_; |
| 235 bool last_touch_event_was_handled_; | 244 bool last_touch_event_was_handled_; |
| 236 bool in_touch_sequence_; | 245 bool in_touch_sequence_; |
| 237 | 246 |
| 238 // Painting. | 247 // Painting. |
| 239 SkRect last_clip_; | 248 SkRect last_clip_; |
| 240 | 249 |
| 241 // Accelerators. | 250 // Accelerators. |
| 242 std::map<ui::Accelerator, int> accelerator_count_map_; | 251 std::map<ui::Accelerator, int> accelerator_count_map_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 259 MockGestureManager(); | 268 MockGestureManager(); |
| 260 | 269 |
| 261 bool previously_handled_flag_; | 270 bool previously_handled_flag_; |
| 262 int last_touch_event_; | 271 int last_touch_event_; |
| 263 View *last_view_; | 272 View *last_view_; |
| 264 bool dispatched_synthetic_event_; | 273 bool dispatched_synthetic_event_; |
| 265 | 274 |
| 266 DISALLOW_COPY_AND_ASSIGN(MockGestureManager); | 275 DISALLOW_COPY_AND_ASSIGN(MockGestureManager); |
| 267 }; | 276 }; |
| 268 | 277 |
| 278 // GestureRecognizer for testing. |
| 279 class TestGestureRecognizer : public GestureRecognizer { |
| 280 public: |
| 281 TestGestureRecognizer(); |
| 282 |
| 283 // Reset all test state. |
| 284 void reset() { |
| 285 last_touch_event_ = 0; |
| 286 previously_handled_flag_ = false; |
| 287 } |
| 288 |
| 289 virtual Gestures* ProcessTouchEventForGesture( |
| 290 const TouchEvent& event, |
| 291 ui::TouchStatus status) OVERRIDE; |
| 292 |
| 293 bool previously_handled_flag_; |
| 294 int last_touch_event_; |
| 295 |
| 296 DISALLOW_COPY_AND_ASSIGN(TestGestureRecognizer); |
| 297 }; |
| 298 |
| 269 // A view subclass that ignores all touch events for testing purposes. | 299 // A view subclass that ignores all touch events for testing purposes. |
| 270 class TestViewIgnoreTouch : public TestView { | 300 class TestViewIgnoreTouch : public TestView { |
| 271 public: | 301 public: |
| 272 TestViewIgnoreTouch() : TestView() {} | 302 TestViewIgnoreTouch() : TestView() {} |
| 273 virtual ~TestViewIgnoreTouch() {} | 303 virtual ~TestViewIgnoreTouch() {} |
| 274 | 304 |
| 275 private: | 305 private: |
| 276 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 306 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 277 }; | 307 }; |
| 278 | 308 |
| 309 // A view subclass that consumes all Gesture events for testing purposes. |
| 310 class TestViewConsumeGesture : public TestView { |
| 311 public: |
| 312 TestViewConsumeGesture() : TestView() {} |
| 313 virtual ~TestViewConsumeGesture() {} |
| 314 |
| 315 private: |
| 316 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 317 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
| 318 |
| 319 DISALLOW_COPY_AND_ASSIGN(TestViewConsumeGesture); |
| 320 }; |
| 321 |
| 322 // A view subclass that ignores all Gesture and touch events. |
| 323 class TestViewIgnoreTouchAndGesture: public TestView { |
| 324 public: |
| 325 TestViewIgnoreTouchAndGesture() : TestView() {} |
| 326 virtual ~TestViewIgnoreTouchAndGesture() {} |
| 327 |
| 328 private: |
| 329 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
| 330 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
| 331 |
| 332 DISALLOW_COPY_AND_ASSIGN(TestViewIgnoreTouchAndGesture); |
| 333 }; |
| 334 |
| 279 //////////////////////////////////////////////////////////////////////////////// | 335 //////////////////////////////////////////////////////////////////////////////// |
| 280 // OnBoundsChanged | 336 // OnBoundsChanged |
| 281 //////////////////////////////////////////////////////////////////////////////// | 337 //////////////////////////////////////////////////////////////////////////////// |
| 282 | 338 |
| 283 void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 339 void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 284 did_change_bounds_ = true; | 340 did_change_bounds_ = true; |
| 285 new_bounds_ = bounds(); | 341 new_bounds_ = bounds(); |
| 286 } | 342 } |
| 287 | 343 |
| 288 TEST_F(ViewTest, OnBoundsChanged) { | 344 TEST_F(ViewTest, OnBoundsChanged) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 EXPECT_EQ(v1->last_touch_event_type_, 0); | 589 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 534 | 590 |
| 535 EXPECT_EQ(gm.last_touch_event_, 0); | 591 EXPECT_EQ(gm.last_touch_event_, 0); |
| 536 EXPECT_EQ(NULL, gm.last_view_); | 592 EXPECT_EQ(NULL, gm.last_view_); |
| 537 EXPECT_EQ(gm.previously_handled_flag_, false); | 593 EXPECT_EQ(gm.previously_handled_flag_, false); |
| 538 | 594 |
| 539 widget->CloseNow(); | 595 widget->CloseNow(); |
| 540 } | 596 } |
| 541 | 597 |
| 542 //////////////////////////////////////////////////////////////////////////////// | 598 //////////////////////////////////////////////////////////////////////////////// |
| 599 // GestureEvent |
| 600 //////////////////////////////////////////////////////////////////////////////// |
| 601 |
| 602 GestureRecognizer::Gestures* TestGestureRecognizer::ProcessTouchEventForGesture( |
| 603 const TouchEvent& event, |
| 604 ui::TouchStatus status) { |
| 605 if (status != ui::TOUCH_STATUS_UNKNOWN) { |
| 606 return NULL; |
| 607 } |
| 608 last_touch_event_ = event.type(); |
| 609 previously_handled_flag_ = status != ui::TOUCH_STATUS_UNKNOWN; |
| 610 return GestureRecognizer::ProcessTouchEventForGesture(event, status); |
| 611 } |
| 612 |
| 613 TestGestureRecognizer::TestGestureRecognizer() { |
| 614 } |
| 615 |
| 616 ui::GestureStatus TestView::OnGestureEvent(const GestureEvent& event) { |
| 617 return ui::GESTURE_STATUS_UNKNOWN; |
| 618 } |
| 619 |
| 620 // GestureConsumer view should ignore TouchEvent for testing purposes. |
| 621 ui::TouchStatus TestViewConsumeGesture::OnTouchEvent( |
| 622 const TouchEvent& event) { |
| 623 return ui::TOUCH_STATUS_UNKNOWN; |
| 624 } |
| 625 |
| 626 ui::GestureStatus TestViewConsumeGesture::OnGestureEvent( |
| 627 const GestureEvent& event) { |
| 628 last_gesture_event_type_ = event.type(); |
| 629 location_.SetPoint(event.x(), event.y()); |
| 630 return ui::GESTURE_STATUS_CONSUMED; |
| 631 } |
| 632 |
| 633 // IgnoreTouchAndGesture view should ignore touch and Gesture event for |
| 634 // testing purposes. |
| 635 ui::TouchStatus TestViewIgnoreTouchAndGesture::OnTouchEvent( |
| 636 const TouchEvent& event) { |
| 637 return ui::TOUCH_STATUS_UNKNOWN; |
| 638 } |
| 639 |
| 640 ui::GestureStatus TestViewIgnoreTouchAndGesture::OnGestureEvent( |
| 641 const GestureEvent& event) { |
| 642 return ui::GESTURE_STATUS_UNKNOWN; |
| 643 } |
| 644 |
| 645 #if defined(TOUCH_UI) |
| 646 TEST_F(ViewTest, GestureEvent) { |
| 647 MockGestureManager gm; |
| 648 TestGestureRecognizer gr; |
| 649 |
| 650 // Views hierarchy for non delivery of GestureEvent. |
| 651 TestView* v1 = new TestViewConsumeGesture(); |
| 652 v1->SetBounds(0, 0, 300, 300); |
| 653 |
| 654 TestView* v2 = new TestView(); |
| 655 v2->SetBounds(100, 100, 100, 100); |
| 656 |
| 657 TestView* v3 = new TestViewConsumeGesture(); |
| 658 v3->SetBounds(0, 0, 100, 100); |
| 659 |
| 660 // Views hierarchy for delivery of GestureEvent. |
| 661 TestView* v4 = new TestViewConsumeGesture(); |
| 662 v4->SetBounds(200, 200, 100, 100); |
| 663 |
| 664 scoped_ptr<Widget> widget(new Widget()); |
| 665 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
| 666 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 667 params.bounds = gfx::Rect(50, 50, 650, 650); |
| 668 widget->Init(params); |
| 669 View* root = widget->GetRootView(); |
| 670 |
| 671 root->AddChildView(v1); |
| 672 static_cast<internal::RootView*>(root)->SetGestureManagerForTesting(&gm); |
| 673 static_cast<internal::RootView*>(root)->SetGestureRecognizerForTesting(&gr); |
| 674 v1->AddChildView(v2); |
| 675 v2->AddChildView(v3); |
| 676 v1->AddChildView(v4); |
| 677 |
| 678 // |v3| completely obscures |v2|, but all the touch events on |v3| should |
| 679 // reach |v2| because |v3| doesn't process any touch events, hence no gesture |
| 680 // conversion take place. |
| 681 |
| 682 // Both |v4| and |v1| ignore touch events, hence |v4| should recieve gesture |
| 683 // events. |
| 684 |
| 685 // Make sure if none of the views handle the touch event, the gesture manager |
| 686 // does. |
| 687 v1->Reset(); |
| 688 v2->Reset(); |
| 689 v3->Reset(); |
| 690 v4->Reset(); |
| 691 gr.reset(); |
| 692 gm.Reset(); |
| 693 |
| 694 TouchEvent unhandled(ui::ET_TOUCH_MOVED, |
| 695 400, |
| 696 400, |
| 697 0, /* no flags */ |
| 698 0, /* first finger touch */ |
| 699 1.0, 0.0, 1.0, 0.0); |
| 700 root->OnTouchEvent(unhandled); |
| 701 |
| 702 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 703 EXPECT_EQ(v2->last_touch_event_type_, 0); |
| 704 EXPECT_EQ(v4->last_touch_event_type_, 0); |
| 705 EXPECT_EQ(v4->last_gesture_event_type_, 0); |
| 706 |
| 707 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 708 EXPECT_EQ(gr.last_touch_event_, ui::ET_TOUCH_MOVED); |
| 709 |
| 710 // Test press, drag, release touch sequence. |
| 711 v1->Reset(); |
| 712 v2->Reset(); |
| 713 v3->Reset(); |
| 714 v4->Reset(); |
| 715 gr.reset(); |
| 716 gm.Reset(); |
| 717 |
| 718 TouchEvent pressed(ui::ET_TOUCH_PRESSED, |
| 719 110, |
| 720 120, |
| 721 0, /* no flags */ |
| 722 0, /* first finger touch */ |
| 723 1.0, 0.0, 1.0, 0.0); |
| 724 v2->last_touch_event_was_handled_ = true; |
| 725 root->OnTouchEvent(pressed); |
| 726 |
| 727 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_PRESSED); |
| 728 EXPECT_EQ(v2->location_.x(), 10); |
| 729 EXPECT_EQ(v2->location_.y(), 20); |
| 730 // Make sure v1 did not receive the event |
| 731 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 732 |
| 733 // Since v2 handled the touch-event, the gesture recognizer should not |
| 734 // handle it. |
| 735 EXPECT_EQ(gr.last_touch_event_, 0); |
| 736 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 737 |
| 738 // Drag event out of bounds. Should still go to v2 |
| 739 v1->Reset(); |
| 740 v2->Reset(); |
| 741 TouchEvent dragged(ui::ET_TOUCH_MOVED, |
| 742 50, |
| 743 40, |
| 744 0, /* no flags */ |
| 745 0, /* first finger touch */ |
| 746 1.0, 0.0, 1.0, 0.0); |
| 747 root->OnTouchEvent(dragged); |
| 748 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_MOVED); |
| 749 EXPECT_EQ(v2->location_.x(), -50); |
| 750 EXPECT_EQ(v2->location_.y(), -60); |
| 751 // Make sure v1 did not receive the event |
| 752 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 753 |
| 754 EXPECT_EQ(gr.last_touch_event_, 0); |
| 755 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 756 |
| 757 // Released event out of bounds. Should still go to v2 |
| 758 v1->Reset(); |
| 759 v2->Reset(); |
| 760 TouchEvent released(ui::ET_TOUCH_RELEASED, 0, 0, 0, 0 /* first finger */, |
| 761 1.0, 0.0, 1.0, 0.0); |
| 762 v2->last_touch_event_was_handled_ = true; |
| 763 root->OnTouchEvent(released); |
| 764 EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_RELEASED); |
| 765 EXPECT_EQ(v2->location_.x(), -100); |
| 766 EXPECT_EQ(v2->location_.y(), -100); |
| 767 // Make sure v1 did not receive the event |
| 768 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 769 |
| 770 EXPECT_EQ(gr.last_touch_event_, 0); |
| 771 EXPECT_EQ(gr.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 gr.reset(); |
| 778 gm.Reset(); |
| 779 |
| 780 TouchEvent second_pressed(ui::ET_TOUCH_PRESSED, |
| 781 210, |
| 782 220, |
| 783 0, /* no flags */ |
| 784 0, /* first finger touch */ |
| 785 1.0, 0.0, 1.0, 0.0); |
| 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(gr.last_touch_event_, ui::ET_TOUCH_PRESSED); |
| 792 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 793 |
| 794 // Check v4 should receive gesture event but not v1. |
| 795 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 796 EXPECT_EQ(v4->last_touch_event_type_, 0); |
| 797 EXPECT_EQ(v4->last_gesture_event_type_, ui::ET_GESTURE_TAP_DOWN); |
| 798 EXPECT_EQ(v4->location_.x(), 10); |
| 799 EXPECT_EQ(v4->location_.y(), 20); |
| 800 |
| 801 // 2) Test gesture type ui::ET_GESTURE_TAP. |
| 802 v1->Reset(); |
| 803 v4->Reset(); |
| 804 gr.reset(); |
| 805 gm.Reset(); |
| 806 |
| 807 TouchEvent second_released(ui::ET_TOUCH_RELEASED, |
| 808 210, |
| 809 220, |
| 810 0, /* no flags */ |
| 811 0, /* first finger touch */ |
| 812 1.0, 0.0, 1.0, 0.0); |
| 813 |
| 814 // Set touch time with-in click window. |
| 815 second_released.set_time_stamp(base::Time::FromDoubleT( |
| 816 pressed_time.ToDoubleT() + 0.7)); |
| 817 root->OnTouchEvent(second_released); |
| 818 |
| 819 // Since v1 and V4 didn't handled touch event, the gesture manager should |
| 820 // handle it. |
| 821 EXPECT_EQ(gr.last_touch_event_, ui::ET_TOUCH_RELEASED); |
| 822 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 823 |
| 824 // Check v4 should receive gesture event but not v1. |
| 825 EXPECT_EQ(v1->last_touch_event_type_, 0); |
| 826 EXPECT_EQ(v4->last_touch_event_type_, 0); |
| 827 EXPECT_EQ(v4->last_gesture_event_type_, ui::ET_GESTURE_TAP); |
| 828 EXPECT_EQ(v4->location_.x(), 10); |
| 829 EXPECT_EQ(v4->location_.y(), 20); |
| 830 |
| 831 // 3) Test Gesture to mouse conversion. |
| 832 // Views hierarchy for delivery of mouse event in absence of Touch and |
| 833 // Gesture handlers. |
| 834 TestView* v5 = new TestViewIgnoreTouchAndGesture(); |
| 835 v5->SetBounds(0, 0, 300, 300); |
| 836 |
| 837 TestView* v6 = new TestViewIgnoreTouchAndGesture(); |
| 838 v6->SetBounds(100, 100, 100, 100); |
| 839 |
| 840 root->AddChildView(v5); |
| 841 v5->AddChildView(v6); |
| 842 |
| 843 v5->Reset(); |
| 844 v6->Reset(); |
| 845 gr.reset(); |
| 846 gm.Reset(); |
| 847 |
| 848 TouchEvent third_pressed(ui::ET_TOUCH_PRESSED, |
| 849 110, |
| 850 120, |
| 851 0, /* no flags */ |
| 852 0, /* first finger touch */ |
| 853 1.0, 0.0, 1.0, 0.0); |
| 854 root->OnTouchEvent(third_pressed); |
| 855 |
| 856 // Since v5 and V6 didn't handled touch and gesture event, gesture recognizer |
| 857 // and manager should recieve touch event. |
| 858 EXPECT_EQ(gr.last_touch_event_, ui::ET_TOUCH_PRESSED); |
| 859 EXPECT_EQ(gr.previously_handled_flag_, false); |
| 860 EXPECT_EQ(gm.previously_handled_flag_, false); |
| 861 EXPECT_EQ(gm.last_touch_event_, ui::ET_TOUCH_PRESSED); |
| 862 EXPECT_EQ(gm.last_view_, root); |
| 863 EXPECT_EQ(gm.dispatched_synthetic_event_, true); |
| 864 |
| 865 // Check v6 shouldn't recieve touch and gesture event but mouse event. |
| 866 EXPECT_EQ(v6->last_touch_event_type_, 0); |
| 867 EXPECT_EQ(v6->last_gesture_event_type_, 0); |
| 868 |
| 869 // Check v5 shouldn't recieve touch, gesture and mouse event. |
| 870 EXPECT_EQ(v5->last_touch_event_type_, 0); |
| 871 EXPECT_EQ(v5->last_gesture_event_type_, 0); |
| 872 widget->CloseNow(); |
| 873 } |
| 874 #endif |
| 875 |
| 876 //////////////////////////////////////////////////////////////////////////////// |
| 543 // Painting | 877 // Painting |
| 544 //////////////////////////////////////////////////////////////////////////////// | 878 //////////////////////////////////////////////////////////////////////////////// |
| 545 | 879 |
| 546 void TestView::Paint(gfx::Canvas* canvas) { | 880 void TestView::Paint(gfx::Canvas* canvas) { |
| 547 canvas->GetSkCanvas()->getClipBounds(&last_clip_); | 881 canvas->GetSkCanvas()->getClipBounds(&last_clip_); |
| 548 } | 882 } |
| 549 | 883 |
| 550 void TestView::SchedulePaintInRect(const gfx::Rect& rect) { | 884 void TestView::SchedulePaintInRect(const gfx::Rect& rect) { |
| 551 scheduled_paint_rects_.push_back(rect); | 885 scheduled_paint_rects_.push_back(rect); |
| 552 View::SchedulePaintInRect(rect); | 886 View::SchedulePaintInRect(rect); |
| (...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 // Move c1 to the front. The layers should have moved too. | 3431 // Move c1 to the front. The layers should have moved too. |
| 3098 content->ReorderChildView(c1, -1); | 3432 content->ReorderChildView(c1, -1); |
| 3099 EXPECT_EQ(c1->layer(), parent_layer->children()[1]); | 3433 EXPECT_EQ(c1->layer(), parent_layer->children()[1]); |
| 3100 EXPECT_EQ(c2->layer(), parent_layer->children()[0]); | 3434 EXPECT_EQ(c2->layer(), parent_layer->children()[0]); |
| 3101 } | 3435 } |
| 3102 #endif | 3436 #endif |
| 3103 | 3437 |
| 3104 #endif // VIEWS_COMPOSITOR | 3438 #endif // VIEWS_COMPOSITOR |
| 3105 | 3439 |
| 3106 } // namespace views | 3440 } // namespace views |
| OLD | NEW |