| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/ui_scene_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/test/scoped_mock_time_message_loop_task_runner.h" | 10 #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 // Note: Fast-forwarding appears broken in conjunction with restarting timers. | 157 // Note: Fast-forwarding appears broken in conjunction with restarting timers. |
| 158 // In this test, we can fast-forward by the appropriate time interval, but in | 158 // In this test, we can fast-forward by the appropriate time interval, but in |
| 159 // other cases (until the bug is addressed), we could work around the problem | 159 // other cases (until the bug is addressed), we could work around the problem |
| 160 // by using FastForwardUntilNoTasksRemain() instead. | 160 // by using FastForwardUntilNoTasksRemain() instead. |
| 161 // See http://crbug.com/736558. | 161 // See http://crbug.com/736558. |
| 162 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(31)); | 162 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(31)); |
| 163 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); | 163 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 TEST_F(UiSceneManagerTest, ToastVisibility) { | 166 TEST_F(UiSceneManagerTest, ToastStateTransitions) { |
| 167 // Tests toast not showing when directly entering VR though WebVR | 167 // Tests toast not showing when directly entering VR though WebVR |
| 168 // presentation. | 168 // presentation. |
| 169 MakeManager(kNotInCct, kInWebVr); | 169 MakeManager(kNotInCct, kInWebVr); |
| 170 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); | 170 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 171 | 171 |
| 172 MakeManager(kNotInCct, kNotInWebVr); | 172 MakeManager(kNotInCct, kNotInWebVr); |
| 173 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); | 173 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 174 | 174 |
| 175 manager_->SetFullscreen(true); | 175 manager_->SetFullscreen(true); |
| 176 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); | 176 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); |
| 177 | 177 |
| 178 manager_->SetWebVrMode(true, true); | 178 manager_->SetWebVrMode(true, true); |
| 179 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); | 179 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); |
| 180 | 180 |
| 181 manager_->SetWebVrMode(false, false); | 181 manager_->SetWebVrMode(false, false); |
| 182 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); | 182 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 183 | 183 |
| 184 manager_->SetFullscreen(false); | 184 manager_->SetFullscreen(false); |
| 185 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); | 185 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 186 | 186 |
| 187 manager_->SetWebVrMode(true, false); | 187 manager_->SetWebVrMode(true, false); |
| 188 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); | 188 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 189 | 189 |
| 190 manager_->SetWebVrMode(false, true); | 190 manager_->SetWebVrMode(false, true); |
| 191 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 192 } |
| 193 |
| 194 TEST_F(UiSceneManagerTest, ToastTransience) { |
| 195 base::ScopedMockTimeMessageLoopTaskRunner task_runner_; |
| 196 |
| 197 MakeManager(kNotInCct, kNotInWebVr); |
| 198 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 199 |
| 200 manager_->SetFullscreen(true); |
| 191 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); | 201 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); |
| 202 task_runner_->FastForwardUntilNoTasksRemain(); |
| 203 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 204 |
| 205 manager_->SetWebVrMode(true, true); |
| 206 EXPECT_TRUE(IsVisible(kExclusiveScreenToast)); |
| 207 task_runner_->FastForwardUntilNoTasksRemain(); |
| 208 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 209 |
| 210 manager_->SetWebVrMode(false, false); |
| 211 EXPECT_FALSE(IsVisible(kExclusiveScreenToast)); |
| 192 } | 212 } |
| 193 | 213 |
| 194 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) { | 214 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) { |
| 195 // Button should be visible in cct. | 215 // Button should be visible in cct. |
| 196 MakeManager(kInCct, kNotInWebVr); | 216 MakeManager(kInCct, kNotInWebVr); |
| 197 EXPECT_TRUE(IsVisible(kCloseButton)); | 217 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 198 | 218 |
| 199 // Button should not be visible when not in cct or fullscreen. | 219 // Button should not be visible when not in cct or fullscreen. |
| 200 MakeManager(kNotInCct, kNotInWebVr); | 220 MakeManager(kNotInCct, kNotInWebVr); |
| 201 EXPECT_FALSE(IsVisible(kCloseButton)); | 221 EXPECT_FALSE(IsVisible(kCloseButton)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 290 |
| 271 manager_->SetIncognito(false); | 291 manager_->SetIncognito(false); |
| 272 | 292 |
| 273 { | 293 { |
| 274 SCOPED_TRACE("Exited Incognito"); | 294 SCOPED_TRACE("Exited Incognito"); |
| 275 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); | 295 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); |
| 276 } | 296 } |
| 277 } | 297 } |
| 278 | 298 |
| 279 TEST_F(UiSceneManagerTest, WebVrAutopresented) { | 299 TEST_F(UiSceneManagerTest, WebVrAutopresented) { |
| 300 base::ScopedMockTimeMessageLoopTaskRunner task_runner_; |
| 301 |
| 280 MakeAutoPresentedManager(); | 302 MakeAutoPresentedManager(); |
| 281 | |
| 282 manager_->SetWebVrSecureOrigin(true); | 303 manager_->SetWebVrSecureOrigin(true); |
| 283 | 304 |
| 284 // Initially, we should only show the splash screen. | 305 // Initially, we should only show the splash screen. |
| 285 VerifyElementsVisible("Initial", | 306 VerifyElementsVisible("Initial", |
| 286 std::set<UiElementDebugId>{kSplashScreenIcon}); | 307 std::set<UiElementDebugId>{kSplashScreenIcon}); |
| 287 | 308 |
| 288 // Enter WebVR with autopresentation. | 309 // Enter WebVR with autopresentation. |
| 289 manager_->SetWebVrMode(true, false); | 310 manager_->SetWebVrMode(true, false); |
| 290 | |
| 291 VerifyElementsVisible("Autopresented", | 311 VerifyElementsVisible("Autopresented", |
| 292 std::set<UiElementDebugId>{kTransientUrlBar}); | 312 std::set<UiElementDebugId>{kTransientUrlBar}); |
| 313 |
| 314 // Make sure the transient URL bar times out. |
| 315 task_runner_->FastForwardUntilNoTasksRemain(); |
| 316 EXPECT_FALSE(IsVisible(kTransientUrlBar)); |
| 293 } | 317 } |
| 294 | 318 |
| 295 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { | 319 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { |
| 296 std::set<UiElementDebugId> visible_in_fullscreen = { | 320 std::set<UiElementDebugId> visible_in_fullscreen = { |
| 297 kContentQuad, kCloseButton, kBackplane, | 321 kContentQuad, kCloseButton, kBackplane, |
| 298 kCeiling, kFloor, kExclusiveScreenToast, | 322 kCeiling, kFloor, kExclusiveScreenToast, |
| 299 }; | 323 }; |
| 300 | 324 |
| 301 MakeManager(kNotInCct, kNotInWebVr); | 325 MakeManager(kNotInCct, kNotInWebVr); |
| 302 | 326 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // Ensure they can be turned off. | 443 // Ensure they can be turned off. |
| 420 manager_->SetAudioCapturingIndicator(false); | 444 manager_->SetAudioCapturingIndicator(false); |
| 421 manager_->SetVideoCapturingIndicator(false); | 445 manager_->SetVideoCapturingIndicator(false); |
| 422 manager_->SetScreenCapturingIndicator(false); | 446 manager_->SetScreenCapturingIndicator(false); |
| 423 manager_->SetLocationAccessIndicator(false); | 447 manager_->SetLocationAccessIndicator(false); |
| 424 manager_->SetBluetoothConnectedIndicator(false); | 448 manager_->SetBluetoothConnectedIndicator(false); |
| 425 EXPECT_TRUE(VerifyVisibility(indicators, false)); | 449 EXPECT_TRUE(VerifyVisibility(indicators, false)); |
| 426 } | 450 } |
| 427 | 451 |
| 428 } // namespace vr_shell | 452 } // namespace vr_shell |
| OLD | NEW |