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

Side by Side Diff: ash/system/overview/overview_button_tray_unittest.cc

Issue 308683002: Move MaximizeModeWindowManager to the controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 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/system/overview/overview_button_tray.cc ('k') | ash/test/shell_test_api.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/overview/overview_button_tray.h" 5 #include "ash/system/overview/overview_button_tray.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_types.h" 9 #include "ash/shelf/shelf_types.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/system/status_area_widget.h" 12 #include "ash/system/status_area_widget.h"
13 #include "ash/system/user/login_status.h" 13 #include "ash/system/user/login_status.h"
14 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
15 #include "ash/test/status_area_widget_test_helper.h" 15 #include "ash/test/status_area_widget_test_helper.h"
16 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
16 #include "ash/wm/overview/window_selector_controller.h" 17 #include "ash/wm/overview/window_selector_controller.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "ui/events/event.h" 19 #include "ui/events/event.h"
19 #include "ui/events/event_constants.h" 20 #include "ui/events/event_constants.h"
20 #include "ui/events/gestures/gesture_types.h" 21 #include "ui/events/gestures/gesture_types.h"
21 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
22 23
23 namespace ash { 24 namespace ash {
24 25
25 namespace { 26 namespace {
(...skipping 27 matching lines...) Expand all
53 // Ensures that creation doesn't cause any crashes and adds the image icon. 54 // Ensures that creation doesn't cause any crashes and adds the image icon.
54 TEST_F(OverviewButtonTrayTest, BasicConstruction) { 55 TEST_F(OverviewButtonTrayTest, BasicConstruction) {
55 EXPECT_TRUE(GetImageView(GetTray()) != NULL); 56 EXPECT_TRUE(GetImageView(GetTray()) != NULL);
56 } 57 }
57 58
58 // Test that maximize mode toggle changes visibility. 59 // Test that maximize mode toggle changes visibility.
59 // OverviewButtonTray should only be visible when MaximizeMode is enabled. 60 // OverviewButtonTray should only be visible when MaximizeMode is enabled.
60 // By default the system should not have MaximizeMode enabled. 61 // By default the system should not have MaximizeMode enabled.
61 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { 62 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) {
62 ASSERT_FALSE(GetTray()->visible()); 63 ASSERT_FALSE(GetTray()->visible());
63 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 64 Shell::GetInstance()->maximize_mode_controller()->
65 EnableMaximizeModeWindowManager(true);
64 EXPECT_TRUE(GetTray()->visible()); 66 EXPECT_TRUE(GetTray()->visible());
65 67
66 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 68 Shell::GetInstance()->maximize_mode_controller()->
69 EnableMaximizeModeWindowManager(false);
67 EXPECT_FALSE(GetTray()->visible()); 70 EXPECT_FALSE(GetTray()->visible());
68 } 71 }
69 72
70 // Tests that activating this control brings up window selection mode. 73 // Tests that activating this control brings up window selection mode.
71 TEST_F(OverviewButtonTrayTest, PerformAction) { 74 TEST_F(OverviewButtonTrayTest, PerformAction) {
72 ASSERT_FALSE(Shell::GetInstance()->window_selector_controller()-> 75 ASSERT_FALSE(Shell::GetInstance()->window_selector_controller()->
73 IsSelecting()); 76 IsSelecting());
74 77
75 // Overview Mode only works when there is a window 78 // Overview Mode only works when there is a window
76 scoped_ptr<aura::Window> window( 79 scoped_ptr<aura::Window> window(
77 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 80 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
78 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), 81 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(),
79 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f), 0); 82 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f), 0);
80 GetTray()->PerformAction(tap); 83 GetTray()->PerformAction(tap);
81 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> 84 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()->
82 IsSelecting()); 85 IsSelecting());
83 } 86 }
84 87
85 // Tests that a second OverviewButtonTray has been created, and only shows 88 // Tests that a second OverviewButtonTray has been created, and only shows
86 // when MaximizeMode has been enabled, when we are using multiple displays. 89 // when MaximizeMode has been enabled, when we are using multiple displays.
87 // By default the DisplayManger is in extended mode. 90 // By default the DisplayManger is in extended mode.
88 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { 91 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) {
89 if (!SupportsMultipleDisplays()) 92 if (!SupportsMultipleDisplays())
90 return; 93 return;
91 94
92 UpdateDisplay("400x400,200x200"); 95 UpdateDisplay("400x400,200x200");
93 EXPECT_FALSE(GetTray()->visible()); 96 EXPECT_FALSE(GetTray()->visible());
94 EXPECT_FALSE(GetSecondaryTray()->visible()); 97 EXPECT_FALSE(GetSecondaryTray()->visible());
95 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 98 Shell::GetInstance()->maximize_mode_controller()->
99 EnableMaximizeModeWindowManager(true);
96 EXPECT_TRUE(GetTray()->visible()); 100 EXPECT_TRUE(GetTray()->visible());
97 EXPECT_TRUE(GetSecondaryTray()->visible()); 101 EXPECT_TRUE(GetSecondaryTray()->visible());
98 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 102 Shell::GetInstance()->maximize_mode_controller()->
103 EnableMaximizeModeWindowManager(false);
99 } 104 }
100 105
101 // Tests if Maximize Mode is enabled before a secondary display is attached 106 // Tests if Maximize Mode is enabled before a secondary display is attached
102 // that the second OverviewButtonTray should be created in a visible state. 107 // that the second OverviewButtonTray should be created in a visible state.
103 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { 108 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) {
104 if (!SupportsMultipleDisplays()) 109 if (!SupportsMultipleDisplays())
105 return; 110 return;
106 111
107 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 112 Shell::GetInstance()->maximize_mode_controller()->
113 EnableMaximizeModeWindowManager(true);
108 UpdateDisplay("400x400,200x200"); 114 UpdateDisplay("400x400,200x200");
109 EXPECT_TRUE(GetSecondaryTray()->visible()); 115 EXPECT_TRUE(GetSecondaryTray()->visible());
110 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 116 Shell::GetInstance()->maximize_mode_controller()->
117 EnableMaximizeModeWindowManager(false);
111 } 118 }
112 119
113 // Tests that the tray loses visibility when a user logs out, and that it 120 // Tests that the tray loses visibility when a user logs out, and that it
114 // regains visibility when a user logs back in. 121 // regains visibility when a user logs back in.
115 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { 122 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
116 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 123 Shell::GetInstance()->maximize_mode_controller()->
124 EnableMaximizeModeWindowManager(true);
117 SetUserLoggedIn(false); 125 SetUserLoggedIn(false);
118 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE); 126 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE);
119 EXPECT_FALSE(GetTray()->visible()); 127 EXPECT_FALSE(GetTray()->visible());
120 SetUserLoggedIn(true); 128 SetUserLoggedIn(true);
121 SetSessionStarted(true); 129 SetSessionStarted(true);
122 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER); 130 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER);
123 EXPECT_TRUE(GetTray()->visible()); 131 EXPECT_TRUE(GetTray()->visible());
124 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 132 Shell::GetInstance()->maximize_mode_controller()->
133 EnableMaximizeModeWindowManager(false);
125 } 134 }
126 135
127 } // namespace ash 136 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/overview/overview_button_tray.cc ('k') | ash/test/shell_test_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698