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

Side by Side Diff: ash/extended_desktop_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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
« no previous file with comments | « ash/drag_drop/drag_image_view.h ('k') | ash/first_run/desktop_cleaner.h » ('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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 #include "ash/root_window_controller.h" 6 #include "ash/root_window_controller.h"
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/gfx/screen.h" 28 #include "ui/gfx/screen.h"
29 #include "ui/views/controls/textfield/textfield.h" 29 #include "ui/views/controls/textfield/textfield.h"
30 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
31 #include "ui/views/widget/widget_delegate.h" 31 #include "ui/views/widget/widget_delegate.h"
32 #include "ui/wm/public/activation_client.h" 32 #include "ui/wm/public/activation_client.h"
33 33
34 namespace ash { 34 namespace ash {
35 namespace { 35 namespace {
36 36
37 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { 37 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) {
38 scoped_ptr<display::DisplayLayout> layout = 38 std::unique_ptr<display::DisplayLayout> layout =
39 Shell::GetInstance()->display_manager()->GetCurrentDisplayLayout().Copy(); 39 Shell::GetInstance()->display_manager()->GetCurrentDisplayLayout().Copy();
40 layout->placement_list[0].position = position; 40 layout->placement_list[0].position = position;
41 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 41 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
42 std::move(layout)); 42 std::move(layout));
43 } 43 }
44 44
45 class ModalWidgetDelegate : public views::WidgetDelegateView { 45 class ModalWidgetDelegate : public views::WidgetDelegateView {
46 public: 46 public:
47 ModalWidgetDelegate() {} 47 ModalWidgetDelegate() {}
48 ~ModalWidgetDelegate() override {} 48 ~ModalWidgetDelegate() override {}
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if (!SupportsMultipleDisplays()) 371 if (!SupportsMultipleDisplays())
372 return; 372 return;
373 373
374 UpdateDisplay("1000x600,600x400"); 374 UpdateDisplay("1000x600,600x400");
375 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 375 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
376 376
377 aura::test::EventCountDelegate r1_d1; 377 aura::test::EventCountDelegate r1_d1;
378 aura::test::EventCountDelegate r1_d2; 378 aura::test::EventCountDelegate r1_d2;
379 aura::test::EventCountDelegate r2_d1; 379 aura::test::EventCountDelegate r2_d1;
380 380
381 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 381 std::unique_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
382 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 382 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
383 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 383 std::unique_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
384 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 384 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
385 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 385 std::unique_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
386 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); 386 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
387 387
388 r1_w1->SetCapture(); 388 r1_w1->SetCapture();
389 389
390 EXPECT_EQ(r1_w1.get(), 390 EXPECT_EQ(r1_w1.get(),
391 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); 391 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
392 392
393 ui::test::EventGenerator& generator = GetEventGenerator(); 393 ui::test::EventGenerator& generator = GetEventGenerator();
394 generator.MoveMouseToCenterOf(r2_w1.get()); 394 generator.MoveMouseToCenterOf(r2_w1.get());
395 // |r1_w1| will receive the events because it has capture. 395 // |r1_w1| will receive the events because it has capture.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (!SupportsMultipleDisplays()) 441 if (!SupportsMultipleDisplays())
442 return; 442 return;
443 443
444 UpdateDisplay("1000x600,600x400"); 444 UpdateDisplay("1000x600,600x400");
445 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 445 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
446 446
447 aura::test::EventCountDelegate r1_d1; 447 aura::test::EventCountDelegate r1_d1;
448 aura::test::EventCountDelegate r1_d2; 448 aura::test::EventCountDelegate r1_d2;
449 aura::test::EventCountDelegate r2_d1; 449 aura::test::EventCountDelegate r2_d1;
450 450
451 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 451 std::unique_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
452 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 452 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
453 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 453 std::unique_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
454 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 454 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
455 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 455 std::unique_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
456 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); 456 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
457 457
458 r1_w1->SetCapture(); 458 r1_w1->SetCapture();
459 459
460 ui::test::EventGenerator& generator = GetEventGenerator(); 460 ui::test::EventGenerator& generator = GetEventGenerator();
461 generator.MoveMouseToCenterOf(r2_w1.get()); 461 generator.MoveMouseToCenterOf(r2_w1.get());
462 EXPECT_EQ(gfx::Point(1060, 60).ToString(), 462 EXPECT_EQ(gfx::Point(1060, 60).ToString(),
463 generator.current_location().ToString()); 463 generator.current_location().ToString());
464 464
465 EventLocationHandler location_handler; 465 EventLocationHandler location_handler;
(...skipping 10 matching lines...) Expand all
476 if (!SupportsMultipleDisplays()) 476 if (!SupportsMultipleDisplays())
477 return; 477 return;
478 478
479 UpdateDisplay("1000x600*2,600x400"); 479 UpdateDisplay("1000x600*2,600x400");
480 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 480 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
481 481
482 aura::test::EventCountDelegate r1_d1; 482 aura::test::EventCountDelegate r1_d1;
483 aura::test::EventCountDelegate r1_d2; 483 aura::test::EventCountDelegate r1_d2;
484 aura::test::EventCountDelegate r2_d1; 484 aura::test::EventCountDelegate r2_d1;
485 485
486 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 486 std::unique_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
487 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 487 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
488 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 488 std::unique_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
489 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 489 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
490 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 490 std::unique_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
491 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); 491 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
492 492
493 r1_w1->SetCapture(); 493 r1_w1->SetCapture();
494 494
495 ui::test::EventGenerator& generator = GetEventGenerator(); 495 ui::test::EventGenerator& generator = GetEventGenerator();
496 generator.MoveMouseToCenterOf(r2_w1.get()); 496 generator.MoveMouseToCenterOf(r2_w1.get());
497 EXPECT_EQ(gfx::Point(560, 60).ToString(), 497 EXPECT_EQ(gfx::Point(560, 60).ToString(),
498 generator.current_location().ToString()); 498 generator.current_location().ToString());
499 499
500 EventLocationHandler location_handler; 500 EventLocationHandler location_handler;
(...skipping 10 matching lines...) Expand all
511 if (!SupportsMultipleDisplays()) 511 if (!SupportsMultipleDisplays())
512 return; 512 return;
513 513
514 UpdateDisplay("1000x600,600x400*2"); 514 UpdateDisplay("1000x600,600x400*2");
515 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 515 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
516 516
517 aura::test::EventCountDelegate r1_d1; 517 aura::test::EventCountDelegate r1_d1;
518 aura::test::EventCountDelegate r1_d2; 518 aura::test::EventCountDelegate r1_d2;
519 aura::test::EventCountDelegate r2_d1; 519 aura::test::EventCountDelegate r2_d1;
520 520
521 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 521 std::unique_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
522 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 522 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
523 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 523 std::unique_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
524 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 524 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
525 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 525 std::unique_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
526 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); 526 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
527 527
528 r1_w1->SetCapture(); 528 r1_w1->SetCapture();
529 529
530 ui::test::EventGenerator& generator = GetEventGenerator(); 530 ui::test::EventGenerator& generator = GetEventGenerator();
531 generator.MoveMouseToCenterOf(r2_w1.get()); 531 generator.MoveMouseToCenterOf(r2_w1.get());
532 EXPECT_EQ(gfx::Point(1060, 60).ToString(), 532 EXPECT_EQ(gfx::Point(1060, 60).ToString(),
533 generator.current_location().ToString()); 533 generator.current_location().ToString());
534 534
535 EventLocationHandler location_handler; 535 EventLocationHandler location_handler;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // Verifies if the mouse event arrives to the window even when the window 584 // Verifies if the mouse event arrives to the window even when the window
585 // moves to another root in a pre-target handler. See: crbug.com/157583 585 // moves to another root in a pre-target handler. See: crbug.com/157583
586 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) { 586 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
587 if (!SupportsMultipleDisplays()) 587 if (!SupportsMultipleDisplays())
588 return; 588 return;
589 589
590 UpdateDisplay("1000x600,600x400"); 590 UpdateDisplay("1000x600,600x400");
591 591
592 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 592 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
593 aura::test::EventCountDelegate delegate; 593 aura::test::EventCountDelegate delegate;
594 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( 594 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
595 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 595 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
596 MoveWindowByClickEventHandler event_handler(window.get()); 596 MoveWindowByClickEventHandler event_handler(window.get());
597 window->AddPreTargetHandler(&event_handler); 597 window->AddPreTargetHandler(&event_handler);
598 598
599 ui::test::EventGenerator& event_generator(GetEventGenerator()); 599 ui::test::EventGenerator& event_generator(GetEventGenerator());
600 600
601 event_generator.MoveMouseToCenterOf(window.get()); 601 event_generator.MoveMouseToCenterOf(window.get());
602 event_generator.ClickLeftButton(); 602 event_generator.ClickLeftButton();
603 // Both mouse pressed and released arrive at the window and its delegate. 603 // Both mouse pressed and released arrive at the window and its delegate.
604 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); 604 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 generator.ReleaseLeftButton(); 929 generator.ReleaseLeftButton();
930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset());
931 931
932 generator.MoveMouseTo(400, 150); 932 generator.MoveMouseTo(400, 150);
933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset());
934 934
935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
936 } 936 }
937 937
938 } // namespace ash 938 } // namespace ash
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_image_view.h ('k') | ash/first_run/desktop_cleaner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698