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

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

Issue 354063003: View should store a ViewTargeter instead of an EventTargeter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compilation errors Created 6 years, 5 months 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 | Annotate | Revision Log
« ui/views/view.h ('K') | « ui/views/widget/root_view.cc ('k') | no next file » | 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/events/event_targeter.h"
8 #include "ui/views/context_menu_controller.h" 7 #include "ui/views/context_menu_controller.h"
9 #include "ui/views/test/views_test_base.h" 8 #include "ui/views/test/views_test_base.h"
10 #include "ui/views/view_targeter.h" 9 #include "ui/views/view_targeter.h"
11 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
12 11
13 namespace views { 12 namespace views {
14 namespace test { 13 namespace test {
15 14
16 typedef ViewsTestBase RootViewTest; 15 typedef ViewsTestBase RootViewTest;
17 16
(...skipping 29 matching lines...) Expand all
47 View* content = new View; 46 View* content = new View;
48 widget.SetContentsView(content); 47 widget.SetContentsView(content);
49 48
50 View* child = new DeleteOnKeyEventView(&got_key_event); 49 View* child = new DeleteOnKeyEventView(&got_key_event);
51 content->AddChildView(child); 50 content->AddChildView(child);
52 51
53 // Give focus to |child| so that it will be the target of the key event. 52 // Give focus to |child| so that it will be the target of the key event.
54 child->SetFocusable(true); 53 child->SetFocusable(true);
55 child->RequestFocus(); 54 child->RequestFocus();
56 55
57 ui::EventTargeter* targeter = new ViewTargeter(); 56 ViewTargeter* targeter = new ViewTargeter();
58 internal::RootView* root_view = 57 internal::RootView* root_view =
59 static_cast<internal::RootView*>(widget.GetRootView()); 58 static_cast<internal::RootView*>(widget.GetRootView());
60 root_view->SetEventTargeter(make_scoped_ptr(targeter)); 59 root_view->SetEventTargeter(make_scoped_ptr(targeter));
61 60
62 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false); 61 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false);
63 ui::EventDispatchDetails details = root_view->OnEventFromSource(&key_event); 62 ui::EventDispatchDetails details = root_view->OnEventFromSource(&key_event);
64 EXPECT_TRUE(details.target_destroyed); 63 EXPECT_TRUE(details.target_destroyed);
65 EXPECT_FALSE(details.dispatcher_destroyed); 64 EXPECT_FALSE(details.dispatcher_destroyed);
66 EXPECT_TRUE(got_key_event); 65 EXPECT_TRUE(got_key_event);
67 } 66 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0), 1); 233 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0), 1);
235 details = root_view->OnEventFromSource(&end2); 234 details = root_view->OnEventFromSource(&end2);
236 235
237 EXPECT_FALSE(details.target_destroyed); 236 EXPECT_FALSE(details.target_destroyed);
238 EXPECT_FALSE(details.dispatcher_destroyed); 237 EXPECT_FALSE(details.dispatcher_destroyed);
239 EXPECT_EQ(1, controller.show_context_menu_calls()); 238 EXPECT_EQ(1, controller.show_context_menu_calls());
240 } 239 }
241 240
242 } // namespace test 241 } // namespace test
243 } // namespace views 242 } // namespace views
OLDNEW
« ui/views/view.h ('K') | « ui/views/widget/root_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698