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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager_unittest.cc

Issue 681913002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/display/display_layout.h" 9 #include "ash/display/display_layout.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 28 matching lines...) Expand all
39 #include "ui/wm/core/window_util.h" 39 #include "ui/wm/core/window_util.h"
40 40
41 namespace ash { 41 namespace ash {
42 namespace { 42 namespace {
43 43
44 class MaximizeDelegateView : public views::WidgetDelegateView { 44 class MaximizeDelegateView : public views::WidgetDelegateView {
45 public: 45 public:
46 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) 46 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds)
47 : initial_bounds_(initial_bounds) { 47 : initial_bounds_(initial_bounds) {
48 } 48 }
49 virtual ~MaximizeDelegateView() {} 49 ~MaximizeDelegateView() override {}
50 50
51 virtual bool GetSavedWindowPlacement( 51 bool GetSavedWindowPlacement(const views::Widget* widget,
52 const views::Widget* widget, 52 gfx::Rect* bounds,
53 gfx::Rect* bounds, 53 ui::WindowShowState* show_state) const override {
54 ui::WindowShowState* show_state) const override {
55 *bounds = initial_bounds_; 54 *bounds = initial_bounds_;
56 *show_state = ui::SHOW_STATE_MAXIMIZED; 55 *show_state = ui::SHOW_STATE_MAXIMIZED;
57 return true; 56 return true;
58 } 57 }
59 58
60 private: 59 private:
61 const gfx::Rect initial_bounds_; 60 const gfx::Rect initial_bounds_;
62 61
63 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); 62 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView);
64 }; 63 };
65 64
66 class TestShellObserver : public ShellObserver { 65 class TestShellObserver : public ShellObserver {
67 public: 66 public:
68 TestShellObserver() : call_count_(0), 67 TestShellObserver() : call_count_(0),
69 is_fullscreen_(false) { 68 is_fullscreen_(false) {
70 Shell::GetInstance()->AddShellObserver(this); 69 Shell::GetInstance()->AddShellObserver(this);
71 } 70 }
72 71
73 virtual ~TestShellObserver() { 72 ~TestShellObserver() override {
74 Shell::GetInstance()->RemoveShellObserver(this); 73 Shell::GetInstance()->RemoveShellObserver(this);
75 } 74 }
76 75
77 virtual void OnFullscreenStateChanged(bool is_fullscreen, 76 void OnFullscreenStateChanged(bool is_fullscreen,
78 aura::Window* root_window) override { 77 aura::Window* root_window) override {
79 call_count_++; 78 call_count_++;
80 is_fullscreen_ = is_fullscreen; 79 is_fullscreen_ = is_fullscreen;
81 } 80 }
82 81
83 int call_count() const { 82 int call_count() const {
84 return call_count_; 83 return call_count_;
85 } 84 }
86 85
87 bool is_fullscreen() const { 86 bool is_fullscreen() const {
88 return is_fullscreen_; 87 return is_fullscreen_;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. 305 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver.
307 // This code mirrors what BrowserFrameAsh does. In particular when this code 306 // This code mirrors what BrowserFrameAsh does. In particular when this code
308 // sees the window was maximized it changes the bounds of a secondary 307 // sees the window was maximized it changes the bounds of a secondary
309 // window. The secondary window mirrors the status window. 308 // window. The secondary window mirrors the status window.
310 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { 309 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
311 public: 310 public:
312 DontClobberRestoreBoundsWindowObserver() : window_(NULL) {} 311 DontClobberRestoreBoundsWindowObserver() : window_(NULL) {}
313 312
314 void set_window(aura::Window* window) { window_ = window; } 313 void set_window(aura::Window* window) { window_ = window; }
315 314
316 virtual void OnWindowPropertyChanged(aura::Window* window, 315 void OnWindowPropertyChanged(aura::Window* window,
317 const void* key, 316 const void* key,
318 intptr_t old) override { 317 intptr_t old) override {
319 if (!window_) 318 if (!window_)
320 return; 319 return;
321 320
322 if (wm::GetWindowState(window)->IsMaximized()) { 321 if (wm::GetWindowState(window)->IsMaximized()) {
323 aura::Window* w = window_; 322 aura::Window* w = window_;
324 window_ = NULL; 323 window_ = NULL;
325 324
326 gfx::Rect shelf_bounds(Shell::GetPrimaryRootWindowController()-> 325 gfx::Rect shelf_bounds(Shell::GetPrimaryRootWindowController()->
327 GetShelfLayoutManager()->GetIdealBounds()); 326 GetShelfLayoutManager()->GetIdealBounds());
328 const gfx::Rect& window_bounds(w->bounds()); 327 const gfx::Rect& window_bounds(w->bounds());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 EXPECT_EQ(6, observer.call_count()); 521 EXPECT_EQ(6, observer.call_count());
523 EXPECT_FALSE(observer.is_fullscreen()); 522 EXPECT_FALSE(observer.is_fullscreen());
524 } 523 }
525 524
526 // Following "Solo" tests were originally written for BaseLayoutManager. 525 // Following "Solo" tests were originally written for BaseLayoutManager.
527 namespace { 526 namespace {
528 527
529 class WorkspaceLayoutManagerSoloTest : public test::AshTestBase { 528 class WorkspaceLayoutManagerSoloTest : public test::AshTestBase {
530 public: 529 public:
531 WorkspaceLayoutManagerSoloTest() {} 530 WorkspaceLayoutManagerSoloTest() {}
532 virtual ~WorkspaceLayoutManagerSoloTest() {} 531 ~WorkspaceLayoutManagerSoloTest() override {}
533 532
534 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 533 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
535 return CreateTestWindowInShellWithBounds(bounds); 534 return CreateTestWindowInShellWithBounds(bounds);
536 } 535 }
537 536
538 private: 537 private:
539 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerSoloTest); 538 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerSoloTest);
540 }; 539 };
541 540
542 } // namespace 541 } // namespace
(...skipping 24 matching lines...) Expand all
567 } 566 }
568 567
569 // A WindowDelegate which sets the focus when the window 568 // A WindowDelegate which sets the focus when the window
570 // becomes visible. 569 // becomes visible.
571 class FocusDelegate : public aura::test::TestWindowDelegate { 570 class FocusDelegate : public aura::test::TestWindowDelegate {
572 public: 571 public:
573 FocusDelegate() 572 FocusDelegate()
574 : window_(NULL), 573 : window_(NULL),
575 show_state_(ui::SHOW_STATE_END) { 574 show_state_(ui::SHOW_STATE_END) {
576 } 575 }
577 virtual ~FocusDelegate() {} 576 ~FocusDelegate() override {}
578 577
579 void set_window(aura::Window* window) { window_ = window; } 578 void set_window(aura::Window* window) { window_ = window; }
580 579
581 // aura::test::TestWindowDelegate overrides: 580 // aura::test::TestWindowDelegate overrides:
582 virtual void OnWindowTargetVisibilityChanged(bool visible) override { 581 void OnWindowTargetVisibilityChanged(bool visible) override {
583 if (window_) { 582 if (window_) {
584 if (visible) 583 if (visible)
585 window_->Focus(); 584 window_->Focus();
586 show_state_ = window_->GetProperty(aura::client::kShowStateKey); 585 show_state_ = window_->GetProperty(aura::client::kShowStateKey);
587 } 586 }
588 } 587 }
589 588
590 ui::WindowShowState GetShowStateAndReset() { 589 ui::WindowShowState GetShowStateAndReset() {
591 ui::WindowShowState ret = show_state_; 590 ui::WindowShowState ret = show_state_;
592 show_state_ = ui::SHOW_STATE_END; 591 show_state_ = ui::SHOW_STATE_END;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); 780 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
782 } 781 }
783 782
784 // Following tests are written to test the backdrop functionality. 783 // Following tests are written to test the backdrop functionality.
785 784
786 namespace { 785 namespace {
787 786
788 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { 787 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
789 public: 788 public:
790 WorkspaceLayoutManagerBackdropTest() {} 789 WorkspaceLayoutManagerBackdropTest() {}
791 virtual ~WorkspaceLayoutManagerBackdropTest() {} 790 ~WorkspaceLayoutManagerBackdropTest() override {}
792 791
793 virtual void SetUp() override { 792 void SetUp() override {
794 test::AshTestBase::SetUp(); 793 test::AshTestBase::SetUp();
795 UpdateDisplay("800x600"); 794 UpdateDisplay("800x600");
796 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), 795 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
797 kShellWindowId_DefaultContainer); 796 kShellWindowId_DefaultContainer);
798 } 797 }
799 798
800 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 799 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
801 aura::Window* window = CreateTestWindowInShellWithBounds(bounds); 800 aura::Window* window = CreateTestWindowInShellWithBounds(bounds);
802 return window; 801 return window;
803 } 802 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 968 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
970 shelf_layout_manager->UpdateVisibilityState(); 969 shelf_layout_manager->UpdateVisibilityState();
971 970
972 EXPECT_GT(default_container()->children()[0]->bounds().height(), 971 EXPECT_GT(default_container()->children()[0]->bounds().height(),
973 reduced_bounds.height()); 972 reduced_bounds.height());
974 } 973 }
975 974
976 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { 975 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase {
977 public: 976 public:
978 WorkspaceLayoutManagerKeyboardTest() {} 977 WorkspaceLayoutManagerKeyboardTest() {}
979 virtual ~WorkspaceLayoutManagerKeyboardTest() {} 978 ~WorkspaceLayoutManagerKeyboardTest() override {}
980 979
981 virtual void SetUp() override { 980 void SetUp() override {
982 test::AshTestBase::SetUp(); 981 test::AshTestBase::SetUp();
983 UpdateDisplay("800x600"); 982 UpdateDisplay("800x600");
984 aura::Window* default_container = Shell::GetContainer( 983 aura::Window* default_container = Shell::GetContainer(
985 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); 984 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer);
986 layout_manager_ = static_cast<WorkspaceLayoutManager*>( 985 layout_manager_ = static_cast<WorkspaceLayoutManager*>(
987 default_container->layout_manager()); 986 default_container->layout_manager());
988 } 987 }
989 988
990 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 989 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
991 return CreateTestWindowInShellWithBounds(bounds); 990 return CreateTestWindowInShellWithBounds(bounds);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 gfx::Insets restore_work_area_insets_; 1040 gfx::Insets restore_work_area_insets_;
1042 gfx::Rect keyboard_bounds_; 1041 gfx::Rect keyboard_bounds_;
1043 WorkspaceLayoutManager* layout_manager_; 1042 WorkspaceLayoutManager* layout_manager_;
1044 1043
1045 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 1044 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest);
1046 }; 1045 };
1047 1046
1048 class FakeTextInputClient : public ui::DummyTextInputClient { 1047 class FakeTextInputClient : public ui::DummyTextInputClient {
1049 public: 1048 public:
1050 explicit FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} 1049 explicit FakeTextInputClient(gfx::NativeWindow window) : window_(window) {}
1051 virtual ~FakeTextInputClient() {} 1050 ~FakeTextInputClient() override {}
1052 1051
1053 virtual gfx::NativeWindow GetAttachedWindow() const override { 1052 gfx::NativeWindow GetAttachedWindow() const override { return window_; }
1054 return window_;
1055 }
1056 1053
1057 private: 1054 private:
1058 gfx::NativeWindow window_; 1055 gfx::NativeWindow window_;
1059 1056
1060 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient); 1057 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient);
1061 }; 1058 };
1062 1059
1063 // Tests that when a child window gains focus the top level window containing it 1060 // Tests that when a child window gains focus the top level window containing it
1064 // is resized to fit the remaining workspace area. 1061 // is resized to fit the remaining workspace area.
1065 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { 1062 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 occluded_window_bounds.width(), 1148 occluded_window_bounds.width(),
1152 occluded_window_bounds.height()).ToString(), 1149 occluded_window_bounds.height()).ToString(),
1153 window->bounds().ToString()); 1150 window->bounds().ToString());
1154 HideKeyboard(); 1151 HideKeyboard();
1155 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1152 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1156 1153
1157 Blur(&text_input_client); 1154 Blur(&text_input_client);
1158 } 1155 }
1159 1156
1160 } // namespace ash 1157 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.h ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698