| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 int last_flags() const { | 80 int last_flags() const { |
| 81 return last_flags_; | 81 return last_flags_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void set_handle_mode(HandleMode handle_mode) { | 84 void set_handle_mode(HandleMode handle_mode) { |
| 85 handle_mode_ = handle_mode; | 85 handle_mode_ = handle_mode; |
| 86 } | 86 } |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 // Overridden from View: | 89 // Overridden from View: |
| 90 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE { | 90 virtual void OnMouseMoved(const ui::MouseEvent& event) override { |
| 91 // MouseMove events are not re-dispatched from the RootView. | 91 // MouseMove events are not re-dispatched from the RootView. |
| 92 ++event_count_[ui::ET_MOUSE_MOVED]; | 92 ++event_count_[ui::ET_MOUSE_MOVED]; |
| 93 last_flags_ = 0; | 93 last_flags_ = 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Overridden from ui::EventHandler: | 96 // Overridden from ui::EventHandler: |
| 97 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 97 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
| 98 RecordEvent(event); | 98 RecordEvent(event); |
| 99 } | 99 } |
| 100 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 100 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 101 RecordEvent(event); | 101 RecordEvent(event); |
| 102 } | 102 } |
| 103 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { | 103 virtual void OnScrollEvent(ui::ScrollEvent* event) override { |
| 104 RecordEvent(event); | 104 RecordEvent(event); |
| 105 } | 105 } |
| 106 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 106 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 107 RecordEvent(event); | 107 RecordEvent(event); |
| 108 } | 108 } |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 void RecordEvent(ui::Event* event) { | 111 void RecordEvent(ui::Event* event) { |
| 112 ++event_count_[event->type()]; | 112 ++event_count_[event->type()]; |
| 113 last_flags_ = event->flags(); | 113 last_flags_ = event->flags(); |
| 114 if (handle_mode_ == CONSUME_EVENTS) | 114 if (handle_mode_ == CONSUME_EVENTS) |
| 115 event->SetHandled(); | 115 event->SetHandled(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 std::map<ui::EventType, int> event_count_; | 118 std::map<ui::EventType, int> event_count_; |
| 119 int last_flags_; | 119 int last_flags_; |
| 120 HandleMode handle_mode_; | 120 HandleMode handle_mode_; |
| 121 | 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(EventCountView); | 122 DISALLOW_COPY_AND_ASSIGN(EventCountView); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 // A view that keeps track of the events it receives, and consumes all scroll | 125 // A view that keeps track of the events it receives, and consumes all scroll |
| 126 // gesture events and ui::ET_SCROLL events. | 126 // gesture events and ui::ET_SCROLL events. |
| 127 class ScrollableEventCountView : public EventCountView { | 127 class ScrollableEventCountView : public EventCountView { |
| 128 public: | 128 public: |
| 129 ScrollableEventCountView() {} | 129 ScrollableEventCountView() {} |
| 130 virtual ~ScrollableEventCountView() {} | 130 virtual ~ScrollableEventCountView() {} |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 // Overridden from ui::EventHandler: | 133 // Overridden from ui::EventHandler: |
| 134 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 134 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 135 EventCountView::OnGestureEvent(event); | 135 EventCountView::OnGestureEvent(event); |
| 136 switch (event->type()) { | 136 switch (event->type()) { |
| 137 case ui::ET_GESTURE_SCROLL_BEGIN: | 137 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 138 case ui::ET_GESTURE_SCROLL_UPDATE: | 138 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 139 case ui::ET_GESTURE_SCROLL_END: | 139 case ui::ET_GESTURE_SCROLL_END: |
| 140 case ui::ET_SCROLL_FLING_START: | 140 case ui::ET_SCROLL_FLING_START: |
| 141 event->SetHandled(); | 141 event->SetHandled(); |
| 142 break; | 142 break; |
| 143 default: | 143 default: |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { | 148 virtual void OnScrollEvent(ui::ScrollEvent* event) override { |
| 149 EventCountView::OnScrollEvent(event); | 149 EventCountView::OnScrollEvent(event); |
| 150 if (event->type() == ui::ET_SCROLL) | 150 if (event->type() == ui::ET_SCROLL) |
| 151 event->SetHandled(); | 151 event->SetHandled(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ScrollableEventCountView); | 154 DISALLOW_COPY_AND_ASSIGN(ScrollableEventCountView); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 // A view that implements GetMinimumSize. | 157 // A view that implements GetMinimumSize. |
| 158 class MinimumSizeFrameView : public NativeFrameView { | 158 class MinimumSizeFrameView : public NativeFrameView { |
| 159 public: | 159 public: |
| 160 explicit MinimumSizeFrameView(Widget* frame): NativeFrameView(frame) {} | 160 explicit MinimumSizeFrameView(Widget* frame): NativeFrameView(frame) {} |
| 161 virtual ~MinimumSizeFrameView() {} | 161 virtual ~MinimumSizeFrameView() {} |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 // Overridden from View: | 164 // Overridden from View: |
| 165 virtual gfx::Size GetMinimumSize() const OVERRIDE { | 165 virtual gfx::Size GetMinimumSize() const override { |
| 166 return gfx::Size(300, 400); | 166 return gfx::Size(300, 400); |
| 167 } | 167 } |
| 168 | 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(MinimumSizeFrameView); | 169 DISALLOW_COPY_AND_ASSIGN(MinimumSizeFrameView); |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 // An event handler that simply keeps a count of the different types of events | 172 // An event handler that simply keeps a count of the different types of events |
| 173 // it receives. | 173 // it receives. |
| 174 class EventCountHandler : public ui::EventHandler { | 174 class EventCountHandler : public ui::EventHandler { |
| 175 public: | 175 public: |
| 176 EventCountHandler() {} | 176 EventCountHandler() {} |
| 177 virtual ~EventCountHandler() {} | 177 virtual ~EventCountHandler() {} |
| 178 | 178 |
| 179 int GetEventCount(ui::EventType type) { | 179 int GetEventCount(ui::EventType type) { |
| 180 return event_count_[type]; | 180 return event_count_[type]; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void ResetCounts() { | 183 void ResetCounts() { |
| 184 event_count_.clear(); | 184 event_count_.clear(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 protected: | 187 protected: |
| 188 // Overridden from ui::EventHandler: | 188 // Overridden from ui::EventHandler: |
| 189 virtual void OnEvent(ui::Event* event) OVERRIDE { | 189 virtual void OnEvent(ui::Event* event) override { |
| 190 RecordEvent(*event); | 190 RecordEvent(*event); |
| 191 ui::EventHandler::OnEvent(event); | 191 ui::EventHandler::OnEvent(event); |
| 192 } | 192 } |
| 193 | 193 |
| 194 private: | 194 private: |
| 195 void RecordEvent(const ui::Event& event) { | 195 void RecordEvent(const ui::Event& event) { |
| 196 ++event_count_[event.type()]; | 196 ++event_count_[event.type()]; |
| 197 } | 197 } |
| 198 | 198 |
| 199 std::map<ui::EventType, int> event_count_; | 199 std::map<ui::EventType, int> event_count_; |
| 200 | 200 |
| 201 DISALLOW_COPY_AND_ASSIGN(EventCountHandler); | 201 DISALLOW_COPY_AND_ASSIGN(EventCountHandler); |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 // Class that closes the widget (which ends up deleting it immediately) when the | 204 // Class that closes the widget (which ends up deleting it immediately) when the |
| 205 // appropriate event is received. | 205 // appropriate event is received. |
| 206 class CloseWidgetView : public View { | 206 class CloseWidgetView : public View { |
| 207 public: | 207 public: |
| 208 explicit CloseWidgetView(ui::EventType event_type) | 208 explicit CloseWidgetView(ui::EventType event_type) |
| 209 : event_type_(event_type) { | 209 : event_type_(event_type) { |
| 210 } | 210 } |
| 211 | 211 |
| 212 // ui::EventHandler override: | 212 // ui::EventHandler override: |
| 213 virtual void OnEvent(ui::Event* event) OVERRIDE { | 213 virtual void OnEvent(ui::Event* event) override { |
| 214 if (event->type() == event_type_) { | 214 if (event->type() == event_type_) { |
| 215 // Go through NativeWidgetPrivate to simulate what happens if the OS | 215 // Go through NativeWidgetPrivate to simulate what happens if the OS |
| 216 // deletes the NativeWindow out from under us. | 216 // deletes the NativeWindow out from under us. |
| 217 GetWidget()->native_widget_private()->CloseNow(); | 217 GetWidget()->native_widget_private()->CloseNow(); |
| 218 } else { | 218 } else { |
| 219 View::OnEvent(event); | 219 View::OnEvent(event); |
| 220 if (!event->IsTouchEvent()) | 220 if (!event->IsTouchEvent()) |
| 221 event->SetHandled(); | 221 event->SetHandled(); |
| 222 } | 222 } |
| 223 } | 223 } |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 widget_closed_(NULL), | 711 widget_closed_(NULL), |
| 712 widget_activated_(NULL), | 712 widget_activated_(NULL), |
| 713 widget_shown_(NULL), | 713 widget_shown_(NULL), |
| 714 widget_hidden_(NULL), | 714 widget_hidden_(NULL), |
| 715 widget_bounds_changed_(NULL) { | 715 widget_bounds_changed_(NULL) { |
| 716 } | 716 } |
| 717 | 717 |
| 718 virtual ~WidgetObserverTest() {} | 718 virtual ~WidgetObserverTest() {} |
| 719 | 719 |
| 720 // Overridden from WidgetObserver: | 720 // Overridden from WidgetObserver: |
| 721 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE { | 721 virtual void OnWidgetDestroying(Widget* widget) override { |
| 722 if (active_ == widget) | 722 if (active_ == widget) |
| 723 active_ = NULL; | 723 active_ = NULL; |
| 724 widget_closed_ = widget; | 724 widget_closed_ = widget; |
| 725 } | 725 } |
| 726 | 726 |
| 727 virtual void OnWidgetActivationChanged(Widget* widget, | 727 virtual void OnWidgetActivationChanged(Widget* widget, |
| 728 bool active) OVERRIDE { | 728 bool active) override { |
| 729 if (active) { | 729 if (active) { |
| 730 if (widget_activated_) | 730 if (widget_activated_) |
| 731 widget_activated_->Deactivate(); | 731 widget_activated_->Deactivate(); |
| 732 widget_activated_ = widget; | 732 widget_activated_ = widget; |
| 733 active_ = widget; | 733 active_ = widget; |
| 734 } else { | 734 } else { |
| 735 if (widget_activated_ == widget) | 735 if (widget_activated_ == widget) |
| 736 widget_activated_ = NULL; | 736 widget_activated_ = NULL; |
| 737 widget_deactivated_ = widget; | 737 widget_deactivated_ = widget; |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 virtual void OnWidgetVisibilityChanged(Widget* widget, | 741 virtual void OnWidgetVisibilityChanged(Widget* widget, |
| 742 bool visible) OVERRIDE { | 742 bool visible) override { |
| 743 if (visible) | 743 if (visible) |
| 744 widget_shown_ = widget; | 744 widget_shown_ = widget; |
| 745 else | 745 else |
| 746 widget_hidden_ = widget; | 746 widget_hidden_ = widget; |
| 747 } | 747 } |
| 748 | 748 |
| 749 virtual void OnWidgetBoundsChanged(Widget* widget, | 749 virtual void OnWidgetBoundsChanged(Widget* widget, |
| 750 const gfx::Rect& new_bounds) OVERRIDE { | 750 const gfx::Rect& new_bounds) override { |
| 751 widget_bounds_changed_ = widget; | 751 widget_bounds_changed_ = widget; |
| 752 } | 752 } |
| 753 | 753 |
| 754 void reset() { | 754 void reset() { |
| 755 active_ = NULL; | 755 active_ = NULL; |
| 756 widget_closed_ = NULL; | 756 widget_closed_ = NULL; |
| 757 widget_activated_ = NULL; | 757 widget_activated_ = NULL; |
| 758 widget_deactivated_ = NULL; | 758 widget_deactivated_ = NULL; |
| 759 widget_shown_ = NULL; | 759 widget_shown_ = NULL; |
| 760 widget_hidden_ = NULL; | 760 widget_hidden_ = NULL; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 EXPECT_TRUE(contents_view->HasFocus()); | 1055 EXPECT_TRUE(contents_view->HasFocus()); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 class TestBubbleDelegateView : public BubbleDelegateView { | 1058 class TestBubbleDelegateView : public BubbleDelegateView { |
| 1059 public: | 1059 public: |
| 1060 TestBubbleDelegateView(View* anchor) | 1060 TestBubbleDelegateView(View* anchor) |
| 1061 : BubbleDelegateView(anchor, BubbleBorder::NONE), | 1061 : BubbleDelegateView(anchor, BubbleBorder::NONE), |
| 1062 reset_controls_called_(false) {} | 1062 reset_controls_called_(false) {} |
| 1063 virtual ~TestBubbleDelegateView() {} | 1063 virtual ~TestBubbleDelegateView() {} |
| 1064 | 1064 |
| 1065 virtual bool ShouldShowCloseButton() const OVERRIDE { | 1065 virtual bool ShouldShowCloseButton() const override { |
| 1066 reset_controls_called_ = true; | 1066 reset_controls_called_ = true; |
| 1067 return true; | 1067 return true; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 mutable bool reset_controls_called_; | 1070 mutable bool reset_controls_called_; |
| 1071 }; | 1071 }; |
| 1072 | 1072 |
| 1073 TEST_F(WidgetTest, BubbleControlsResetOnInit) { | 1073 TEST_F(WidgetTest, BubbleControlsResetOnInit) { |
| 1074 Widget* anchor = CreateTopLevelPlatformWidget(); | 1074 Widget* anchor = CreateTopLevelPlatformWidget(); |
| 1075 anchor->Show(); | 1075 anchor->Show(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 class DesktopAuraTestValidPaintWidget : public views::Widget { | 1113 class DesktopAuraTestValidPaintWidget : public views::Widget { |
| 1114 public: | 1114 public: |
| 1115 DesktopAuraTestValidPaintWidget() | 1115 DesktopAuraTestValidPaintWidget() |
| 1116 : expect_paint_(true), | 1116 : expect_paint_(true), |
| 1117 received_paint_while_hidden_(false) { | 1117 received_paint_while_hidden_(false) { |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 virtual ~DesktopAuraTestValidPaintWidget() { | 1120 virtual ~DesktopAuraTestValidPaintWidget() { |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 virtual void Show() OVERRIDE { | 1123 virtual void Show() override { |
| 1124 expect_paint_ = true; | 1124 expect_paint_ = true; |
| 1125 views::Widget::Show(); | 1125 views::Widget::Show(); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 virtual void Close() OVERRIDE { | 1128 virtual void Close() override { |
| 1129 expect_paint_ = false; | 1129 expect_paint_ = false; |
| 1130 views::Widget::Close(); | 1130 views::Widget::Close(); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 void Hide() { | 1133 void Hide() { |
| 1134 expect_paint_ = false; | 1134 expect_paint_ = false; |
| 1135 views::Widget::Hide(); | 1135 views::Widget::Hide(); |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE { | 1138 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) override { |
| 1139 EXPECT_TRUE(expect_paint_); | 1139 EXPECT_TRUE(expect_paint_); |
| 1140 if (!expect_paint_) | 1140 if (!expect_paint_) |
| 1141 received_paint_while_hidden_ = true; | 1141 received_paint_while_hidden_ = true; |
| 1142 views::Widget::OnNativeWidgetPaint(canvas); | 1142 views::Widget::OnNativeWidgetPaint(canvas); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 bool received_paint_while_hidden() const { | 1145 bool received_paint_while_hidden() const { |
| 1146 return received_paint_while_hidden_; | 1146 return received_paint_while_hidden_; |
| 1147 } | 1147 } |
| 1148 | 1148 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 class MousePressEventConsumer : public ui::EventHandler { | 1544 class MousePressEventConsumer : public ui::EventHandler { |
| 1545 public: | 1545 public: |
| 1546 explicit MousePressEventConsumer() { | 1546 explicit MousePressEventConsumer() { |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 virtual ~MousePressEventConsumer() { | 1549 virtual ~MousePressEventConsumer() { |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 private: | 1552 private: |
| 1553 // ui::EventHandler: | 1553 // ui::EventHandler: |
| 1554 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1554 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 1555 if (event->type() == ui::ET_MOUSE_PRESSED) | 1555 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1556 event->SetHandled(); | 1556 event->SetHandled(); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 DISALLOW_COPY_AND_ASSIGN(MousePressEventConsumer); | 1559 DISALLOW_COPY_AND_ASSIGN(MousePressEventConsumer); |
| 1560 }; | 1560 }; |
| 1561 | 1561 |
| 1562 } // namespace | 1562 } // namespace |
| 1563 | 1563 |
| 1564 // Test that mouse presses and mouse releases are dispatched normally when a | 1564 // Test that mouse presses and mouse releases are dispatched normally when a |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1589 // been invoked. | 1589 // been invoked. |
| 1590 class ClosingDelegate : public WidgetDelegate { | 1590 class ClosingDelegate : public WidgetDelegate { |
| 1591 public: | 1591 public: |
| 1592 ClosingDelegate() : count_(0), widget_(NULL) {} | 1592 ClosingDelegate() : count_(0), widget_(NULL) {} |
| 1593 | 1593 |
| 1594 int count() const { return count_; } | 1594 int count() const { return count_; } |
| 1595 | 1595 |
| 1596 void set_widget(views::Widget* widget) { widget_ = widget; } | 1596 void set_widget(views::Widget* widget) { widget_ = widget; } |
| 1597 | 1597 |
| 1598 // WidgetDelegate overrides: | 1598 // WidgetDelegate overrides: |
| 1599 virtual Widget* GetWidget() OVERRIDE { return widget_; } | 1599 virtual Widget* GetWidget() override { return widget_; } |
| 1600 virtual const Widget* GetWidget() const OVERRIDE { return widget_; } | 1600 virtual const Widget* GetWidget() const override { return widget_; } |
| 1601 virtual void WindowClosing() OVERRIDE { | 1601 virtual void WindowClosing() override { |
| 1602 count_++; | 1602 count_++; |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 private: | 1605 private: |
| 1606 int count_; | 1606 int count_; |
| 1607 views::Widget* widget_; | 1607 views::Widget* widget_; |
| 1608 | 1608 |
| 1609 DISALLOW_COPY_AND_ASSIGN(ClosingDelegate); | 1609 DISALLOW_COPY_AND_ASSIGN(ClosingDelegate); |
| 1610 }; | 1610 }; |
| 1611 | 1611 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 } | 1725 } |
| 1726 | 1726 |
| 1727 // See description of RunGetNativeThemeFromDestructor() for details. | 1727 // See description of RunGetNativeThemeFromDestructor() for details. |
| 1728 class GetNativeThemeFromDestructorView : public WidgetDelegateView { | 1728 class GetNativeThemeFromDestructorView : public WidgetDelegateView { |
| 1729 public: | 1729 public: |
| 1730 GetNativeThemeFromDestructorView() {} | 1730 GetNativeThemeFromDestructorView() {} |
| 1731 virtual ~GetNativeThemeFromDestructorView() { | 1731 virtual ~GetNativeThemeFromDestructorView() { |
| 1732 VerifyNativeTheme(); | 1732 VerifyNativeTheme(); |
| 1733 } | 1733 } |
| 1734 | 1734 |
| 1735 virtual View* GetContentsView() OVERRIDE { | 1735 virtual View* GetContentsView() override { |
| 1736 return this; | 1736 return this; |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 private: | 1739 private: |
| 1740 void VerifyNativeTheme() { | 1740 void VerifyNativeTheme() { |
| 1741 ASSERT_TRUE(GetNativeTheme() != NULL); | 1741 ASSERT_TRUE(GetNativeTheme() != NULL); |
| 1742 } | 1742 } |
| 1743 | 1743 |
| 1744 DISALLOW_COPY_AND_ASSIGN(GetNativeThemeFromDestructorView); | 1744 DISALLOW_COPY_AND_ASSIGN(GetNativeThemeFromDestructorView); |
| 1745 }; | 1745 }; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1800 | 1800 |
| 1801 // An observer that registers that an animation has ended. | 1801 // An observer that registers that an animation has ended. |
| 1802 class AnimationEndObserver : public ui::ImplicitAnimationObserver { | 1802 class AnimationEndObserver : public ui::ImplicitAnimationObserver { |
| 1803 public: | 1803 public: |
| 1804 AnimationEndObserver() : animation_completed_(false) {} | 1804 AnimationEndObserver() : animation_completed_(false) {} |
| 1805 virtual ~AnimationEndObserver() {} | 1805 virtual ~AnimationEndObserver() {} |
| 1806 | 1806 |
| 1807 bool animation_completed() const { return animation_completed_; } | 1807 bool animation_completed() const { return animation_completed_; } |
| 1808 | 1808 |
| 1809 // ui::ImplicitAnimationObserver: | 1809 // ui::ImplicitAnimationObserver: |
| 1810 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 1810 virtual void OnImplicitAnimationsCompleted() override { |
| 1811 animation_completed_ = true; | 1811 animation_completed_ = true; |
| 1812 } | 1812 } |
| 1813 | 1813 |
| 1814 private: | 1814 private: |
| 1815 bool animation_completed_; | 1815 bool animation_completed_; |
| 1816 | 1816 |
| 1817 DISALLOW_COPY_AND_ASSIGN(AnimationEndObserver); | 1817 DISALLOW_COPY_AND_ASSIGN(AnimationEndObserver); |
| 1818 }; | 1818 }; |
| 1819 | 1819 |
| 1820 // An observer that registers the bounds of a widget on destruction. | 1820 // An observer that registers the bounds of a widget on destruction. |
| 1821 class WidgetBoundsObserver : public WidgetObserver { | 1821 class WidgetBoundsObserver : public WidgetObserver { |
| 1822 public: | 1822 public: |
| 1823 WidgetBoundsObserver() {} | 1823 WidgetBoundsObserver() {} |
| 1824 virtual ~WidgetBoundsObserver() {} | 1824 virtual ~WidgetBoundsObserver() {} |
| 1825 | 1825 |
| 1826 gfx::Rect bounds() { return bounds_; } | 1826 gfx::Rect bounds() { return bounds_; } |
| 1827 | 1827 |
| 1828 // WidgetObserver: | 1828 // WidgetObserver: |
| 1829 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE { | 1829 virtual void OnWidgetDestroying(Widget* widget) override { |
| 1830 bounds_ = widget->GetWindowBoundsInScreen(); | 1830 bounds_ = widget->GetWindowBoundsInScreen(); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 private: | 1833 private: |
| 1834 gfx::Rect bounds_; | 1834 gfx::Rect bounds_; |
| 1835 | 1835 |
| 1836 DISALLOW_COPY_AND_ASSIGN(WidgetBoundsObserver); | 1836 DISALLOW_COPY_AND_ASSIGN(WidgetBoundsObserver); |
| 1837 }; | 1837 }; |
| 1838 | 1838 |
| 1839 // Verifies Close() results in destroying. | 1839 // Verifies Close() results in destroying. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 EXPECT_TRUE(animation_observer.animation_completed()); | 1890 EXPECT_TRUE(animation_observer.animation_completed()); |
| 1891 EXPECT_EQ(widget_observer.bounds(), bounds); | 1891 EXPECT_EQ(widget_observer.bounds(), bounds); |
| 1892 } | 1892 } |
| 1893 | 1893 |
| 1894 // A view that consumes mouse-pressed event and gesture-tap-down events. | 1894 // A view that consumes mouse-pressed event and gesture-tap-down events. |
| 1895 class RootViewTestView : public View { | 1895 class RootViewTestView : public View { |
| 1896 public: | 1896 public: |
| 1897 RootViewTestView(): View() {} | 1897 RootViewTestView(): View() {} |
| 1898 | 1898 |
| 1899 private: | 1899 private: |
| 1900 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 1900 virtual bool OnMousePressed(const ui::MouseEvent& event) override { |
| 1901 return true; | 1901 return true; |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 1904 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 1905 if (event->type() == ui::ET_GESTURE_TAP_DOWN) | 1905 if (event->type() == ui::ET_GESTURE_TAP_DOWN) |
| 1906 event->SetHandled(); | 1906 event->SetHandled(); |
| 1907 } | 1907 } |
| 1908 }; | 1908 }; |
| 1909 | 1909 |
| 1910 // Checks if RootView::*_handler_ fields are unset when widget is hidden. | 1910 // Checks if RootView::*_handler_ fields are unset when widget is hidden. |
| 1911 // Fails on chromium.webkit Windows bot, see crbug.com/264872. | 1911 // Fails on chromium.webkit Windows bot, see crbug.com/264872. |
| 1912 #if defined(OS_WIN) | 1912 #if defined(OS_WIN) |
| 1913 #define MAYBE_DisableTestRootViewHandlersWhenHidden\ | 1913 #define MAYBE_DisableTestRootViewHandlersWhenHidden\ |
| 1914 DISABLED_TestRootViewHandlersWhenHidden | 1914 DISABLED_TestRootViewHandlersWhenHidden |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2440 class GestureLocationView : public EventCountView { | 2440 class GestureLocationView : public EventCountView { |
| 2441 public: | 2441 public: |
| 2442 GestureLocationView() {} | 2442 GestureLocationView() {} |
| 2443 virtual ~GestureLocationView() {} | 2443 virtual ~GestureLocationView() {} |
| 2444 | 2444 |
| 2445 void set_expected_location(gfx::Point expected_location) { | 2445 void set_expected_location(gfx::Point expected_location) { |
| 2446 expected_location_ = expected_location; | 2446 expected_location_ = expected_location; |
| 2447 } | 2447 } |
| 2448 | 2448 |
| 2449 // EventCountView: | 2449 // EventCountView: |
| 2450 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 2450 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 2451 EventCountView::OnGestureEvent(event); | 2451 EventCountView::OnGestureEvent(event); |
| 2452 | 2452 |
| 2453 // Verify that the location of |event| is in the local coordinate | 2453 // Verify that the location of |event| is in the local coordinate |
| 2454 // space of |this|. | 2454 // space of |this|. |
| 2455 EXPECT_EQ(expected_location_, event->location()); | 2455 EXPECT_EQ(expected_location_, event->location()); |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 private: | 2458 private: |
| 2459 // The expected location of a gesture event dispatched to |this|. | 2459 // The expected location of a gesture event dispatched to |this|. |
| 2460 gfx::Point expected_location_; | 2460 gfx::Point expected_location_; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2767 } | 2767 } |
| 2768 | 2768 |
| 2769 #if !defined(OS_CHROMEOS) | 2769 #if !defined(OS_CHROMEOS) |
| 2770 // Provides functionality to create a window modal dialog. | 2770 // Provides functionality to create a window modal dialog. |
| 2771 class ModalDialogDelegate : public DialogDelegateView { | 2771 class ModalDialogDelegate : public DialogDelegateView { |
| 2772 public: | 2772 public: |
| 2773 ModalDialogDelegate() {} | 2773 ModalDialogDelegate() {} |
| 2774 virtual ~ModalDialogDelegate() {} | 2774 virtual ~ModalDialogDelegate() {} |
| 2775 | 2775 |
| 2776 // WidgetDelegate overrides. | 2776 // WidgetDelegate overrides. |
| 2777 virtual ui::ModalType GetModalType() const OVERRIDE { | 2777 virtual ui::ModalType GetModalType() const override { |
| 2778 return ui::MODAL_TYPE_WINDOW; | 2778 return ui::MODAL_TYPE_WINDOW; |
| 2779 } | 2779 } |
| 2780 | 2780 |
| 2781 private: | 2781 private: |
| 2782 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); | 2782 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); |
| 2783 }; | 2783 }; |
| 2784 | 2784 |
| 2785 // This test verifies that whether mouse events when a modal dialog is | 2785 // This test verifies that whether mouse events when a modal dialog is |
| 2786 // displayed are eaten or recieved by the dialog. | 2786 // displayed are eaten or recieved by the dialog. |
| 2787 TEST_F(WidgetTest, WindowMouseModalityTest) { | 2787 TEST_F(WidgetTest, WindowMouseModalityTest) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2896 // which can be set by an accessor. | 2896 // which can be set by an accessor. |
| 2897 class ModalWindowTestWidgetDelegate : public WidgetDelegate { | 2897 class ModalWindowTestWidgetDelegate : public WidgetDelegate { |
| 2898 public: | 2898 public: |
| 2899 ModalWindowTestWidgetDelegate() | 2899 ModalWindowTestWidgetDelegate() |
| 2900 : widget_(NULL), | 2900 : widget_(NULL), |
| 2901 can_activate_(true) {} | 2901 can_activate_(true) {} |
| 2902 | 2902 |
| 2903 virtual ~ModalWindowTestWidgetDelegate() {} | 2903 virtual ~ModalWindowTestWidgetDelegate() {} |
| 2904 | 2904 |
| 2905 // Overridden from WidgetDelegate: | 2905 // Overridden from WidgetDelegate: |
| 2906 virtual void DeleteDelegate() OVERRIDE { | 2906 virtual void DeleteDelegate() override { |
| 2907 delete this; | 2907 delete this; |
| 2908 } | 2908 } |
| 2909 virtual Widget* GetWidget() OVERRIDE { | 2909 virtual Widget* GetWidget() override { |
| 2910 return widget_; | 2910 return widget_; |
| 2911 } | 2911 } |
| 2912 virtual const Widget* GetWidget() const OVERRIDE { | 2912 virtual const Widget* GetWidget() const override { |
| 2913 return widget_; | 2913 return widget_; |
| 2914 } | 2914 } |
| 2915 virtual bool CanActivate() const OVERRIDE { | 2915 virtual bool CanActivate() const override { |
| 2916 return can_activate_; | 2916 return can_activate_; |
| 2917 } | 2917 } |
| 2918 virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE { | 2918 virtual bool ShouldAdvanceFocusToTopLevelWidget() const override { |
| 2919 return true; | 2919 return true; |
| 2920 } | 2920 } |
| 2921 | 2921 |
| 2922 void set_can_activate(bool can_activate) { | 2922 void set_can_activate(bool can_activate) { |
| 2923 can_activate_ = can_activate; | 2923 can_activate_ = can_activate; |
| 2924 } | 2924 } |
| 2925 | 2925 |
| 2926 void set_widget(Widget* widget) { | 2926 void set_widget(Widget* widget) { |
| 2927 widget_ = widget; | 2927 widget_ = widget; |
| 2928 } | 2928 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 | 3079 |
| 3080 namespace { | 3080 namespace { |
| 3081 | 3081 |
| 3082 class FullscreenAwareFrame : public views::NonClientFrameView { | 3082 class FullscreenAwareFrame : public views::NonClientFrameView { |
| 3083 public: | 3083 public: |
| 3084 explicit FullscreenAwareFrame(views::Widget* widget) | 3084 explicit FullscreenAwareFrame(views::Widget* widget) |
| 3085 : widget_(widget), fullscreen_layout_called_(false) {} | 3085 : widget_(widget), fullscreen_layout_called_(false) {} |
| 3086 virtual ~FullscreenAwareFrame() {} | 3086 virtual ~FullscreenAwareFrame() {} |
| 3087 | 3087 |
| 3088 // views::NonClientFrameView overrides: | 3088 // views::NonClientFrameView overrides: |
| 3089 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE { | 3089 virtual gfx::Rect GetBoundsForClientView() const override { |
| 3090 return gfx::Rect(); | 3090 return gfx::Rect(); |
| 3091 } | 3091 } |
| 3092 virtual gfx::Rect GetWindowBoundsForClientBounds( | 3092 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 3093 const gfx::Rect& client_bounds) const OVERRIDE { | 3093 const gfx::Rect& client_bounds) const override { |
| 3094 return gfx::Rect(); | 3094 return gfx::Rect(); |
| 3095 } | 3095 } |
| 3096 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE { | 3096 virtual int NonClientHitTest(const gfx::Point& point) override { |
| 3097 return HTNOWHERE; | 3097 return HTNOWHERE; |
| 3098 } | 3098 } |
| 3099 virtual void GetWindowMask(const gfx::Size& size, | 3099 virtual void GetWindowMask(const gfx::Size& size, |
| 3100 gfx::Path* window_mask) OVERRIDE {} | 3100 gfx::Path* window_mask) override {} |
| 3101 virtual void ResetWindowControls() OVERRIDE {} | 3101 virtual void ResetWindowControls() override {} |
| 3102 virtual void UpdateWindowIcon() OVERRIDE {} | 3102 virtual void UpdateWindowIcon() override {} |
| 3103 virtual void UpdateWindowTitle() OVERRIDE {} | 3103 virtual void UpdateWindowTitle() override {} |
| 3104 virtual void SizeConstraintsChanged() OVERRIDE {} | 3104 virtual void SizeConstraintsChanged() override {} |
| 3105 | 3105 |
| 3106 // views::View overrides: | 3106 // views::View overrides: |
| 3107 virtual void Layout() OVERRIDE { | 3107 virtual void Layout() override { |
| 3108 if (widget_->IsFullscreen()) | 3108 if (widget_->IsFullscreen()) |
| 3109 fullscreen_layout_called_ = true; | 3109 fullscreen_layout_called_ = true; |
| 3110 } | 3110 } |
| 3111 | 3111 |
| 3112 bool fullscreen_layout_called() const { return fullscreen_layout_called_; } | 3112 bool fullscreen_layout_called() const { return fullscreen_layout_called_; } |
| 3113 | 3113 |
| 3114 private: | 3114 private: |
| 3115 views::Widget* widget_; | 3115 views::Widget* widget_; |
| 3116 bool fullscreen_layout_called_; | 3116 bool fullscreen_layout_called_; |
| 3117 | 3117 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3141 | 3141 |
| 3142 #if !defined(OS_CHROMEOS) | 3142 #if !defined(OS_CHROMEOS) |
| 3143 namespace { | 3143 namespace { |
| 3144 | 3144 |
| 3145 // Trivial WidgetObserverTest that invokes Widget::IsActive() from | 3145 // Trivial WidgetObserverTest that invokes Widget::IsActive() from |
| 3146 // OnWindowDestroying. | 3146 // OnWindowDestroying. |
| 3147 class IsActiveFromDestroyObserver : public WidgetObserver { | 3147 class IsActiveFromDestroyObserver : public WidgetObserver { |
| 3148 public: | 3148 public: |
| 3149 IsActiveFromDestroyObserver() {} | 3149 IsActiveFromDestroyObserver() {} |
| 3150 virtual ~IsActiveFromDestroyObserver() {} | 3150 virtual ~IsActiveFromDestroyObserver() {} |
| 3151 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE { | 3151 virtual void OnWidgetDestroying(Widget* widget) override { |
| 3152 widget->IsActive(); | 3152 widget->IsActive(); |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 private: | 3155 private: |
| 3156 DISALLOW_COPY_AND_ASSIGN(IsActiveFromDestroyObserver); | 3156 DISALLOW_COPY_AND_ASSIGN(IsActiveFromDestroyObserver); |
| 3157 }; | 3157 }; |
| 3158 | 3158 |
| 3159 } // namespace | 3159 } // namespace |
| 3160 | 3160 |
| 3161 // Verifies Widget::IsActive() invoked from | 3161 // Verifies Widget::IsActive() invoked from |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 | 3347 |
| 3348 EXPECT_EQ(test_rect, root_view->bounds()); | 3348 EXPECT_EQ(test_rect, root_view->bounds()); |
| 3349 widget->ReorderNativeViews(); | 3349 widget->ReorderNativeViews(); |
| 3350 EXPECT_EQ(test_rect, root_view->bounds()); | 3350 EXPECT_EQ(test_rect, root_view->bounds()); |
| 3351 | 3351 |
| 3352 widget->CloseNow(); | 3352 widget->CloseNow(); |
| 3353 } | 3353 } |
| 3354 | 3354 |
| 3355 } // namespace test | 3355 } // namespace test |
| 3356 } // namespace views | 3356 } // namespace views |
| OLD | NEW |