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

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

Issue 2234033002: mash: Remove WorkspaceLayoutManagerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove WmRootWindowControllerObserver::OnFullscreenStateChanged; use ShellObserver. Created 4 years, 4 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/mus/root_window_controller.cc ('k') | ash/root_window_controller.cc » ('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/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/shell_observer.h"
10 #include "ash/common/wm/fullscreen_window_finder.h" 11 #include "ash/common/wm/fullscreen_window_finder.h"
11 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/wm_event.h" 13 #include "ash/common/wm/wm_event.h"
13 #include "ash/common/wm/wm_screen_util.h" 14 #include "ash/common/wm/wm_screen_util.h"
14 #include "ash/common/wm_root_window_controller_observer.h" 15 #include "ash/common/wm_shell.h"
15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" 16 #include "ash/mus/bridge/wm_root_window_controller_mus.h"
16 #include "ash/mus/bridge/wm_window_mus.h" 17 #include "ash/mus/bridge/wm_window_mus.h"
17 #include "ash/mus/bridge/wm_window_mus_test_api.h" 18 #include "ash/mus/bridge/wm_window_mus_test_api.h"
18 #include "ash/mus/test/wm_test_base.h" 19 #include "ash/mus/test/wm_test_base.h"
19 #include "base/run_loop.h" 20 #include "base/run_loop.h"
20 #include "services/ui/public/cpp/tests/test_window.h" 21 #include "services/ui/public/cpp/tests/test_window.h"
21 #include "ui/display/display.h" 22 #include "ui/display/display.h"
22 23
23 namespace ash { 24 namespace ash {
24 namespace mus { 25 namespace mus {
(...skipping 16 matching lines...) Expand all
41 return true; 42 return true;
42 } 43 }
43 44
44 private: 45 private:
45 const gfx::Rect initial_bounds_; 46 const gfx::Rect initial_bounds_;
46 47
47 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); 48 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView);
48 }; 49 };
49 */ 50 */
50 51
51 class FullscreenObserver : public WmRootWindowControllerObserver { 52 class FullscreenObserver : public ShellObserver {
52 public: 53 public:
53 explicit FullscreenObserver(WmRootWindowController* root_window_controller) 54 FullscreenObserver() : call_count_(0), is_fullscreen_(false) {
54 : root_window_controller_(root_window_controller), 55 WmShell::Get()->AddShellObserver(this);
55 call_count_(0),
56 is_fullscreen_(false) {
57 root_window_controller_->AddObserver(this);
58 } 56 }
59 57
60 ~FullscreenObserver() override { 58 ~FullscreenObserver() override { WmShell::Get()->RemoveShellObserver(this); }
61 root_window_controller_->RemoveObserver(this);
62 }
63 59
64 void OnFullscreenStateChanged(bool is_fullscreen) override { 60 void OnFullscreenStateChanged(bool is_fullscreen,
61 WmWindow* root_window) override {
65 call_count_++; 62 call_count_++;
66 is_fullscreen_ = is_fullscreen; 63 is_fullscreen_ = is_fullscreen;
67 } 64 }
68 65
69 int call_count() const { return call_count_; } 66 int call_count() const { return call_count_; }
70 67
71 bool is_fullscreen() const { return is_fullscreen_; } 68 bool is_fullscreen() const { return is_fullscreen_; }
72 69
73 private: 70 private:
74 WmRootWindowController* root_window_controller_;
75 int call_count_; 71 int call_count_;
76 bool is_fullscreen_; 72 bool is_fullscreen_;
77 73
78 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver); 74 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver);
79 }; 75 };
80 76
81 } // namespace 77 } // namespace
82 78
83 using WorkspaceLayoutManagerTest = WmTestBase; 79 using WorkspaceLayoutManagerTest = WmTestBase;
84 80
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 window->bounds().ToString()); 445 window->bounds().ToString());
450 446
451 // Directly setting the bounds triggers a slightly different code path. Verify 447 // Directly setting the bounds triggers a slightly different code path. Verify
452 // that too. 448 // that too.
453 WmWindowMus::Get(window)->SetBounds(window_bounds); 449 WmWindowMus::Get(window)->SetBounds(window_bounds);
454 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 450 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
455 window->bounds().ToString()); 451 window->bounds().ToString());
456 } 452 }
457 453
458 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { 454 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
459 FullscreenObserver observer( 455 FullscreenObserver observer;
460 WmWindowMus::Get(GetPrimaryRootWindow())->GetRootWindowController());
461 ui::Window* window1 = CreateTestWindow(gfx::Rect(1, 2, 30, 40)); 456 ui::Window* window1 = CreateTestWindow(gfx::Rect(1, 2, 30, 40));
462 ui::Window* window2 = CreateTestWindow(gfx::Rect(1, 2, 30, 40)); 457 ui::Window* window2 = CreateTestWindow(gfx::Rect(1, 2, 30, 40));
463 wm::WindowState* window_state1 = WmWindowMus::Get(window1)->GetWindowState(); 458 wm::WindowState* window_state1 = WmWindowMus::Get(window1)->GetWindowState();
464 wm::WindowState* window_state2 = WmWindowMus::Get(window2)->GetWindowState(); 459 wm::WindowState* window_state2 = WmWindowMus::Get(window2)->GetWindowState();
465 window_state2->Activate(); 460 window_state2->Activate();
466 461
467 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 462 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
468 window_state2->OnWMEvent(&toggle_fullscreen_event); 463 window_state2->OnWMEvent(&toggle_fullscreen_event);
469 EXPECT_EQ(1, observer.call_count()); 464 EXPECT_EQ(1, observer.call_count());
470 EXPECT_TRUE(observer.is_fullscreen()); 465 EXPECT_TRUE(observer.is_fullscreen());
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 occluded_window_bounds.width(), 1092 occluded_window_bounds.width(),
1098 occluded_window_bounds.height()).ToString(), 1093 occluded_window_bounds.height()).ToString(),
1099 window->bounds().ToString()); 1094 window->bounds().ToString());
1100 HideKeyboard(); 1095 HideKeyboard();
1101 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1096 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1102 } 1097 }
1103 */ 1098 */
1104 1099
1105 } // namespace mus 1100 } // namespace mus
1106 } // namespace ash 1101 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/root_window_controller.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698