| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/path_service.h" |
| 7 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 8 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
| 9 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| 10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/base/ui_base_paths.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 #include "ui/gl/gl_surface.h" |
| 14 #include "ui/views/test/widget_test.h" | 18 #include "ui/views/test/widget_test.h" |
| 15 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/window/dialog_delegate.h" | 20 #include "ui/views/window/dialog_delegate.h" |
| 17 | 21 |
| 18 #if !defined(OS_CHROMEOS) | 22 #if !defined(OS_CHROMEOS) |
| 19 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 23 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 20 #endif | 24 #endif |
| 21 | 25 |
| 22 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 23 #include "ui/views/win/hwnd_util.h" | 27 #include "ui/views/win/hwnd_util.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return true; | 139 return true; |
| 136 } | 140 } |
| 137 | 141 |
| 138 Widget* widget_; | 142 Widget* widget_; |
| 139 | 143 |
| 140 DISALLOW_COPY_AND_ASSIGN(NestedLoopCaptureView); | 144 DISALLOW_COPY_AND_ASSIGN(NestedLoopCaptureView); |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 } // namespace | 147 } // namespace |
| 144 | 148 |
| 149 class WidgetTestInteractive : public WidgetTest { |
| 150 public: |
| 151 WidgetTestInteractive() {} |
| 152 virtual ~WidgetTestInteractive() {} |
| 153 |
| 154 virtual void SetUp() OVERRIDE { |
| 155 gfx::GLSurface::InitializeOneOffForTests(); |
| 156 base::FilePath pak_dir; |
| 157 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 158 base::FilePath pak_file; |
| 159 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak")); |
| 160 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 161 WidgetTest::SetUp(); |
| 162 } |
| 163 }; |
| 164 |
| 145 #if defined(OS_WIN) | 165 #if defined(OS_WIN) |
| 146 // Tests whether activation and focus change works correctly in Windows. | 166 // Tests whether activation and focus change works correctly in Windows. |
| 147 // We test the following:- | 167 // We test the following:- |
| 148 // 1. If the active aura window is correctly set when a top level widget is | 168 // 1. If the active aura window is correctly set when a top level widget is |
| 149 // created. | 169 // created. |
| 150 // 2. If the active aura window in widget 1 created above, is set to NULL when | 170 // 2. If the active aura window in widget 1 created above, is set to NULL when |
| 151 // another top level widget is created and focused. | 171 // another top level widget is created and focused. |
| 152 // 3. On focusing the native platform window for widget 1, the active aura | 172 // 3. On focusing the native platform window for widget 1, the active aura |
| 153 // window for widget 1 should be set and that for widget 2 should reset. | 173 // window for widget 1 should be set and that for widget 2 should reset. |
| 154 // TODO(ananta) | 174 // TODO(ananta) |
| 155 // Discuss with erg on how to write this test for linux x11 aura. | 175 // Discuss with erg on how to write this test for linux x11 aura. |
| 156 TEST_F(WidgetTest, DesktopNativeWidgetAuraActivationAndFocusTest) { | 176 TEST_F(WidgetTestInteractive, DesktopNativeWidgetAuraActivationAndFocusTest) { |
| 157 // Create widget 1 and expect the active window to be its window. | 177 // Create widget 1 and expect the active window to be its window. |
| 158 View* contents_view1 = new View; | 178 View* contents_view1 = new View; |
| 159 contents_view1->SetFocusable(true); | 179 contents_view1->SetFocusable(true); |
| 160 Widget widget1; | 180 Widget widget1; |
| 161 Widget::InitParams init_params = | 181 Widget::InitParams init_params = |
| 162 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 182 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 163 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 183 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
| 164 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 184 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 165 init_params.native_widget = new DesktopNativeWidgetAura(&widget1); | 185 init_params.native_widget = new DesktopNativeWidgetAura(&widget1); |
| 166 widget1.Init(init_params); | 186 widget1.Init(init_params); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // window. | 222 // window. |
| 203 contents_view1->RequestFocus(); | 223 contents_view1->RequestFocus(); |
| 204 ::SetActiveWindow( | 224 ::SetActiveWindow( |
| 205 root_window1->GetHost()->GetAcceleratedWidget()); | 225 root_window1->GetHost()->GetAcceleratedWidget()); |
| 206 EXPECT_EQ(activation_client2->GetActiveWindow(), | 226 EXPECT_EQ(activation_client2->GetActiveWindow(), |
| 207 reinterpret_cast<aura::Window*>(NULL)); | 227 reinterpret_cast<aura::Window*>(NULL)); |
| 208 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView()); | 228 EXPECT_EQ(activation_client1->GetActiveWindow(), widget1.GetNativeView()); |
| 209 } | 229 } |
| 210 #endif | 230 #endif |
| 211 | 231 |
| 212 TEST_F(WidgetTest, CaptureAutoReset) { | 232 TEST_F(WidgetTestInteractive, CaptureAutoReset) { |
| 213 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); | 233 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); |
| 214 View* container = new View; | 234 View* container = new View; |
| 215 toplevel->SetContentsView(container); | 235 toplevel->SetContentsView(container); |
| 216 | 236 |
| 217 EXPECT_FALSE(toplevel->HasCapture()); | 237 EXPECT_FALSE(toplevel->HasCapture()); |
| 218 toplevel->SetCapture(NULL); | 238 toplevel->SetCapture(NULL); |
| 219 EXPECT_TRUE(toplevel->HasCapture()); | 239 EXPECT_TRUE(toplevel->HasCapture()); |
| 220 | 240 |
| 221 // By default, mouse release removes capture. | 241 // By default, mouse release removes capture. |
| 222 gfx::Point click_location(45, 15); | 242 gfx::Point click_location(45, 15); |
| 223 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, | 243 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, |
| 224 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 244 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 225 toplevel->OnMouseEvent(&release); | 245 toplevel->OnMouseEvent(&release); |
| 226 EXPECT_FALSE(toplevel->HasCapture()); | 246 EXPECT_FALSE(toplevel->HasCapture()); |
| 227 | 247 |
| 228 // Now a mouse release shouldn't remove capture. | 248 // Now a mouse release shouldn't remove capture. |
| 229 toplevel->set_auto_release_capture(false); | 249 toplevel->set_auto_release_capture(false); |
| 230 toplevel->SetCapture(NULL); | 250 toplevel->SetCapture(NULL); |
| 231 EXPECT_TRUE(toplevel->HasCapture()); | 251 EXPECT_TRUE(toplevel->HasCapture()); |
| 232 toplevel->OnMouseEvent(&release); | 252 toplevel->OnMouseEvent(&release); |
| 233 EXPECT_TRUE(toplevel->HasCapture()); | 253 EXPECT_TRUE(toplevel->HasCapture()); |
| 234 toplevel->ReleaseCapture(); | 254 toplevel->ReleaseCapture(); |
| 235 EXPECT_FALSE(toplevel->HasCapture()); | 255 EXPECT_FALSE(toplevel->HasCapture()); |
| 236 | 256 |
| 237 toplevel->Close(); | 257 toplevel->Close(); |
| 238 RunPendingMessages(); | 258 RunPendingMessages(); |
| 239 } | 259 } |
| 240 | 260 |
| 241 TEST_F(WidgetTest, ResetCaptureOnGestureEnd) { | 261 TEST_F(WidgetTestInteractive, ResetCaptureOnGestureEnd) { |
| 242 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); | 262 Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); |
| 243 View* container = new View; | 263 View* container = new View; |
| 244 toplevel->SetContentsView(container); | 264 toplevel->SetContentsView(container); |
| 245 | 265 |
| 246 View* gesture = new GestureCaptureView; | 266 View* gesture = new GestureCaptureView; |
| 247 gesture->SetBounds(0, 0, 30, 30); | 267 gesture->SetBounds(0, 0, 30, 30); |
| 248 container->AddChildView(gesture); | 268 container->AddChildView(gesture); |
| 249 | 269 |
| 250 MouseView* mouse = new MouseView; | 270 MouseView* mouse = new MouseView; |
| 251 mouse->SetBounds(30, 0, 30, 30); | 271 mouse->SetBounds(30, 0, 30, 30); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 toplevel->OnMouseEvent(&release); | 307 toplevel->OnMouseEvent(&release); |
| 288 EXPECT_EQ(1, mouse->pressed()); | 308 EXPECT_EQ(1, mouse->pressed()); |
| 289 | 309 |
| 290 toplevel->Close(); | 310 toplevel->Close(); |
| 291 RunPendingMessages(); | 311 RunPendingMessages(); |
| 292 } | 312 } |
| 293 | 313 |
| 294 // Checks that if a mouse-press triggers a capture on a different widget (which | 314 // Checks that if a mouse-press triggers a capture on a different widget (which |
| 295 // consumes the mouse-release event), then the target of the press does not have | 315 // consumes the mouse-release event), then the target of the press does not have |
| 296 // capture. | 316 // capture. |
| 297 TEST_F(WidgetTest, DisableCaptureWidgetFromMousePress) { | 317 TEST_F(WidgetTestInteractive, DisableCaptureWidgetFromMousePress) { |
| 298 // The test creates two widgets: |first| and |second|. | 318 // The test creates two widgets: |first| and |second|. |
| 299 // The View in |first| makes |second| visible, sets capture on it, and starts | 319 // The View in |first| makes |second| visible, sets capture on it, and starts |
| 300 // a nested loop (like a menu does). The View in |second| terminates the | 320 // a nested loop (like a menu does). The View in |second| terminates the |
| 301 // nested loop and closes the widget. | 321 // nested loop and closes the widget. |
| 302 // The test sends a mouse-press event to |first|, and posts a task to send a | 322 // The test sends a mouse-press event to |first|, and posts a task to send a |
| 303 // release event to |second|, to make sure that the release event is | 323 // release event to |second|, to make sure that the release event is |
| 304 // dispatched after the nested loop starts. | 324 // dispatched after the nested loop starts. |
| 305 | 325 |
| 306 Widget* first = CreateTopLevelFramelessPlatformWidget(); | 326 Widget* first = CreateTopLevelFramelessPlatformWidget(); |
| 307 Widget* second = CreateTopLevelFramelessPlatformWidget(); | 327 Widget* second = CreateTopLevelFramelessPlatformWidget(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 326 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location, | 346 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location, |
| 327 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 347 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 328 first->OnMouseEvent(&press); | 348 first->OnMouseEvent(&press); |
| 329 EXPECT_FALSE(first->HasCapture()); | 349 EXPECT_FALSE(first->HasCapture()); |
| 330 first->Close(); | 350 first->Close(); |
| 331 RunPendingMessages(); | 351 RunPendingMessages(); |
| 332 } | 352 } |
| 333 | 353 |
| 334 // Tests some grab/ungrab events. | 354 // Tests some grab/ungrab events. |
| 335 // TODO(estade): can this be enabled now that this is an interactive ui test? | 355 // TODO(estade): can this be enabled now that this is an interactive ui test? |
| 336 TEST_F(WidgetTest, DISABLED_GrabUngrab) { | 356 TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) { |
| 337 Widget* toplevel = CreateTopLevelPlatformWidget(); | 357 Widget* toplevel = CreateTopLevelPlatformWidget(); |
| 338 Widget* child1 = CreateChildNativeWidgetWithParent(toplevel); | 358 Widget* child1 = CreateChildNativeWidgetWithParent(toplevel); |
| 339 Widget* child2 = CreateChildNativeWidgetWithParent(toplevel); | 359 Widget* child2 = CreateChildNativeWidgetWithParent(toplevel); |
| 340 | 360 |
| 341 toplevel->SetBounds(gfx::Rect(0, 0, 500, 500)); | 361 toplevel->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 342 | 362 |
| 343 child1->SetBounds(gfx::Rect(10, 10, 300, 300)); | 363 child1->SetBounds(gfx::Rect(10, 10, 300, 300)); |
| 344 View* view = new MouseView(); | 364 View* view = new MouseView(); |
| 345 view->SetBounds(0, 0, 300, 300); | 365 view->SetBounds(0, 0, 300, 300); |
| 346 child1->GetRootView()->AddChildView(view); | 366 child1->GetRootView()->AddChildView(view); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 toplevel->OnMouseEvent(&released2); | 408 toplevel->OnMouseEvent(&released2); |
| 389 EXPECT_FALSE(toplevel->HasCapture()); | 409 EXPECT_FALSE(toplevel->HasCapture()); |
| 390 EXPECT_FALSE(child1->HasCapture()); | 410 EXPECT_FALSE(child1->HasCapture()); |
| 391 EXPECT_FALSE(child2->HasCapture()); | 411 EXPECT_FALSE(child2->HasCapture()); |
| 392 | 412 |
| 393 toplevel->CloseNow(); | 413 toplevel->CloseNow(); |
| 394 } | 414 } |
| 395 | 415 |
| 396 // Tests mouse move outside of the window into the "resize controller" and back | 416 // Tests mouse move outside of the window into the "resize controller" and back |
| 397 // will still generate an OnMouseEntered and OnMouseExited event.. | 417 // will still generate an OnMouseEntered and OnMouseExited event.. |
| 398 TEST_F(WidgetTest, CheckResizeControllerEvents) { | 418 TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) { |
| 399 Widget* toplevel = CreateTopLevelPlatformWidget(); | 419 Widget* toplevel = CreateTopLevelPlatformWidget(); |
| 400 | 420 |
| 401 toplevel->SetBounds(gfx::Rect(0, 0, 100, 100)); | 421 toplevel->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 402 | 422 |
| 403 MouseView* view = new MouseView(); | 423 MouseView* view = new MouseView(); |
| 404 view->SetBounds(90, 90, 10, 10); | 424 view->SetBounds(90, 90, 10, 10); |
| 405 toplevel->GetRootView()->AddChildView(view); | 425 toplevel->GetRootView()->AddChildView(view); |
| 406 | 426 |
| 407 toplevel->Show(); | 427 toplevel->Show(); |
| 408 RunPendingMessages(); | 428 RunPendingMessages(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 bool active() const { return active_; } | 484 bool active() const { return active_; } |
| 465 | 485 |
| 466 private: | 486 private: |
| 467 bool active_; | 487 bool active_; |
| 468 | 488 |
| 469 DISALLOW_COPY_AND_ASSIGN(WidgetActivationTest); | 489 DISALLOW_COPY_AND_ASSIGN(WidgetActivationTest); |
| 470 }; | 490 }; |
| 471 | 491 |
| 472 // Tests whether the widget only becomes active when the underlying window | 492 // Tests whether the widget only becomes active when the underlying window |
| 473 // is really active. | 493 // is really active. |
| 474 TEST_F(WidgetTest, WidgetNotActivatedOnFakeActivationMessages) { | 494 TEST_F(WidgetTestInteractive, WidgetNotActivatedOnFakeActivationMessages) { |
| 475 WidgetActivationTest widget1; | 495 WidgetActivationTest widget1; |
| 476 Widget::InitParams init_params = | 496 Widget::InitParams init_params = |
| 477 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 497 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 478 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 498 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 479 init_params.native_widget = new DesktopNativeWidgetAura(&widget1); | 499 init_params.native_widget = new DesktopNativeWidgetAura(&widget1); |
| 480 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 500 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
| 481 widget1.Init(init_params); | 501 widget1.Init(init_params); |
| 482 widget1.Show(); | 502 widget1.Show(); |
| 483 EXPECT_EQ(true, widget1.active()); | 503 EXPECT_EQ(true, widget1.active()); |
| 484 | 504 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 536 |
| 517 private: | 537 private: |
| 518 ui::ModalType type_; | 538 ui::ModalType type_; |
| 519 | 539 |
| 520 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); | 540 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); |
| 521 }; | 541 }; |
| 522 | 542 |
| 523 // Tests whether the focused window is set correctly when a modal window is | 543 // Tests whether the focused window is set correctly when a modal window is |
| 524 // created and destroyed. When it is destroyed it should focus the owner | 544 // created and destroyed. When it is destroyed it should focus the owner |
| 525 // window. | 545 // window. |
| 526 TEST_F(WidgetTest, WindowModalWindowDestroyedActivationTest) { | 546 TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) { |
| 527 // Create a top level widget. | 547 // Create a top level widget. |
| 528 Widget top_level_widget; | 548 Widget top_level_widget; |
| 529 Widget::InitParams init_params = | 549 Widget::InitParams init_params = |
| 530 CreateParams(Widget::InitParams::TYPE_WINDOW); | 550 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 531 init_params.show_state = ui::SHOW_STATE_NORMAL; | 551 init_params.show_state = ui::SHOW_STATE_NORMAL; |
| 532 gfx::Rect initial_bounds(0, 0, 500, 500); | 552 gfx::Rect initial_bounds(0, 0, 500, 500); |
| 533 init_params.bounds = initial_bounds; | 553 init_params.bounds = initial_bounds; |
| 534 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 554 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 535 init_params.native_widget = new DesktopNativeWidgetAura(&top_level_widget); | 555 init_params.native_widget = new DesktopNativeWidgetAura(&top_level_widget); |
| 536 top_level_widget.Init(init_params); | 556 top_level_widget.Init(init_params); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 553 EXPECT_EQ(dialog_window, aura::client::GetFocusClient( | 573 EXPECT_EQ(dialog_window, aura::client::GetFocusClient( |
| 554 top_level_window)->GetFocusedWindow()); | 574 top_level_window)->GetFocusedWindow()); |
| 555 | 575 |
| 556 modal_dialog_widget->CloseNow(); | 576 modal_dialog_widget->CloseNow(); |
| 557 EXPECT_EQ(top_level_window, aura::client::GetFocusClient( | 577 EXPECT_EQ(top_level_window, aura::client::GetFocusClient( |
| 558 top_level_window)->GetFocusedWindow()); | 578 top_level_window)->GetFocusedWindow()); |
| 559 top_level_widget.CloseNow(); | 579 top_level_widget.CloseNow(); |
| 560 } | 580 } |
| 561 | 581 |
| 562 // Test that when opening a system-modal window, capture is released. | 582 // Test that when opening a system-modal window, capture is released. |
| 563 TEST_F(WidgetTest, SystemModalWindowReleasesCapture) { | 583 TEST_F(WidgetTestInteractive, SystemModalWindowReleasesCapture) { |
| 564 // Create a top level widget. | 584 // Create a top level widget. |
| 565 Widget top_level_widget; | 585 Widget top_level_widget; |
| 566 Widget::InitParams init_params = | 586 Widget::InitParams init_params = |
| 567 CreateParams(Widget::InitParams::TYPE_WINDOW); | 587 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 568 init_params.show_state = ui::SHOW_STATE_NORMAL; | 588 init_params.show_state = ui::SHOW_STATE_NORMAL; |
| 569 gfx::Rect initial_bounds(0, 0, 500, 500); | 589 gfx::Rect initial_bounds(0, 0, 500, 500); |
| 570 init_params.bounds = initial_bounds; | 590 init_params.bounds = initial_bounds; |
| 571 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 591 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 572 init_params.native_widget = new DesktopNativeWidgetAura(&top_level_widget); | 592 init_params.native_widget = new DesktopNativeWidgetAura(&top_level_widget); |
| 573 top_level_widget.Init(init_params); | 593 top_level_widget.Init(init_params); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 } // namespace | 647 } // namespace |
| 628 | 648 |
| 629 class WidgetCaptureTest : public ViewsTestBase { | 649 class WidgetCaptureTest : public ViewsTestBase { |
| 630 public: | 650 public: |
| 631 WidgetCaptureTest() { | 651 WidgetCaptureTest() { |
| 632 } | 652 } |
| 633 | 653 |
| 634 virtual ~WidgetCaptureTest() { | 654 virtual ~WidgetCaptureTest() { |
| 635 } | 655 } |
| 636 | 656 |
| 657 virtual void SetUp() OVERRIDE { |
| 658 gfx::GLSurface::InitializeOneOffForTests(); |
| 659 base::FilePath pak_dir; |
| 660 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 661 base::FilePath pak_file; |
| 662 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak")); |
| 663 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 664 ViewsTestBase::SetUp(); |
| 665 } |
| 666 |
| 637 // Verifies Widget::SetCapture() results in updating native capture along with | 667 // Verifies Widget::SetCapture() results in updating native capture along with |
| 638 // invoking the right Widget function. | 668 // invoking the right Widget function. |
| 639 void TestCapture(bool use_desktop_native_widget) { | 669 void TestCapture(bool use_desktop_native_widget) { |
| 640 CaptureLostTrackingWidget widget1; | 670 CaptureLostTrackingWidget widget1; |
| 641 Widget::InitParams params1 = | 671 Widget::InitParams params1 = |
| 642 CreateParams(views::Widget::InitParams::TYPE_WINDOW); | 672 CreateParams(views::Widget::InitParams::TYPE_WINDOW); |
| 643 params1.native_widget = CreateNativeWidget(use_desktop_native_widget, | 673 params1.native_widget = CreateNativeWidget(use_desktop_native_widget, |
| 644 &widget1); | 674 &widget1); |
| 645 params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 675 params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 646 widget1.Init(params1); | 676 widget1.Init(params1); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 803 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
| 774 GetHost()->dispatcher()->OnEventFromSource(&mouse_event); | 804 GetHost()->dispatcher()->OnEventFromSource(&mouse_event); |
| 775 ASSERT_FALSE(details.dispatcher_destroyed); | 805 ASSERT_FALSE(details.dispatcher_destroyed); |
| 776 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 806 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
| 777 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 807 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
| 778 } | 808 } |
| 779 #endif | 809 #endif |
| 780 | 810 |
| 781 } // namespace test | 811 } // namespace test |
| 782 } // namespace views | 812 } // namespace views |
| OLD | NEW |