| 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/test/scoped_task_environment.h" | 8 #include "base/test/scoped_task_environment.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 9 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 MakeManager(kNotInCct, kNotInWebVr); | 120 MakeManager(kNotInCct, kNotInWebVr); |
| 121 | 121 |
| 122 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); | 122 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| 123 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); | 123 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| 124 | 124 |
| 125 manager_->SetWebVrMode(true); | 125 manager_->SetWebVrMode(true); |
| 126 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); | 126 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| 127 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); | 127 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(UiSceneManagerTest, CctButtonVisibleInCct) { | 130 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) { |
| 131 // Button should be visible in cct. |
| 131 MakeManager(kInCct, kNotInWebVr); | 132 MakeManager(kInCct, kNotInWebVr); |
| 132 EXPECT_TRUE(IsVisible(kCloseButton)); | 133 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 133 | 134 |
| 135 // Button should not be visible when not in cct or fullscreen. |
| 134 MakeManager(kNotInCct, kNotInWebVr); | 136 MakeManager(kNotInCct, kNotInWebVr); |
| 135 EXPECT_FALSE(IsVisible(kCloseButton)); | 137 EXPECT_FALSE(IsVisible(kCloseButton)); |
| 136 | 138 |
| 139 // Button should be visible in fullscreen and hidden when leaving fullscreen. |
| 140 manager_->SetFullscreen(true); |
| 141 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 142 manager_->SetFullscreen(false); |
| 143 EXPECT_FALSE(IsVisible(kCloseButton)); |
| 144 |
| 145 // Button should not be visible when in WebVR. |
| 137 MakeManager(kInCct, kInWebVr); | 146 MakeManager(kInCct, kInWebVr); |
| 138 EXPECT_FALSE(IsVisible(kCloseButton)); | 147 EXPECT_FALSE(IsVisible(kCloseButton)); |
| 139 manager_->SetWebVrMode(false); | 148 manager_->SetWebVrMode(false); |
| 140 EXPECT_TRUE(IsVisible(kCloseButton)); | 149 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 150 |
| 151 // Button should be visible in Cct across transistions in fullscreen. |
| 152 MakeManager(kInCct, kNotInWebVr); |
| 153 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 154 manager_->SetFullscreen(true); |
| 155 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 156 manager_->SetFullscreen(false); |
| 157 EXPECT_TRUE(IsVisible(kCloseButton)); |
| 141 } | 158 } |
| 142 | 159 |
| 143 TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) { | 160 TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) { |
| 144 MakeManager(kNotInCct, kNotInWebVr); | 161 MakeManager(kNotInCct, kNotInWebVr); |
| 145 | 162 |
| 146 // Hold onto the background color to make sure it changes. | 163 // Hold onto the background color to make sure it changes. |
| 147 SkColor initial_background = scene_->GetBackgroundColor(); | 164 SkColor initial_background = scene_->GetWorldBackgroundColor(); |
| 148 manager_->SetFullscreen(true); | 165 manager_->SetFullscreen(true); |
| 149 | 166 |
| 150 { | 167 { |
| 151 SCOPED_TRACE("Entered Fullsceen"); | 168 SCOPED_TRACE("Entered Fullsceen"); |
| 152 // Make sure background has changed for fullscreen. | 169 // Make sure background has changed for fullscreen. |
| 153 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); | 170 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); |
| 154 } | 171 } |
| 155 | 172 |
| 156 SkColor fullscreen_background = scene_->GetBackgroundColor(); | 173 SkColor fullscreen_background = scene_->GetWorldBackgroundColor(); |
| 157 | 174 |
| 158 manager_->SetIncognito(true); | 175 manager_->SetIncognito(true); |
| 159 | 176 |
| 160 { | 177 { |
| 161 SCOPED_TRACE("Entered Incognito"); | 178 SCOPED_TRACE("Entered Incognito"); |
| 162 // Make sure background has changed for incognito. | 179 // Make sure background has changed for incognito. |
| 163 EXPECT_NE(fullscreen_background, scene_->GetBackgroundColor()); | 180 EXPECT_NE(fullscreen_background, scene_->GetWorldBackgroundColor()); |
| 164 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); | 181 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); |
| 165 } | 182 } |
| 166 | 183 |
| 167 SkColor incognito_background = scene_->GetBackgroundColor(); | 184 SkColor incognito_background = scene_->GetWorldBackgroundColor(); |
| 168 | 185 |
| 169 manager_->SetIncognito(false); | 186 manager_->SetIncognito(false); |
| 170 | 187 |
| 171 { | 188 { |
| 172 SCOPED_TRACE("Exited Incognito"); | 189 SCOPED_TRACE("Exited Incognito"); |
| 173 EXPECT_EQ(fullscreen_background, scene_->GetBackgroundColor()); | 190 EXPECT_EQ(fullscreen_background, scene_->GetWorldBackgroundColor()); |
| 174 } | 191 } |
| 175 | 192 |
| 176 manager_->SetFullscreen(false); | 193 manager_->SetFullscreen(false); |
| 177 | 194 |
| 178 { | 195 { |
| 179 SCOPED_TRACE("Exited Fullsceen"); | 196 SCOPED_TRACE("Exited Fullsceen"); |
| 180 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); | 197 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); |
| 181 } | 198 } |
| 182 | 199 |
| 183 manager_->SetIncognito(true); | 200 manager_->SetIncognito(true); |
| 184 | 201 |
| 185 { | 202 { |
| 186 SCOPED_TRACE("Entered Incognito"); | 203 SCOPED_TRACE("Entered Incognito"); |
| 187 EXPECT_EQ(incognito_background, scene_->GetBackgroundColor()); | 204 EXPECT_EQ(incognito_background, scene_->GetWorldBackgroundColor()); |
| 188 } | 205 } |
| 189 | 206 |
| 190 manager_->SetIncognito(false); | 207 manager_->SetIncognito(false); |
| 191 | 208 |
| 192 { | 209 { |
| 193 SCOPED_TRACE("Exited Incognito"); | 210 SCOPED_TRACE("Exited Incognito"); |
| 194 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); | 211 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); |
| 195 } | 212 } |
| 196 } | 213 } |
| 197 | 214 |
| 198 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { | 215 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { |
| 199 std::set<UiElementDebugId> visible_in_browsing = { | 216 std::set<UiElementDebugId> visible_in_browsing = { |
| 200 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, | 217 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, |
| 201 UiElementDebugId::kCeiling, UiElementDebugId::kFloor, | 218 UiElementDebugId::kCeiling, UiElementDebugId::kFloor, |
| 202 UiElementDebugId::kUrlBar, UiElementDebugId::kLoadingIndicator}; | 219 UiElementDebugId::kUrlBar, UiElementDebugId::kLoadingIndicator}; |
| 203 std::set<UiElementDebugId> visible_in_fullscreen = { | 220 std::set<UiElementDebugId> visible_in_fullscreen = { |
| 204 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, | 221 UiElementDebugId::kContentQuad, UiElementDebugId::kCloseButton, |
| 205 UiElementDebugId::kCeiling, UiElementDebugId::kFloor}; | 222 UiElementDebugId::kBackplane, UiElementDebugId::kCeiling, |
| 223 UiElementDebugId::kFloor}; |
| 206 | 224 |
| 207 MakeManager(kNotInCct, kNotInWebVr); | 225 MakeManager(kNotInCct, kNotInWebVr); |
| 208 | 226 |
| 209 // Hold onto the background color to make sure it changes. | 227 // Hold onto the background color to make sure it changes. |
| 210 SkColor initial_background = scene_->GetBackgroundColor(); | 228 SkColor initial_background = scene_->GetWorldBackgroundColor(); |
| 211 | 229 |
| 212 for (const auto& element : scene_->GetUiElements()) { | 230 for (const auto& element : scene_->GetUiElements()) { |
| 213 SCOPED_TRACE(element->debug_id()); | 231 SCOPED_TRACE(element->debug_id()); |
| 214 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != | 232 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != |
| 215 visible_in_browsing.end(); | 233 visible_in_browsing.end(); |
| 216 EXPECT_EQ(should_be_visible, element->visible()); | 234 EXPECT_EQ(should_be_visible, element->visible()); |
| 217 } | 235 } |
| 218 | 236 |
| 219 // Transistion to fullscreen. | 237 // Transistion to fullscreen. |
| 220 manager_->SetFullscreen(true); | 238 manager_->SetFullscreen(true); |
| 221 | 239 |
| 222 // Content elements should be visible, control elements should be hidden. | 240 // Content elements should be visible, control elements should be hidden. |
| 223 for (const auto& element : scene_->GetUiElements()) { | 241 for (const auto& element : scene_->GetUiElements()) { |
| 224 SCOPED_TRACE(element->debug_id()); | 242 SCOPED_TRACE(element->debug_id()); |
| 225 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) != | 243 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) != |
| 226 visible_in_fullscreen.end(); | 244 visible_in_fullscreen.end(); |
| 227 EXPECT_EQ(should_be_visible, element->visible()); | 245 EXPECT_EQ(should_be_visible, element->visible()); |
| 228 } | 246 } |
| 229 | 247 |
| 230 { | 248 { |
| 231 SCOPED_TRACE("Entered Fullsceen"); | 249 SCOPED_TRACE("Entered Fullsceen"); |
| 232 // Make sure background has changed for fullscreen. | 250 // Make sure background has changed for fullscreen. |
| 233 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); | 251 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor()); |
| 234 } | 252 } |
| 235 | 253 |
| 236 // Exit fullscreen. | 254 // Exit fullscreen. |
| 237 manager_->SetFullscreen(false); | 255 manager_->SetFullscreen(false); |
| 238 | 256 |
| 239 // Everything should return to original state after leaving fullscreen. | 257 // Everything should return to original state after leaving fullscreen. |
| 240 for (const auto& element : scene_->GetUiElements()) { | 258 for (const auto& element : scene_->GetUiElements()) { |
| 241 SCOPED_TRACE(element->debug_id()); | 259 SCOPED_TRACE(element->debug_id()); |
| 242 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != | 260 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != |
| 243 visible_in_browsing.end(); | 261 visible_in_browsing.end(); |
| 244 EXPECT_EQ(should_be_visible, element->visible()); | 262 EXPECT_EQ(should_be_visible, element->visible()); |
| 245 } | 263 } |
| 246 { | 264 { |
| 247 SCOPED_TRACE("Exited Fullsceen"); | 265 SCOPED_TRACE("Exited Fullsceen"); |
| 248 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); | 266 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor()); |
| 249 } | 267 } |
| 250 } | 268 } |
| 251 | 269 |
| 252 TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) { | 270 TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) { |
| 253 MakeManager(kNotInCct, kInWebVr); | 271 MakeManager(kNotInCct, kInWebVr); |
| 254 | 272 |
| 255 manager_->SetWebVrSecureOrigin(true); | 273 manager_->SetWebVrSecureOrigin(true); |
| 256 manager_->SetAudioCapturingIndicator(true); | 274 manager_->SetAudioCapturingIndicator(true); |
| 257 manager_->SetVideoCapturingIndicator(true); | 275 manager_->SetVideoCapturingIndicator(true); |
| 258 manager_->SetScreenCapturingIndicator(true); | 276 manager_->SetScreenCapturingIndicator(true); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 325 |
| 308 manager_->SetAudioCapturingIndicator(false); | 326 manager_->SetAudioCapturingIndicator(false); |
| 309 manager_->SetVideoCapturingIndicator(false); | 327 manager_->SetVideoCapturingIndicator(false); |
| 310 manager_->SetScreenCapturingIndicator(false); | 328 manager_->SetScreenCapturingIndicator(false); |
| 311 | 329 |
| 312 EXPECT_FALSE(IsVisible(kAudioCaptureIndicator)); | 330 EXPECT_FALSE(IsVisible(kAudioCaptureIndicator)); |
| 313 EXPECT_FALSE(IsVisible(kVideoCaptureIndicator)); | 331 EXPECT_FALSE(IsVisible(kVideoCaptureIndicator)); |
| 314 EXPECT_FALSE(IsVisible(kScreenCaptureIndicator)); | 332 EXPECT_FALSE(IsVisible(kScreenCaptureIndicator)); |
| 315 } | 333 } |
| 316 } // namespace vr_shell | 334 } // namespace vr_shell |
| OLD | NEW |