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

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc

Issue 2955483003: Show splash screen when entering VR from a deep-link (Closed)
Patch Set: fix compile error on bots Created 3 years, 5 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
OLDNEW
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/test/scoped_task_environment.h" 9 #include "base/test/scoped_task_environment.h"
10 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" 10 #include "chrome/browser/android/vr_shell/ui_browser_interface.h"
(...skipping 19 matching lines...) Expand all
30 MOCK_METHOD1(OnUnsupportedMode, void(UiUnsupportedMode mode)); 30 MOCK_METHOD1(OnUnsupportedMode, void(UiUnsupportedMode mode));
31 31
32 private: 32 private:
33 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); 33 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
34 }; 34 };
35 35
36 std::set<UiElementDebugId> kElementsVisibleInBrowsing = { 36 std::set<UiElementDebugId> kElementsVisibleInBrowsing = {
37 kContentQuad, kBackplane, kCeiling, kFloor, kUrlBar}; 37 kContentQuad, kBackplane, kCeiling, kFloor, kUrlBar};
38 std::set<UiElementDebugId> kElementsVisibleWithExitPrompt = { 38 std::set<UiElementDebugId> kElementsVisibleWithExitPrompt = {
39 kExitPrompt, kExitPromptBackplane, kCeiling, kFloor}; 39 kExitPrompt, kExitPromptBackplane, kCeiling, kFloor};
40
41 } // namespace 40 } // namespace
42 41
43 class UiSceneManagerTest : public testing::Test { 42 class UiSceneManagerTest : public testing::Test {
44 public: 43 public:
45 void SetUp() override { browser_ = base::MakeUnique<MockBrowserInterface>(); } 44 void SetUp() override { browser_ = base::MakeUnique<MockBrowserInterface>(); }
46 45
47 protected: 46 protected:
48 enum InCct : bool { 47 enum InCct : bool {
49 kNotInCct = false, 48 kNotInCct = false,
50 kInCct = true, 49 kInCct = true,
(...skipping 11 matching lines...) Expand all
62 61
63 void MakeManager(InCct in_cct, InWebVr in_web_vr) { 62 void MakeManager(InCct in_cct, InWebVr in_web_vr) {
64 scene_ = base::MakeUnique<UiScene>(); 63 scene_ = base::MakeUnique<UiScene>();
65 manager_ = base::MakeUnique<UiSceneManager>( 64 manager_ = base::MakeUnique<UiSceneManager>(
66 browser_.get(), scene_.get(), in_cct, in_web_vr, kNotAutopresented); 65 browser_.get(), scene_.get(), in_cct, in_web_vr, kNotAutopresented);
67 } 66 }
68 67
69 void MakeAutoPresentedManager() { 68 void MakeAutoPresentedManager() {
70 scene_ = base::MakeUnique<UiScene>(); 69 scene_ = base::MakeUnique<UiScene>();
71 manager_ = base::MakeUnique<UiSceneManager>( 70 manager_ = base::MakeUnique<UiSceneManager>(
72 browser_.get(), scene_.get(), kNotInCct, kInWebVr, kAutopresented); 71 browser_.get(), scene_.get(), kNotInCct, kNotInWebVr, kAutopresented);
73 } 72 }
74 73
75 bool IsVisible(UiElementDebugId debug_id) { 74 bool IsVisible(UiElementDebugId debug_id) {
76 UiElement* element = scene_->GetUiElementByDebugId(debug_id); 75 UiElement* element = scene_->GetUiElementByDebugId(debug_id);
77 return element ? element->visible() : false; 76 return element ? element->visible() : false;
78 } 77 }
79 78
80 // Verify that only the elements in the set are visible. 79 // Verify that only the elements in the set are visible.
81 void VerifyElementsVisible(const std::string& debug_name, 80 void VerifyElementsVisible(const std::string& debug_name,
82 const std::set<UiElementDebugId>& debug_ids) { 81 const std::set<UiElementDebugId>& debug_ids) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 124 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
126 125
127 manager_->SetWebVrSecureOrigin(true); 126 manager_->SetWebVrSecureOrigin(true);
128 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 127 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
129 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 128 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
130 129
131 manager_->SetWebVrSecureOrigin(false); 130 manager_->SetWebVrSecureOrigin(false);
132 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 131 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
133 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 132 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
134 133
135 manager_->SetWebVrMode(false, false, false); 134 manager_->SetWebVrMode(false, false);
136 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 135 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
137 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 136 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
138 } 137 }
139 138
140 TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) { 139 TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) {
141 MakeManager(kNotInCct, kNotInWebVr); 140 MakeManager(kNotInCct, kNotInWebVr);
142 141
143 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 142 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
144 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 143 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
145 144
146 manager_->SetWebVrMode(true, false, false); 145 manager_->SetWebVrMode(true, false);
147 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 146 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
148 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 147 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
149 } 148 }
150 149
151 TEST_F(UiSceneManagerTest, ToastVisibility) { 150 TEST_F(UiSceneManagerTest, ToastVisibility) {
152 // Tests toast not showing when directly entering VR though WebVR 151 // Tests toast not showing when directly entering VR though WebVR
153 // presentation. 152 // presentation.
154 MakeManager(kNotInCct, kInWebVr); 153 MakeManager(kNotInCct, kInWebVr);
155 EXPECT_FALSE(IsVisible(kPresentationToast)); 154 EXPECT_FALSE(IsVisible(kPresentationToast));
156 155
157 MakeManager(kNotInCct, kNotInWebVr); 156 MakeManager(kNotInCct, kNotInWebVr);
158 EXPECT_FALSE(IsVisible(kPresentationToast)); 157 EXPECT_FALSE(IsVisible(kPresentationToast));
159 158
160 manager_->SetFullscreen(true); 159 manager_->SetFullscreen(true);
161 EXPECT_TRUE(IsVisible(kPresentationToast)); 160 EXPECT_TRUE(IsVisible(kPresentationToast));
162 161
163 manager_->SetWebVrMode(true, false, true); 162 manager_->SetWebVrMode(true, true);
164 EXPECT_TRUE(IsVisible(kPresentationToast)); 163 EXPECT_TRUE(IsVisible(kPresentationToast));
165 164
166 manager_->SetWebVrMode(false, false, false); 165 manager_->SetWebVrMode(false, false);
167 EXPECT_FALSE(IsVisible(kPresentationToast)); 166 EXPECT_FALSE(IsVisible(kPresentationToast));
168 167
169 manager_->SetFullscreen(false); 168 manager_->SetFullscreen(false);
170 EXPECT_FALSE(IsVisible(kPresentationToast)); 169 EXPECT_FALSE(IsVisible(kPresentationToast));
171 170
172 manager_->SetWebVrMode(true, false, false); 171 manager_->SetWebVrMode(true, false);
173 EXPECT_FALSE(IsVisible(kPresentationToast)); 172 EXPECT_FALSE(IsVisible(kPresentationToast));
174 173
175 manager_->SetWebVrMode(false, false, true); 174 manager_->SetWebVrMode(false, true);
176 EXPECT_TRUE(IsVisible(kPresentationToast)); 175 EXPECT_TRUE(IsVisible(kPresentationToast));
177 } 176 }
178 177
179 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) { 178 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) {
180 // Button should be visible in cct. 179 // Button should be visible in cct.
181 MakeManager(kInCct, kNotInWebVr); 180 MakeManager(kInCct, kNotInWebVr);
182 EXPECT_TRUE(IsVisible(kCloseButton)); 181 EXPECT_TRUE(IsVisible(kCloseButton));
183 182
184 // Button should not be visible when not in cct or fullscreen. 183 // Button should not be visible when not in cct or fullscreen.
185 MakeManager(kNotInCct, kNotInWebVr); 184 MakeManager(kNotInCct, kNotInWebVr);
186 EXPECT_FALSE(IsVisible(kCloseButton)); 185 EXPECT_FALSE(IsVisible(kCloseButton));
187 186
188 // Button should be visible in fullscreen and hidden when leaving fullscreen. 187 // Button should be visible in fullscreen and hidden when leaving fullscreen.
189 manager_->SetFullscreen(true); 188 manager_->SetFullscreen(true);
190 EXPECT_TRUE(IsVisible(kCloseButton)); 189 EXPECT_TRUE(IsVisible(kCloseButton));
191 manager_->SetFullscreen(false); 190 manager_->SetFullscreen(false);
192 EXPECT_FALSE(IsVisible(kCloseButton)); 191 EXPECT_FALSE(IsVisible(kCloseButton));
193 192
194 // Button should not be visible when in WebVR. 193 // Button should not be visible when in WebVR.
195 MakeManager(kInCct, kInWebVr); 194 MakeManager(kInCct, kInWebVr);
196 EXPECT_FALSE(IsVisible(kCloseButton)); 195 EXPECT_FALSE(IsVisible(kCloseButton));
197 manager_->SetWebVrMode(false, false, false); 196 manager_->SetWebVrMode(false, false);
198 EXPECT_TRUE(IsVisible(kCloseButton)); 197 EXPECT_TRUE(IsVisible(kCloseButton));
199 198
200 // Button should be visible in Cct across transistions in fullscreen. 199 // Button should be visible in Cct across transistions in fullscreen.
201 MakeManager(kInCct, kNotInWebVr); 200 MakeManager(kInCct, kNotInWebVr);
202 EXPECT_TRUE(IsVisible(kCloseButton)); 201 EXPECT_TRUE(IsVisible(kCloseButton));
203 manager_->SetFullscreen(true); 202 manager_->SetFullscreen(true);
204 EXPECT_TRUE(IsVisible(kCloseButton)); 203 EXPECT_TRUE(IsVisible(kCloseButton));
205 manager_->SetFullscreen(false); 204 manager_->SetFullscreen(false);
206 EXPECT_TRUE(IsVisible(kCloseButton)); 205 EXPECT_TRUE(IsVisible(kCloseButton));
207 } 206 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 253 }
255 254
256 manager_->SetIncognito(false); 255 manager_->SetIncognito(false);
257 256
258 { 257 {
259 SCOPED_TRACE("Exited Incognito"); 258 SCOPED_TRACE("Exited Incognito");
260 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); 259 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor());
261 } 260 }
262 } 261 }
263 262
264 TEST_F(UiSceneManagerTest, WebVrAutopresentedInitially) { 263 TEST_F(UiSceneManagerTest, WebVrAutopresented) {
265 MakeAutoPresentedManager(); 264 MakeAutoPresentedManager();
266 manager_->SetWebVrSecureOrigin(true);
267 VerifyElementsVisible("Autopresented",
268 std::set<UiElementDebugId>{kTransientUrlBar});
269 }
270
271 TEST_F(UiSceneManagerTest, WebVrAutopresented) {
272 MakeManager(kNotInCct, kNotInWebVr);
273 265
274 manager_->SetWebVrSecureOrigin(true); 266 manager_->SetWebVrSecureOrigin(true);
275 267
276 // Initial state. 268 // Initially, we should only show the splash screen.
277 VerifyElementsVisible("Initial", kElementsVisibleInBrowsing); 269 VerifyElementsVisible("Initial",
270 std::set<UiElementDebugId>{kSplashScreenIcon});
278 271
279 // Enter WebVR with autopresentation. 272 // Enter WebVR with autopresentation.
280 manager_->SetWebVrMode(true, true, false); 273 manager_->SetWebVrMode(true, false);
281 274
282 VerifyElementsVisible("Autopresented", 275 VerifyElementsVisible("Autopresented",
283 std::set<UiElementDebugId>{kTransientUrlBar}); 276 std::set<UiElementDebugId>{kTransientUrlBar});
284 } 277 }
285 278
286 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { 279 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) {
287 std::set<UiElementDebugId> visible_in_fullscreen = { 280 std::set<UiElementDebugId> visible_in_fullscreen = {
288 kContentQuad, kCloseButton, kBackplane, 281 kContentQuad, kCloseButton, kBackplane,
289 kCeiling, kFloor, kPresentationToast, 282 kCeiling, kFloor, kPresentationToast,
290 }; 283 };
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 356 }
364 357
365 TEST_F(UiSceneManagerTest, UiUpdateTransitionToWebVR) { 358 TEST_F(UiSceneManagerTest, UiUpdateTransitionToWebVR) {
366 MakeManager(kNotInCct, kNotInWebVr); 359 MakeManager(kNotInCct, kNotInWebVr);
367 manager_->SetAudioCapturingIndicator(true); 360 manager_->SetAudioCapturingIndicator(true);
368 manager_->SetVideoCapturingIndicator(true); 361 manager_->SetVideoCapturingIndicator(true);
369 manager_->SetScreenCapturingIndicator(true); 362 manager_->SetScreenCapturingIndicator(true);
370 manager_->SetLocationAccessIndicator(true); 363 manager_->SetLocationAccessIndicator(true);
371 364
372 // Transition to WebVR mode 365 // Transition to WebVR mode
373 manager_->SetWebVrMode(true, false, false); 366 manager_->SetWebVrMode(true, false);
374 manager_->SetWebVrSecureOrigin(true); 367 manager_->SetWebVrSecureOrigin(true);
375 368
376 // All elements should be hidden. 369 // All elements should be hidden.
377 VerifyElementsVisible("Elements hidden", std::set<UiElementDebugId>{}); 370 VerifyElementsVisible("Elements hidden", std::set<UiElementDebugId>{});
378 } 371 }
379 372
380 TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) { 373 TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) {
381 const std::set<UiElementDebugId> indicators = { 374 const std::set<UiElementDebugId> indicators = {
382 kAudioCaptureIndicator, kVideoCaptureIndicator, kScreenCaptureIndicator, 375 kAudioCaptureIndicator, kVideoCaptureIndicator, kScreenCaptureIndicator,
383 kLocationAccessIndicator, 376 kLocationAccessIndicator,
384 }; 377 };
385 378
386 MakeManager(kNotInCct, kNotInWebVr); 379 MakeManager(kNotInCct, kNotInWebVr);
387 EXPECT_TRUE(VerifyVisibility(indicators, false)); 380 EXPECT_TRUE(VerifyVisibility(indicators, false));
388 381
389 manager_->SetAudioCapturingIndicator(true); 382 manager_->SetAudioCapturingIndicator(true);
390 manager_->SetVideoCapturingIndicator(true); 383 manager_->SetVideoCapturingIndicator(true);
391 manager_->SetScreenCapturingIndicator(true); 384 manager_->SetScreenCapturingIndicator(true);
392 manager_->SetLocationAccessIndicator(true); 385 manager_->SetLocationAccessIndicator(true);
393 EXPECT_TRUE(VerifyVisibility(indicators, true)); 386 EXPECT_TRUE(VerifyVisibility(indicators, true));
394 387
395 // Go into non-browser modes and make sure all indicators are hidden. 388 // Go into non-browser modes and make sure all indicators are hidden.
396 manager_->SetWebVrMode(true, false, false); 389 manager_->SetWebVrMode(true, false);
397 EXPECT_TRUE(VerifyVisibility(indicators, false)); 390 EXPECT_TRUE(VerifyVisibility(indicators, false));
398 manager_->SetWebVrMode(false, false, false); 391 manager_->SetWebVrMode(false, false);
399 manager_->SetFullscreen(true); 392 manager_->SetFullscreen(true);
400 EXPECT_TRUE(VerifyVisibility(indicators, false)); 393 EXPECT_TRUE(VerifyVisibility(indicators, false));
401 manager_->SetFullscreen(false); 394 manager_->SetFullscreen(false);
402 395
403 // Back to browser, make sure the indicators reappear. 396 // Back to browser, make sure the indicators reappear.
404 EXPECT_TRUE(VerifyVisibility(indicators, true)); 397 EXPECT_TRUE(VerifyVisibility(indicators, true));
405 398
406 // Ensure they can be turned off. 399 // Ensure they can be turned off.
407 manager_->SetAudioCapturingIndicator(false); 400 manager_->SetAudioCapturingIndicator(false);
408 manager_->SetVideoCapturingIndicator(false); 401 manager_->SetVideoCapturingIndicator(false);
409 manager_->SetScreenCapturingIndicator(false); 402 manager_->SetScreenCapturingIndicator(false);
410 manager_->SetLocationAccessIndicator(false); 403 manager_->SetLocationAccessIndicator(false);
411 EXPECT_TRUE(VerifyVisibility(indicators, false)); 404 EXPECT_TRUE(VerifyVisibility(indicators, false));
412 } 405 }
413 406
414 } // namespace vr_shell 407 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.cc ('k') | chrome/browser/android/vr_shell/vr_gl_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698