| 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 "ui/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/client/event_client.h" | 10 #include "ui/aura/client/event_client.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 int mouse_event_count() const { return mouse_event_count_; } | 50 int mouse_event_count() const { return mouse_event_count_; } |
| 51 gfx::Point mouse_event_location() const { return mouse_event_location_; } | 51 gfx::Point mouse_event_location() const { return mouse_event_location_; } |
| 52 int mouse_event_flags() const { return mouse_event_flags_; } | 52 int mouse_event_flags() const { return mouse_event_flags_; } |
| 53 | 53 |
| 54 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { | 54 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { |
| 55 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); | 55 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); |
| 56 self->non_client_count_++; | 56 self->non_client_count_++; |
| 57 self->non_client_location_ = location; | 57 self->non_client_location_ = location; |
| 58 return HTTOPLEFT; | 58 return HTTOPLEFT; |
| 59 } | 59 } |
| 60 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 60 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| 61 mouse_event_count_++; | 61 mouse_event_count_++; |
| 62 mouse_event_location_ = event->location(); | 62 mouse_event_location_ = event->location(); |
| 63 mouse_event_flags_ = event->flags(); | 63 mouse_event_flags_ = event->flags(); |
| 64 return ui::ER_HANDLED; | 64 event->SetHandled(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 int non_client_count_; | 68 int non_client_count_; |
| 69 gfx::Point non_client_location_; | 69 gfx::Point non_client_location_; |
| 70 int mouse_event_count_; | 70 int mouse_event_count_; |
| 71 gfx::Point mouse_event_location_; | 71 gfx::Point mouse_event_location_; |
| 72 int mouse_event_flags_; | 72 int mouse_event_flags_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(NonClientDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(NonClientDelegate); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 EventFilterRecorder() {} | 439 EventFilterRecorder() {} |
| 440 | 440 |
| 441 Events& events() { return events_; } | 441 Events& events() { return events_; } |
| 442 | 442 |
| 443 // ui::EventHandler overrides: | 443 // ui::EventHandler overrides: |
| 444 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 444 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
| 445 events_.push_back(event->type()); | 445 events_.push_back(event->type()); |
| 446 } | 446 } |
| 447 | 447 |
| 448 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 448 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| 449 events_.push_back(event->type()); | 449 events_.push_back(event->type()); |
| 450 return ui::ER_UNHANDLED; | |
| 451 } | 450 } |
| 452 | 451 |
| 453 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { | 452 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { |
| 454 events_.push_back(event->type()); | 453 events_.push_back(event->type()); |
| 455 } | 454 } |
| 456 | 455 |
| 457 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 456 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
| 458 events_.push_back(event->type()); | 457 events_.push_back(event->type()); |
| 459 } | 458 } |
| 460 | 459 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 delete_during_pre_handle_ = delete_during_pre_handle; | 636 delete_during_pre_handle_ = delete_during_pre_handle; |
| 638 } | 637 } |
| 639 | 638 |
| 640 private: | 639 private: |
| 641 // Overridden from ui::EventHandler: | 640 // Overridden from ui::EventHandler: |
| 642 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 641 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
| 643 if (delete_during_pre_handle_) | 642 if (delete_during_pre_handle_) |
| 644 delete event->target(); | 643 delete event->target(); |
| 645 } | 644 } |
| 646 | 645 |
| 647 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 646 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| 648 if (delete_during_pre_handle_) | 647 if (delete_during_pre_handle_) |
| 649 delete event->target(); | 648 delete event->target(); |
| 650 return ui::ER_UNHANDLED; | |
| 651 } | 649 } |
| 652 | 650 |
| 653 bool delete_during_pre_handle_; | 651 bool delete_during_pre_handle_; |
| 654 | 652 |
| 655 DISALLOW_COPY_AND_ASSIGN(DeletingEventFilter); | 653 DISALLOW_COPY_AND_ASSIGN(DeletingEventFilter); |
| 656 }; | 654 }; |
| 657 | 655 |
| 658 class DeletingWindowDelegate : public test::TestWindowDelegate { | 656 class DeletingWindowDelegate : public test::TestWindowDelegate { |
| 659 public: | 657 public: |
| 660 DeletingWindowDelegate() | 658 DeletingWindowDelegate() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 671 bool got_event() const { return got_event_; } | 669 bool got_event() const { return got_event_; } |
| 672 | 670 |
| 673 private: | 671 private: |
| 674 // Overridden from WindowDelegate: | 672 // Overridden from WindowDelegate: |
| 675 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 673 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
| 676 if (delete_during_handle_) | 674 if (delete_during_handle_) |
| 677 delete window_; | 675 delete window_; |
| 678 got_event_ = true; | 676 got_event_ = true; |
| 679 } | 677 } |
| 680 | 678 |
| 681 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 679 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| 682 if (delete_during_handle_) | 680 if (delete_during_handle_) |
| 683 delete window_; | 681 delete window_; |
| 684 got_event_ = true; | 682 got_event_ = true; |
| 685 return ui::ER_UNHANDLED; | |
| 686 } | 683 } |
| 687 | 684 |
| 688 Window* window_; | 685 Window* window_; |
| 689 bool delete_during_handle_; | 686 bool delete_during_handle_; |
| 690 bool got_event_; | 687 bool got_event_; |
| 691 | 688 |
| 692 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); | 689 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); |
| 693 }; | 690 }; |
| 694 | 691 |
| 695 TEST_F(RootWindowTest, DeleteWindowDuringDispatch) { | 692 TEST_F(RootWindowTest, DeleteWindowDuringDispatch) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { | 762 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { |
| 766 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); | 763 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); |
| 767 DetachesParentOnTapDelegate delegate; | 764 DetachesParentOnTapDelegate delegate; |
| 768 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); | 765 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); |
| 769 Window* child = CreateWindow(11, parent.get(), &delegate); | 766 Window* child = CreateWindow(11, parent.get(), &delegate); |
| 770 test::EventGenerator generator(root_window(), child); | 767 test::EventGenerator generator(root_window(), child); |
| 771 generator.GestureTapAt(gfx::Point(40, 40)); | 768 generator.GestureTapAt(gfx::Point(40, 40)); |
| 772 } | 769 } |
| 773 | 770 |
| 774 } // namespace aura | 771 } // namespace aura |
| OLD | NEW |