Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/views/widget/root_view_unittest.cc

Issue 686493002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/widget/root_view_targeter.h ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include "ui/views/context_menu_controller.h" 7 #include "ui/views/context_menu_controller.h"
8 #include "ui/views/test/views_test_base.h" 8 #include "ui/views/test/views_test_base.h"
9 #include "ui/views/view_targeter.h" 9 #include "ui/views/view_targeter.h"
10 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
11 11
12 namespace views { 12 namespace views {
13 namespace test { 13 namespace test {
14 14
15 typedef ViewsTestBase RootViewTest; 15 typedef ViewsTestBase RootViewTest;
16 16
17 class DeleteOnKeyEventView : public View { 17 class DeleteOnKeyEventView : public View {
18 public: 18 public:
19 explicit DeleteOnKeyEventView(bool* set_on_key) : set_on_key_(set_on_key) {} 19 explicit DeleteOnKeyEventView(bool* set_on_key) : set_on_key_(set_on_key) {}
20 virtual ~DeleteOnKeyEventView() {} 20 ~DeleteOnKeyEventView() override {}
21 21
22 virtual bool OnKeyPressed(const ui::KeyEvent& event) override { 22 bool OnKeyPressed(const ui::KeyEvent& event) override {
23 *set_on_key_ = true; 23 *set_on_key_ = true;
24 delete this; 24 delete this;
25 return true; 25 return true;
26 } 26 }
27 27
28 private: 28 private:
29 // Set to true in OnKeyPressed(). 29 // Set to true in OnKeyPressed().
30 bool* set_on_key_; 30 bool* set_on_key_;
31 31
32 DISALLOW_COPY_AND_ASSIGN(DeleteOnKeyEventView); 32 DISALLOW_COPY_AND_ASSIGN(DeleteOnKeyEventView);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 // Tracks whether a context menu is shown. 68 // Tracks whether a context menu is shown.
69 class TestContextMenuController : public ContextMenuController { 69 class TestContextMenuController : public ContextMenuController {
70 public: 70 public:
71 TestContextMenuController() 71 TestContextMenuController()
72 : show_context_menu_calls_(0), 72 : show_context_menu_calls_(0),
73 menu_source_view_(NULL), 73 menu_source_view_(NULL),
74 menu_source_type_(ui::MENU_SOURCE_NONE) { 74 menu_source_type_(ui::MENU_SOURCE_NONE) {
75 } 75 }
76 virtual ~TestContextMenuController() {} 76 ~TestContextMenuController() override {}
77 77
78 int show_context_menu_calls() const { return show_context_menu_calls_; } 78 int show_context_menu_calls() const { return show_context_menu_calls_; }
79 View* menu_source_view() const { return menu_source_view_; } 79 View* menu_source_view() const { return menu_source_view_; }
80 ui::MenuSourceType menu_source_type() const { return menu_source_type_; } 80 ui::MenuSourceType menu_source_type() const { return menu_source_type_; }
81 81
82 void Reset() { 82 void Reset() {
83 show_context_menu_calls_ = 0; 83 show_context_menu_calls_ = 0;
84 menu_source_view_ = NULL; 84 menu_source_view_ = NULL;
85 menu_source_type_ = ui::MENU_SOURCE_NONE; 85 menu_source_type_ = ui::MENU_SOURCE_NONE;
86 } 86 }
87 87
88 // ContextMenuController: 88 // ContextMenuController:
89 virtual void ShowContextMenuForView( 89 void ShowContextMenuForView(View* source,
90 View* source, 90 const gfx::Point& point,
91 const gfx::Point& point, 91 ui::MenuSourceType source_type) override {
92 ui::MenuSourceType source_type) override {
93 show_context_menu_calls_++; 92 show_context_menu_calls_++;
94 menu_source_view_ = source; 93 menu_source_view_ = source;
95 menu_source_type_ = source_type; 94 menu_source_type_ = source_type;
96 } 95 }
97 96
98 private: 97 private:
99 int show_context_menu_calls_; 98 int show_context_menu_calls_;
100 View* menu_source_view_; 99 View* menu_source_view_;
101 ui::MenuSourceType menu_source_type_; 100 ui::MenuSourceType menu_source_type_;
102 101
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT_EQ(ui::MENU_SOURCE_KEYBOARD, controller.menu_source_type()); 152 EXPECT_EQ(ui::MENU_SOURCE_KEYBOARD, controller.menu_source_type());
154 controller.Reset(); 153 controller.Reset();
155 } 154 }
156 155
157 // View which handles all gesture events. 156 // View which handles all gesture events.
158 class GestureHandlingView : public View { 157 class GestureHandlingView : public View {
159 public: 158 public:
160 GestureHandlingView() { 159 GestureHandlingView() {
161 } 160 }
162 161
163 virtual ~GestureHandlingView() { 162 ~GestureHandlingView() override {}
164 }
165 163
166 virtual void OnGestureEvent(ui::GestureEvent* event) override { 164 void OnGestureEvent(ui::GestureEvent* event) override { event->SetHandled(); }
167 event->SetHandled();
168 }
169 165
170 private: 166 private:
171 DISALLOW_COPY_AND_ASSIGN(GestureHandlingView); 167 DISALLOW_COPY_AND_ASSIGN(GestureHandlingView);
172 }; 168 };
173 169
174 // Tests that context menus are shown for long press by the post-target handler 170 // Tests that context menus are shown for long press by the post-target handler
175 // installed on the RootView only if the event is targetted at a view which can 171 // installed on the RootView only if the event is targetted at a view which can
176 // show a context menu. 172 // show a context menu.
177 TEST_F(RootViewTest, ContextMenuFromLongPress) { 173 TEST_F(RootViewTest, ContextMenuFromLongPress) {
178 Widget widget; 174 Widget widget;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END)); 332 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
337 details = root_view->OnEventFromSource(&end3); 333 details = root_view->OnEventFromSource(&end3);
338 334
339 EXPECT_FALSE(details.target_destroyed); 335 EXPECT_FALSE(details.target_destroyed);
340 EXPECT_FALSE(details.dispatcher_destroyed); 336 EXPECT_FALSE(details.dispatcher_destroyed);
341 EXPECT_EQ(0, controller.show_context_menu_calls()); 337 EXPECT_EQ(0, controller.show_context_menu_calls());
342 } 338 }
343 339
344 } // namespace test 340 } // namespace test
345 } // namespace views 341 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/root_view_targeter.h ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698