| OLD | NEW |
| 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/chromeos/rotation/tray_rotation_lock.h" | 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Tests that when the tray view is initially created, that it is created | 97 // Tests that when the tray view is initially created, that it is created |
| 98 // not visible. | 98 // not visible. |
| 99 TEST_F(TrayRotationLockTest, CreateTrayView) { | 99 TEST_F(TrayRotationLockTest, CreateTrayView) { |
| 100 EXPECT_FALSE(tray_view()->visible()); | 100 EXPECT_FALSE(tray_view()->visible()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Tests that when the tray view is created, while MaximizeMode is active, that | 103 // Tests that when the tray view is created, while MaximizeMode is active, that |
| 104 // it is not visible. | 104 // it is not visible. |
| 105 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { | 105 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { |
| 106 TearDownViews(); | 106 TearDownViews(); |
| 107 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 107 Shell::GetInstance()->maximize_mode_controller()-> |
| 108 EnableMaximizeModeWindowManager(true); |
| 108 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 109 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 109 EXPECT_FALSE(tray_view()->visible()); | 110 EXPECT_FALSE(tray_view()->visible()); |
| 110 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 111 Shell::GetInstance()->maximize_mode_controller()-> |
| 112 EnableMaximizeModeWindowManager(false); |
| 111 } | 113 } |
| 112 | 114 |
| 113 // Tests that when the tray view is created, while MaximizeMode is active, and | 115 // Tests that when the tray view is created, while MaximizeMode is active, and |
| 114 // rotation is locked, that it is visible. | 116 // rotation is locked, that it is visible. |
| 115 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { | 117 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { |
| 116 TearDownViews(); | 118 TearDownViews(); |
| 117 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 119 Shell::GetInstance()->maximize_mode_controller()-> |
| 120 EnableMaximizeModeWindowManager(true); |
| 118 Shell::GetInstance()-> maximize_mode_controller()->set_rotation_locked(true); | 121 Shell::GetInstance()-> maximize_mode_controller()->set_rotation_locked(true); |
| 119 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 122 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 120 EXPECT_TRUE(tray_view()->visible()); | 123 EXPECT_TRUE(tray_view()->visible()); |
| 121 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 124 Shell::GetInstance()->maximize_mode_controller()-> |
| 125 EnableMaximizeModeWindowManager(false); |
| 122 } | 126 } |
| 123 | 127 |
| 124 // Tests that the enabling of MaximizeMode affects a previously created tray | 128 // Tests that the enabling of MaximizeMode affects a previously created tray |
| 125 // view, changing the visibility. | 129 // view, changing the visibility. |
| 126 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { | 130 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { |
| 127 TearDownViews(); | 131 TearDownViews(); |
| 128 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 132 Shell::GetInstance()->maximize_mode_controller()-> |
| 133 EnableMaximizeModeWindowManager(true); |
| 129 Shell::GetInstance()-> maximize_mode_controller()->set_rotation_locked(true); | 134 Shell::GetInstance()-> maximize_mode_controller()->set_rotation_locked(true); |
| 130 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 135 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 131 EXPECT_TRUE(tray_view()->visible()); | 136 EXPECT_TRUE(tray_view()->visible()); |
| 132 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 137 Shell::GetInstance()->maximize_mode_controller()-> |
| 138 EnableMaximizeModeWindowManager(false); |
| 133 EXPECT_FALSE(tray_view()->visible()); | 139 EXPECT_FALSE(tray_view()->visible()); |
| 134 } | 140 } |
| 135 | 141 |
| 136 // Tests that the when the tray view is created for a secondary display, that | 142 // Tests that the when the tray view is created for a secondary display, that |
| 137 // it is not visible, and that MaximizeMode does not affect visibility. | 143 // it is not visible, and that MaximizeMode does not affect visibility. |
| 138 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { | 144 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { |
| 139 if (!SupportsMultipleDisplays()) | 145 if (!SupportsMultipleDisplays()) |
| 140 return; | 146 return; |
| 141 UpdateDisplay("400x400,200x200"); | 147 UpdateDisplay("400x400,200x200"); |
| 142 | 148 |
| 143 SetUpForStatusAreaWidget( | 149 SetUpForStatusAreaWidget( |
| 144 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); | 150 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); |
| 145 EXPECT_FALSE(tray_view()->visible()); | 151 EXPECT_FALSE(tray_view()->visible()); |
| 146 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 152 Shell::GetInstance()->maximize_mode_controller()-> |
| 153 EnableMaximizeModeWindowManager(true); |
| 147 EXPECT_FALSE(tray_view()->visible()); | 154 EXPECT_FALSE(tray_view()->visible()); |
| 148 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 155 Shell::GetInstance()->maximize_mode_controller()-> |
| 156 EnableMaximizeModeWindowManager(false); |
| 149 EXPECT_FALSE(tray_view()->visible()); | 157 EXPECT_FALSE(tray_view()->visible()); |
| 150 } | 158 } |
| 151 | 159 |
| 152 // Tests that when the default view is initially created, that it is created | 160 // Tests that when the default view is initially created, that it is created |
| 153 // not visible. | 161 // not visible. |
| 154 TEST_F(TrayRotationLockTest, CreateDefaultView) { | 162 TEST_F(TrayRotationLockTest, CreateDefaultView) { |
| 155 EXPECT_FALSE(default_view()->visible()); | 163 EXPECT_FALSE(default_view()->visible()); |
| 156 } | 164 } |
| 157 | 165 |
| 158 // Tests that when the default view is created, while MaximizeMode is active, | 166 // Tests that when the default view is created, while MaximizeMode is active, |
| 159 // that it is visible. | 167 // that it is visible. |
| 160 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { | 168 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { |
| 161 TearDownViews(); | 169 TearDownViews(); |
| 162 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 170 Shell::GetInstance()->maximize_mode_controller()-> |
| 171 EnableMaximizeModeWindowManager(true); |
| 163 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 172 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 164 EXPECT_TRUE(default_view()->visible()); | 173 EXPECT_TRUE(default_view()->visible()); |
| 165 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 174 Shell::GetInstance()->maximize_mode_controller()-> |
| 175 EnableMaximizeModeWindowManager(false); |
| 166 } | 176 } |
| 167 | 177 |
| 168 // Tests that the enabling of MaximizeMode affects a previously created default | 178 // Tests that the enabling of MaximizeMode affects a previously created default |
| 169 // view, changing the visibility. | 179 // view, changing the visibility. |
| 170 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { | 180 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { |
| 171 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 181 Shell::GetInstance()->maximize_mode_controller()-> |
| 182 EnableMaximizeModeWindowManager(true); |
| 172 EXPECT_TRUE(default_view()->visible()); | 183 EXPECT_TRUE(default_view()->visible()); |
| 173 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 184 Shell::GetInstance()->maximize_mode_controller()-> |
| 185 EnableMaximizeModeWindowManager(false); |
| 174 EXPECT_FALSE(default_view()->visible()); | 186 EXPECT_FALSE(default_view()->visible()); |
| 175 } | 187 } |
| 176 | 188 |
| 177 // Tests that no default view is created when the target is a secondary | 189 // Tests that no default view is created when the target is a secondary |
| 178 // display. | 190 // display. |
| 179 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { | 191 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { |
| 180 if (!SupportsMultipleDisplays()) | 192 if (!SupportsMultipleDisplays()) |
| 181 return; | 193 return; |
| 182 UpdateDisplay("400x400,200x200"); | 194 UpdateDisplay("400x400,200x200"); |
| 183 | 195 |
| 184 TearDownViews(); | 196 TearDownViews(); |
| 185 SetUpForStatusAreaWidget( | 197 SetUpForStatusAreaWidget( |
| 186 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); | 198 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); |
| 187 EXPECT_EQ(NULL, default_view()); | 199 EXPECT_EQ(NULL, default_view()); |
| 188 } | 200 } |
| 189 | 201 |
| 190 // Tests that activating the default view causes the display to have its | 202 // Tests that activating the default view causes the display to have its |
| 191 // rotation locked, and that the tray view becomes visible. | 203 // rotation locked, and that the tray view becomes visible. |
| 192 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { | 204 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { |
| 193 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> | 205 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> |
| 194 maximize_mode_controller(); | 206 maximize_mode_controller(); |
| 195 ASSERT_FALSE(maximize_mode_controller->rotation_locked()); | 207 ASSERT_FALSE(maximize_mode_controller->rotation_locked()); |
| 196 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 208 Shell::GetInstance()->maximize_mode_controller()-> |
| 209 EnableMaximizeModeWindowManager(true); |
| 197 ASSERT_FALSE(tray_view()->visible()); | 210 ASSERT_FALSE(tray_view()->visible()); |
| 198 | 211 |
| 199 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 212 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
| 200 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f), 0); | 213 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f), 0); |
| 201 default_view()->OnGestureEvent(&tap); | 214 default_view()->OnGestureEvent(&tap); |
| 202 EXPECT_TRUE(maximize_mode_controller->rotation_locked()); | 215 EXPECT_TRUE(maximize_mode_controller->rotation_locked()); |
| 203 EXPECT_TRUE(tray_view()->visible()); | 216 EXPECT_TRUE(tray_view()->visible()); |
| 204 | 217 |
| 205 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 218 Shell::GetInstance()->maximize_mode_controller()-> |
| 219 EnableMaximizeModeWindowManager(false); |
| 206 } | 220 } |
| 207 | 221 |
| 208 } // namespace ash | 222 } // namespace ash |
| OLD | NEW |