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

Side by Side Diff: ash/shell_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/shell_init_params.h ('k') | ash/sticky_keys/sticky_keys_controller.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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 SessionStateDelegate* delegate = 344 SessionStateDelegate* delegate =
345 Shell::GetInstance()->session_state_delegate(); 345 Shell::GetInstance()->session_state_delegate();
346 delegate->LockScreen(); 346 delegate->LockScreen();
347 EXPECT_TRUE(delegate->IsScreenLocked()); 347 EXPECT_TRUE(delegate->IsScreenLocked());
348 delegate->UnlockScreen(); 348 delegate->UnlockScreen();
349 EXPECT_FALSE(delegate->IsScreenLocked()); 349 EXPECT_FALSE(delegate->IsScreenLocked());
350 } 350 }
351 351
352 TEST_F(ShellTest, LockScreenClosesActiveMenu) { 352 TEST_F(ShellTest, LockScreenClosesActiveMenu) {
353 SimpleMenuDelegate menu_delegate; 353 SimpleMenuDelegate menu_delegate;
354 scoped_ptr<ui::SimpleMenuModel> menu_model( 354 std::unique_ptr<ui::SimpleMenuModel> menu_model(
355 new ui::SimpleMenuModel(&menu_delegate)); 355 new ui::SimpleMenuModel(&menu_delegate));
356 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); 356 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item"));
357 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()-> 357 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()->
358 wallpaper_controller()->widget(); 358 wallpaper_controller()->widget();
359 scoped_ptr<views::MenuRunner> menu_runner( 359 std::unique_ptr<views::MenuRunner> menu_runner(
360 new views::MenuRunner(menu_model.get(), views::MenuRunner::CONTEXT_MENU)); 360 new views::MenuRunner(menu_model.get(), views::MenuRunner::CONTEXT_MENU));
361 361
362 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed 362 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed
363 // command will fire, check the menu state and ensure the nested menu loop 363 // command will fire, check the menu state and ensure the nested menu loop
364 // is exited so that the test will terminate. 364 // is exited so that the test will terminate.
365 base::ThreadTaskRunnerHandle::Get()->PostTask( 365 base::ThreadTaskRunnerHandle::Get()->PostTask(
366 FROM_HERE, base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed, 366 FROM_HERE, base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed,
367 base::Unretained(this))); 367 base::Unretained(this)));
368 368
369 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, 369 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 Shell::GetPrimaryRootWindowController()-> 439 Shell::GetPrimaryRootWindowController()->
440 GetShelfLayoutManager()->visibility_state()); 440 GetShelfLayoutManager()->visibility_state());
441 441
442 // Clean up. 442 // Clean up.
443 widget->Close(); 443 widget->Close();
444 } 444 }
445 445
446 // Various assertions around SetShelfAutoHideBehavior() and 446 // Various assertions around SetShelfAutoHideBehavior() and
447 // GetShelfAutoHideBehavior(). 447 // GetShelfAutoHideBehavior().
448 TEST_F(ShellTest, ToggleAutoHide) { 448 TEST_F(ShellTest, ToggleAutoHide) {
449 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 449 std::unique_ptr<aura::Window> window(new aura::Window(NULL));
450 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 450 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
451 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 451 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
452 window->Init(ui::LAYER_TEXTURED); 452 window->Init(ui::LAYER_TEXTURED);
453 ParentWindowInPrimaryRootWindow(window.get()); 453 ParentWindowInPrimaryRootWindow(window.get());
454 window->Show(); 454 window->Show();
455 wm::ActivateWindow(window.get()); 455 wm::ActivateWindow(window.get());
456 456
457 Shell* shell = Shell::GetInstance(); 457 Shell* shell = Shell::GetInstance();
458 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 458 aura::Window* root_window = Shell::GetPrimaryRootWindow();
459 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 459 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as 511 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as
512 // everything is ok, we won't crash. If there is a bug, window's destructor will 512 // everything is ok, we won't crash. If there is a bug, window's destructor will
513 // notify some deleted object (say VideoDetector or ActivationController) and 513 // notify some deleted object (say VideoDetector or ActivationController) and
514 // this will crash. 514 // this will crash.
515 class ShellTest2 : public test::AshTestBase { 515 class ShellTest2 : public test::AshTestBase {
516 public: 516 public:
517 ShellTest2() {} 517 ShellTest2() {}
518 ~ShellTest2() override {} 518 ~ShellTest2() override {}
519 519
520 protected: 520 protected:
521 scoped_ptr<aura::Window> window_; 521 std::unique_ptr<aura::Window> window_;
522 522
523 private: 523 private:
524 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 524 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
525 }; 525 };
526 526
527 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 527 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
528 window_.reset(new aura::Window(NULL)); 528 window_.reset(new aura::Window(NULL));
529 window_->Init(ui::LAYER_NOT_DRAWN); 529 window_->Init(ui::LAYER_NOT_DRAWN);
530 } 530 }
531 531
532 } // namespace ash 532 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell_init_params.h ('k') | ash/sticky_keys/sticky_keys_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698