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