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

Side by Side Diff: ash/wm/window_modality_controller_unittest.cc

Issue 11795004: Continue threading context through unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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) 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/corewm/window_modality_controller.h" 5 #include "ui/views/corewm/window_modality_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // - A |child| window with parent window |parent|, but is modal to 355 // - A |child| window with parent window |parent|, but is modal to
356 // |modal_parent| window. 356 // |modal_parent| window.
357 // Validates: 357 // Validates:
358 // - Clicking on the |modal_parent| should activate the |child| window. 358 // - Clicking on the |modal_parent| should activate the |child| window.
359 // - Clicking on the |parent| window outside of the |modal_parent| bounds should 359 // - Clicking on the |parent| window outside of the |modal_parent| bounds should
360 // activate the |parent| window. 360 // activate the |parent| window.
361 // - Clicking on the |child| while |parent| is active should activate the 361 // - Clicking on the |child| while |parent| is active should activate the
362 // |child| window. 362 // |child| window.
363 // - Focus should follow the active window. 363 // - Focus should follow the active window.
364 TEST_F(WindowModalityControllerTest, ChildModal) { 364 TEST_F(WindowModalityControllerTest, ChildModal) {
365 views::test::ChildModalParent* delegate = new views::test::ChildModalParent; 365 views::test::ChildModalParent* delegate =
366 views::Widget* widget = views::Widget::CreateWindowWithBounds( 366 new views::test::ChildModalParent(CurrentContext());
367 delegate, gfx::Rect(0, 0, 400, 400)); 367 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
368 delegate, CurrentContext(), gfx::Rect(0, 0, 400, 400));
368 widget->Show(); 369 widget->Show();
369 370
370 aura::Window* parent = widget->GetNativeView(); 371 aura::Window* parent = widget->GetNativeView();
371 EXPECT_TRUE(wm::IsActiveWindow(parent)); 372 EXPECT_TRUE(wm::IsActiveWindow(parent));
372 373
373 aura::Window* modal_parent = delegate->GetModalParent(); 374 aura::Window* modal_parent = delegate->GetModalParent();
374 EXPECT_NE(static_cast<aura::Window*>(NULL), modal_parent); 375 EXPECT_NE(static_cast<aura::Window*>(NULL), modal_parent);
375 EXPECT_NE(parent, modal_parent); 376 EXPECT_NE(parent, modal_parent);
376 EXPECT_FALSE(wm::IsActiveWindow(modal_parent)); 377 EXPECT_FALSE(wm::IsActiveWindow(modal_parent));
377 378
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 EXPECT_FALSE(wm::IsActiveWindow(parent)); 415 EXPECT_FALSE(wm::IsActiveWindow(parent));
415 416
416 EXPECT_TRUE(child->HasFocus()); 417 EXPECT_TRUE(child->HasFocus());
417 EXPECT_FALSE(modal_parent->HasFocus()); 418 EXPECT_FALSE(modal_parent->HasFocus());
418 EXPECT_FALSE(parent->HasFocus()); 419 EXPECT_FALSE(parent->HasFocus());
419 } 420 }
420 421
421 // Same as |ChildModal| test, but using |EventGenerator| rather than bypassing 422 // Same as |ChildModal| test, but using |EventGenerator| rather than bypassing
422 // it by calling |ActivateWindow|. 423 // it by calling |ActivateWindow|.
423 TEST_F(WindowModalityControllerTest, ChildModalEventGenerator) { 424 TEST_F(WindowModalityControllerTest, ChildModalEventGenerator) {
424 views::test::ChildModalParent* delegate = new views::test::ChildModalParent; 425 views::test::ChildModalParent* delegate =
425 views::Widget* widget = views::Widget::CreateWindowWithBounds( 426 new views::test::ChildModalParent(CurrentContext());
426 delegate, gfx::Rect(0, 0, 400, 400)); 427 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
428 delegate, CurrentContext(), gfx::Rect(0, 0, 400, 400));
427 widget->Show(); 429 widget->Show();
428 430
429 aura::Window* parent = widget->GetNativeView(); 431 aura::Window* parent = widget->GetNativeView();
430 EXPECT_TRUE(wm::IsActiveWindow(parent)); 432 EXPECT_TRUE(wm::IsActiveWindow(parent));
431 433
432 aura::Window* modal_parent = delegate->GetModalParent(); 434 aura::Window* modal_parent = delegate->GetModalParent();
433 EXPECT_NE(static_cast<aura::Window*>(NULL), modal_parent); 435 EXPECT_NE(static_cast<aura::Window*>(NULL), modal_parent);
434 EXPECT_NE(parent, modal_parent); 436 EXPECT_NE(parent, modal_parent);
435 EXPECT_FALSE(wm::IsActiveWindow(modal_parent)); 437 EXPECT_FALSE(wm::IsActiveWindow(modal_parent));
436 438
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 548
547 wm::ActivateWindow(w3.get()); 549 wm::ActivateWindow(w3.get());
548 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 550 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
549 551
550 wm::ActivateWindow(w4.get()); 552 wm::ActivateWindow(w4.get());
551 EXPECT_TRUE(wm::IsActiveWindow(w4.get())); 553 EXPECT_TRUE(wm::IsActiveWindow(w4.get()));
552 } 554 }
553 555
554 } // namespace internal 556 } // namespace internal
555 } // namespace ash 557 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698