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

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: Fix erroneously removed line from NWWin tests. 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
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/native_widget_unittest.cc » ('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 (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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // Create two views (both sized the same). |child| is configured not to 242 // Create two views (both sized the same). |child| is configured not to
241 // consume the gesture event. 243 // consume the gesture event.
242 GestureTrackingView* view = new GestureTrackingView(); 244 GestureTrackingView* view = new GestureTrackingView();
243 GestureTrackingView* child = new GestureTrackingView(); 245 GestureTrackingView* child = new GestureTrackingView();
244 child->set_consume_gesture_event(false); 246 child->set_consume_gesture_event(false);
245 view->SetLayoutManager(new FillLayout); 247 view->SetLayoutManager(new FillLayout);
246 view->AddChildView(child); 248 view->AddChildView(child);
247 scoped_ptr<TestWidget> widget(new TestWidget()); 249 scoped_ptr<TestWidget> widget(new TestWidget());
248 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 250 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
249 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 251 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
252 params.context = root_window();
250 params.bounds = gfx::Rect(0, 0, 100, 200); 253 params.bounds = gfx::Rect(0, 0, 100, 200);
251 widget->Init(params); 254 widget->Init(params);
252 widget->SetContentsView(view); 255 widget->SetContentsView(view);
253 widget->Show(); 256 widget->Show();
254 257
255 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 258 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
256 base::TimeDelta()); 259 base::TimeDelta());
257 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 260 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
258 // Both views should get the press. 261 // Both views should get the press.
259 EXPECT_TRUE(view->got_gesture_event()); 262 EXPECT_TRUE(view->got_gesture_event());
(...skipping 15 matching lines...) Expand all
275 // Work around for bug in NativeWidgetAura. 278 // Work around for bug in NativeWidgetAura.
276 // TODO: fix bug and remove this. 279 // TODO: fix bug and remove this.
277 widget->Close(); 280 widget->Close();
278 } 281 }
279 282
280 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) { 283 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) {
281 GestureTrackingView* view = new GestureTrackingView(); 284 GestureTrackingView* view = new GestureTrackingView();
282 scoped_ptr<TestWidget> widget(new TestWidget()); 285 scoped_ptr<TestWidget> widget(new TestWidget());
283 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 286 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
284 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 287 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
288 params.context = root_window();
285 params.bounds = gfx::Rect(0, 0, 100, 200); 289 params.bounds = gfx::Rect(0, 0, 100, 200);
286 widget->Init(params); 290 widget->Init(params);
287 widget->SetContentsView(view); 291 widget->SetContentsView(view);
288 widget->Show(); 292 widget->Show();
289 293
290 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 294 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
291 base::TimeDelta()); 295 base::TimeDelta());
292 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 296 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
293 EXPECT_TRUE(view->got_gesture_event()); 297 EXPECT_TRUE(view->got_gesture_event());
294 view->clear_got_gesture_event(); 298 view->clear_got_gesture_event();
(...skipping 16 matching lines...) Expand all
311 315
312 // Verifies views with layers are targeted for events properly. 316 // Verifies views with layers are targeted for events properly.
313 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) { 317 TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) {
314 // Create two widget, |parent_root| and |child|. |child| is a child of 318 // Create two widget, |parent_root| and |child|. |child| is a child of
315 // |parent_root|. 319 // |parent_root|.
316 views::View* parent_root = new views::View; 320 views::View* parent_root = new views::View;
317 scoped_ptr<Widget> parent(new Widget()); 321 scoped_ptr<Widget> parent(new Widget());
318 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 322 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
319 parent_params.ownership = 323 parent_params.ownership =
320 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 324 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
325 parent_params.context = root_window();
321 parent->Init(parent_params); 326 parent->Init(parent_params);
322 parent->SetContentsView(parent_root); 327 parent->SetContentsView(parent_root);
323 parent->SetBounds(gfx::Rect(0, 0, 400, 400)); 328 parent->SetBounds(gfx::Rect(0, 0, 400, 400));
324 parent->Show(); 329 parent->Show();
325 330
326 scoped_ptr<Widget> child(new Widget()); 331 scoped_ptr<Widget> child(new Widget());
327 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); 332 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
328 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 333 child_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
329 child_params.parent = parent->GetNativeWindow(); 334 child_params.parent = parent->GetNativeWindow();
330 child->Init(child_params); 335 child->Init(child_params);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 parent->GetNativeWindow()->GetEventHandlerForPoint( 371 parent->GetNativeWindow()->GetEventHandlerForPoint(
367 gfx::Point(20, 20))); 372 gfx::Point(20, 20)));
368 373
369 // Work around for bug in NativeWidgetAura. 374 // Work around for bug in NativeWidgetAura.
370 // TODO: fix bug and remove this. 375 // TODO: fix bug and remove this.
371 parent->Close(); 376 parent->Close();
372 } 377 }
373 378
374 } // namespace 379 } // namespace
375 } // namespace views 380 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/native_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698