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

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

Issue 11416251: Desktop aura: Continue threading context through views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One last line removed. Created 8 years 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) 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/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // the window ends up maximized. This is important as otherwise 165 // the window ends up maximized. This is important as otherwise
166 // RenderWidgetHostViewAura ends up getting resized during construction, which 166 // RenderWidgetHostViewAura ends up getting resized during construction, which
167 // leads to noticable flashes. 167 // leads to noticable flashes.
168 TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) { 168 TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) {
169 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); 169 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480));
170 root_window()->SetLayoutManager(new TestLayoutManager); 170 root_window()->SetLayoutManager(new TestLayoutManager);
171 scoped_ptr<TestWidget> widget(new TestWidget()); 171 scoped_ptr<TestWidget> widget(new TestWidget());
172 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 172 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
173 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 173 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
174 params.parent = NULL; 174 params.parent = NULL;
175 params.context = root_window();
175 params.show_state = ui::SHOW_STATE_MAXIMIZED; 176 params.show_state = ui::SHOW_STATE_MAXIMIZED;
176 params.bounds = gfx::Rect(10, 10, 100, 200); 177 params.bounds = gfx::Rect(10, 10, 100, 200);
177 widget->Init(params); 178 widget->Init(params);
178 EXPECT_FALSE(widget->did_size_change_more_than_once()); 179 EXPECT_FALSE(widget->did_size_change_more_than_once());
179 widget->CloseNow(); 180 widget->CloseNow();
180 } 181 }
181 182
182 TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) { 183 TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) {
183 // Create a widget. 184 // Create a widget.
184 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 185 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
185 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 186 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
187 params.context = root_window();
186 params.bounds.SetRect(10, 20, 300, 400); 188 params.bounds.SetRect(10, 20, 300, 400);
187 scoped_ptr<Widget> widget(new Widget()); 189 scoped_ptr<Widget> widget(new Widget());
188 widget->Init(params); 190 widget->Init(params);
189 191
190 // For Aura, client area bounds match window bounds. 192 // For Aura, client area bounds match window bounds.
191 gfx::Rect client_bounds = widget->GetClientAreaBoundsInScreen(); 193 gfx::Rect client_bounds = widget->GetClientAreaBoundsInScreen();
192 EXPECT_EQ(10, client_bounds.x()); 194 EXPECT_EQ(10, client_bounds.x());
193 EXPECT_EQ(20, client_bounds.y()); 195 EXPECT_EQ(20, client_bounds.y());
194 EXPECT_EQ(300, client_bounds.width()); 196 EXPECT_EQ(300, client_bounds.width());
195 EXPECT_EQ(400, client_bounds.height()); 197 EXPECT_EQ(400, client_bounds.height());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Create two views (both sized the same). |child| is configured not to 241 // Create two views (both sized the same). |child| is configured not to
240 // consume the gesture event. 242 // consume the gesture event.
241 GestureTrackingView* view = new GestureTrackingView(); 243 GestureTrackingView* view = new GestureTrackingView();
242 GestureTrackingView* child = new GestureTrackingView(); 244 GestureTrackingView* child = new GestureTrackingView();
243 child->set_consume_gesture_event(false); 245 child->set_consume_gesture_event(false);
244 view->SetLayoutManager(new FillLayout); 246 view->SetLayoutManager(new FillLayout);
245 view->AddChildView(child); 247 view->AddChildView(child);
246 scoped_ptr<TestWidget> widget(new TestWidget()); 248 scoped_ptr<TestWidget> widget(new TestWidget());
247 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 249 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
248 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 250 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
251 params.context = root_window();
249 params.bounds = gfx::Rect(0, 0, 100, 200); 252 params.bounds = gfx::Rect(0, 0, 100, 200);
250 widget->Init(params); 253 widget->Init(params);
251 widget->SetContentsView(view); 254 widget->SetContentsView(view);
252 widget->Show(); 255 widget->Show();
253 256
254 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 257 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
255 base::TimeDelta()); 258 base::TimeDelta());
256 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 259 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
257 // Both views should get the press. 260 // Both views should get the press.
258 EXPECT_TRUE(view->got_gesture_event()); 261 EXPECT_TRUE(view->got_gesture_event());
(...skipping 15 matching lines...) Expand all
274 // Work around for bug in NativeWidgetAura. 277 // Work around for bug in NativeWidgetAura.
275 // TODO: fix bug and remove this. 278 // TODO: fix bug and remove this.
276 widget->Close(); 279 widget->Close();
277 } 280 }
278 281
279 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) { 282 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) {
280 GestureTrackingView* view = new GestureTrackingView(); 283 GestureTrackingView* view = new GestureTrackingView();
281 scoped_ptr<TestWidget> widget(new TestWidget()); 284 scoped_ptr<TestWidget> widget(new TestWidget());
282 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 285 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
283 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 286 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
287 params.context = root_window();
284 params.bounds = gfx::Rect(0, 0, 100, 200); 288 params.bounds = gfx::Rect(0, 0, 100, 200);
285 widget->Init(params); 289 widget->Init(params);
286 widget->SetContentsView(view); 290 widget->SetContentsView(view);
287 widget->Show(); 291 widget->Show();
288 292
289 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 293 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
290 base::TimeDelta()); 294 base::TimeDelta());
291 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 295 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
292 EXPECT_TRUE(view->got_gesture_event()); 296 EXPECT_TRUE(view->got_gesture_event());
293 view->clear_got_gesture_event(); 297 view->clear_got_gesture_event();
(...skipping 16 matching lines...) Expand all
310 314
311 // Verifies views with layers are targeted for events properly. 315 // Verifies views with layers are targeted for events properly.
312 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) { 316 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) {
313 // Create two widget, |parent_root| and |child|. |child| is a child of 317 // Create two widget, |parent_root| and |child|. |child| is a child of
314 // |parent_root|. 318 // |parent_root|.
315 views::View* parent_root = new views::View; 319 views::View* parent_root = new views::View;
316 scoped_ptr<Widget> parent(new Widget()); 320 scoped_ptr<Widget> parent(new Widget());
317 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 321 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
318 parent_params.ownership = 322 parent_params.ownership =
319 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 323 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
324 parent_params.context = root_window();
320 parent->Init(parent_params); 325 parent->Init(parent_params);
321 parent->SetContentsView(parent_root); 326 parent->SetContentsView(parent_root);
322 parent->SetBounds(gfx::Rect(0, 0, 400, 400)); 327 parent->SetBounds(gfx::Rect(0, 0, 400, 400));
323 parent->Show(); 328 parent->Show();
324 329
325 scoped_ptr<Widget> child(new Widget()); 330 scoped_ptr<Widget> child(new Widget());
326 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); 331 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
327 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 332 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
328 child_params.parent = parent->GetNativeWindow(); 333 child_params.parent = parent->GetNativeWindow();
329 child->Init(child_params); 334 child->Init(child_params);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 parent->GetNativeWindow()->GetEventHandlerForPoint( 370 parent->GetNativeWindow()->GetEventHandlerForPoint(
366 gfx::Point(20, 20))); 371 gfx::Point(20, 20)));
367 372
368 // Work around for bug in NativeWidgetAura. 373 // Work around for bug in NativeWidgetAura.
369 // TODO: fix bug and remove this. 374 // TODO: fix bug and remove this.
370 parent->Close(); 375 parent->Close();
371 } 376 }
372 377
373 } // namespace 378 } // namespace
374 } // namespace views 379 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698