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

Side by Side Diff: ui/views/corewm/desktop_capture_controller_unittest.cc

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/corewm/capture_controller.h" 5 #include "ui/views/corewm/capture_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/env.h" 8 #include "ui/aura/env.h"
9 #include "ui/aura/test/event_generator.h" 9 #include "ui/aura/test/event_generator.h"
10 #include "ui/aura/test/test_window_delegate.h" 10 #include "ui/aura/test/test_window_delegate.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // creates two widgets, does a mouse press in one, sets capture in the other and 66 // creates two widgets, does a mouse press in one, sets capture in the other and
67 // verifies state is reset in the first. 67 // verifies state is reset in the first.
68 TEST_F(DesktopCaptureControllerTest, ResetMouseHandlers) { 68 TEST_F(DesktopCaptureControllerTest, ResetMouseHandlers) {
69 scoped_ptr<Widget> w1(CreateWidget()); 69 scoped_ptr<Widget> w1(CreateWidget());
70 scoped_ptr<Widget> w2(CreateWidget()); 70 scoped_ptr<Widget> w2(CreateWidget());
71 aura::test::EventGenerator generator1(w1->GetNativeView()->GetRootWindow()); 71 aura::test::EventGenerator generator1(w1->GetNativeView()->GetRootWindow());
72 generator1.MoveMouseToCenterOf(w1->GetNativeView()); 72 generator1.MoveMouseToCenterOf(w1->GetNativeView());
73 generator1.PressLeftButton(); 73 generator1.PressLeftButton();
74 EXPECT_FALSE(w1->HasCapture()); 74 EXPECT_FALSE(w1->HasCapture());
75 aura::WindowEventDispatcher* w1_dispatcher = 75 aura::WindowEventDispatcher* w1_dispatcher =
76 w1->GetNativeView()->GetDispatcher(); 76 w1->GetNativeView()->GetHost()->dispatcher();
77 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() != NULL); 77 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() != NULL);
78 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() != NULL); 78 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() != NULL);
79 w2->SetCapture(w2->GetRootView()); 79 w2->SetCapture(w2->GetRootView());
80 EXPECT_TRUE(w2->HasCapture()); 80 EXPECT_TRUE(w2->HasCapture());
81 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() == NULL); 81 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() == NULL);
82 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() == NULL); 82 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() == NULL);
83 w2->ReleaseCapture(); 83 w2->ReleaseCapture();
84 } 84 }
85 85
86 // Tests aura::Window capture and whether gesture events are sent to the window 86 // Tests aura::Window capture and whether gesture events are sent to the window
(...skipping 11 matching lines...) Expand all
98 scoped_ptr<corewm::ScopedCaptureClient> scoped_capture_client( 98 scoped_ptr<corewm::ScopedCaptureClient> scoped_capture_client(
99 new corewm::ScopedCaptureClient(params.context->GetRootWindow())); 99 new corewm::ScopedCaptureClient(params.context->GetRootWindow()));
100 aura::client::CaptureClient* capture_client = 100 aura::client::CaptureClient* capture_client =
101 scoped_capture_client->capture_client(); 101 scoped_capture_client->capture_client();
102 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 102 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
103 params.bounds = gfx::Rect(50, 50, 650, 650); 103 params.bounds = gfx::Rect(50, 50, 650, 650);
104 widget1->Init(params); 104 widget1->Init(params);
105 internal::RootView* root1 = 105 internal::RootView* root1 =
106 static_cast<internal::RootView*>(widget1->GetRootView()); 106 static_cast<internal::RootView*>(widget1->GetRootView());
107 107
108 desktop_position_client1.reset(new DesktopScreenPositionClient()); 108 desktop_position_client1.reset(
109 new DesktopScreenPositionClient(params.context->GetRootWindow()));
109 aura::client::SetScreenPositionClient( 110 aura::client::SetScreenPositionClient(
110 widget1->GetNativeView()->GetRootWindow(), 111 widget1->GetNativeView()->GetRootWindow(),
111 desktop_position_client1.get()); 112 desktop_position_client1.get());
112 113
113 DesktopViewInputTest* v1 = new DesktopViewInputTest(); 114 DesktopViewInputTest* v1 = new DesktopViewInputTest();
114 v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300)); 115 v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
115 root1->AddChildView(v1); 116 root1->AddChildView(v1);
116 widget1->Show(); 117 widget1->Show();
117 118
118 scoped_ptr<Widget> widget2(new Widget()); 119 scoped_ptr<Widget> widget2(new Widget());
119 120
120 params = CreateParams(Widget::InitParams::TYPE_POPUP); 121 params = CreateParams(Widget::InitParams::TYPE_POPUP);
121 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 122 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
122 params.bounds = gfx::Rect(50, 50, 650, 650); 123 params.bounds = gfx::Rect(50, 50, 650, 650);
123 widget2->Init(params); 124 widget2->Init(params);
124 125
125 internal::RootView* root2 = 126 internal::RootView* root2 =
126 static_cast<internal::RootView*>(widget2->GetRootView()); 127 static_cast<internal::RootView*>(widget2->GetRootView());
127 desktop_position_client2.reset(new DesktopScreenPositionClient()); 128 desktop_position_client2.reset(
129 new DesktopScreenPositionClient(params.context->GetRootWindow()));
128 aura::client::SetScreenPositionClient( 130 aura::client::SetScreenPositionClient(
129 widget2->GetNativeView()->GetRootWindow(), 131 widget2->GetNativeView()->GetRootWindow(),
130 desktop_position_client2.get()); 132 desktop_position_client2.get());
131 133
132 DesktopViewInputTest* v2 = new DesktopViewInputTest(); 134 DesktopViewInputTest* v2 = new DesktopViewInputTest();
133 v2->SetBoundsRect(gfx::Rect(0, 0, 300, 300)); 135 v2->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
134 root2->AddChildView(v2); 136 root2->AddChildView(v2);
135 widget2->Show(); 137 widget2->Show();
136 138
137 EXPECT_FALSE(widget1->GetNativeView()->HasCapture()); 139 EXPECT_FALSE(widget1->GetNativeView()->HasCapture());
(...skipping 25 matching lines...) Expand all
163 root2->DispatchGestureEvent(&g1); 165 root2->DispatchGestureEvent(&g1);
164 EXPECT_TRUE(v2->received_gesture_event()); 166 EXPECT_TRUE(v2->received_gesture_event());
165 EXPECT_FALSE(v1->received_gesture_event()); 167 EXPECT_FALSE(v1->received_gesture_event());
166 168
167 widget1->CloseNow(); 169 widget1->CloseNow();
168 widget2->CloseNow(); 170 widget2->CloseNow();
169 RunPendingMessages(); 171 RunPendingMessages();
170 } 172 }
171 173
172 } // namespace views 174 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/capture_controller_unittest.cc ('k') | ui/views/corewm/input_method_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698