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

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

Issue 2926643003: [VrShell] Centralize color handling and enable close button on fullscreen (Closed)
Patch Set: Created 3 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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 MakeManager(kNotInCct, kNotInWebVr); 102 MakeManager(kNotInCct, kNotInWebVr);
103 103
104 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 104 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
105 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 105 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
106 106
107 manager_->SetWebVrMode(true); 107 manager_->SetWebVrMode(true);
108 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 108 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
109 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 109 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
110 } 110 }
111 111
112 TEST_F(UiSceneManagerTest, CctButtonVisibleInCct) { 112 TEST_F(UiSceneManagerTest, CloseButtonVisibleInCctFullscreen) {
113 // Button should be visible in cct.
113 MakeManager(kInCct, kNotInWebVr); 114 MakeManager(kInCct, kNotInWebVr);
114 EXPECT_TRUE(IsVisible(kCloseButton)); 115 EXPECT_TRUE(IsVisible(kCloseButton));
115 116
117 // Button should not be visible when not in cct or fullscreen.
116 MakeManager(kNotInCct, kNotInWebVr); 118 MakeManager(kNotInCct, kNotInWebVr);
117 EXPECT_FALSE(IsVisible(kCloseButton)); 119 EXPECT_FALSE(IsVisible(kCloseButton));
118 120
121 // Button should be visible in fullscreen and hidden when leaving fullscreen.
122 manager_->SetFullscreen(true);
123 EXPECT_TRUE(IsVisible(kCloseButton));
124 manager_->SetFullscreen(false);
125 EXPECT_FALSE(IsVisible(kCloseButton));
126
127 // Button should not be visible when in WebVR.
119 MakeManager(kInCct, kInWebVr); 128 MakeManager(kInCct, kInWebVr);
120 EXPECT_FALSE(IsVisible(kCloseButton)); 129 EXPECT_FALSE(IsVisible(kCloseButton));
121 manager_->SetWebVrMode(false); 130 manager_->SetWebVrMode(false);
122 EXPECT_TRUE(IsVisible(kCloseButton)); 131 EXPECT_TRUE(IsVisible(kCloseButton));
132
133 // Button should be visible in Cct across transistions in fullscreen.
134 MakeManager(kInCct, kNotInWebVr);
135 EXPECT_TRUE(IsVisible(kCloseButton));
136 manager_->SetFullscreen(true);
137 EXPECT_TRUE(IsVisible(kCloseButton));
138 manager_->SetFullscreen(false);
139 EXPECT_TRUE(IsVisible(kCloseButton));
123 } 140 }
124 141
125 TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) { 142 TEST_F(UiSceneManagerTest, UiUpdatesForIncognito) {
126 MakeManager(kNotInCct, kNotInWebVr); 143 MakeManager(kNotInCct, kNotInWebVr);
127 144
128 // Hold onto the background color to make sure it changes. 145 // Hold onto the background color to make sure it changes.
129 SkColor initial_background = scene_->GetBackgroundColor(); 146 SkColor initial_background = scene_->GetWorldBackgroundColor();
130 manager_->SetFullscreen(true); 147 manager_->SetFullscreen(true);
131 148
132 { 149 {
133 SCOPED_TRACE("Entered Fullsceen"); 150 SCOPED_TRACE("Entered Fullsceen");
134 // Make sure background has changed for fullscreen. 151 // Make sure background has changed for fullscreen.
135 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); 152 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor());
136 } 153 }
137 154
138 SkColor fullscreen_background = scene_->GetBackgroundColor(); 155 SkColor fullscreen_background = scene_->GetWorldBackgroundColor();
139 156
140 manager_->SetIncognito(true); 157 manager_->SetIncognito(true);
141 158
142 { 159 {
143 SCOPED_TRACE("Entered Incognito"); 160 SCOPED_TRACE("Entered Incognito");
144 // Make sure background has changed for incognito. 161 // Make sure background has changed for incognito.
145 EXPECT_NE(fullscreen_background, scene_->GetBackgroundColor()); 162 EXPECT_NE(fullscreen_background, scene_->GetWorldBackgroundColor());
146 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); 163 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor());
147 } 164 }
148 165
149 SkColor incognito_background = scene_->GetBackgroundColor(); 166 SkColor incognito_background = scene_->GetWorldBackgroundColor();
150 167
151 manager_->SetIncognito(false); 168 manager_->SetIncognito(false);
152 169
153 { 170 {
154 SCOPED_TRACE("Exited Incognito"); 171 SCOPED_TRACE("Exited Incognito");
155 EXPECT_EQ(fullscreen_background, scene_->GetBackgroundColor()); 172 EXPECT_EQ(fullscreen_background, scene_->GetWorldBackgroundColor());
156 } 173 }
157 174
158 manager_->SetFullscreen(false); 175 manager_->SetFullscreen(false);
159 176
160 { 177 {
161 SCOPED_TRACE("Exited Fullsceen"); 178 SCOPED_TRACE("Exited Fullsceen");
162 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); 179 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor());
163 } 180 }
164 181
165 manager_->SetIncognito(true); 182 manager_->SetIncognito(true);
166 183
167 { 184 {
168 SCOPED_TRACE("Entered Incognito"); 185 SCOPED_TRACE("Entered Incognito");
169 EXPECT_EQ(incognito_background, scene_->GetBackgroundColor()); 186 EXPECT_EQ(incognito_background, scene_->GetWorldBackgroundColor());
170 } 187 }
171 188
172 manager_->SetIncognito(false); 189 manager_->SetIncognito(false);
173 190
174 { 191 {
175 SCOPED_TRACE("Exited Incognito"); 192 SCOPED_TRACE("Exited Incognito");
176 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); 193 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor());
177 } 194 }
178 } 195 }
179 196
180 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { 197 TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) {
181 std::set<UiElementDebugId> visible_in_browsing = { 198 std::set<UiElementDebugId> visible_in_browsing = {
182 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, 199 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane,
183 UiElementDebugId::kCeiling, UiElementDebugId::kFloor, 200 UiElementDebugId::kCeiling, UiElementDebugId::kFloor,
184 UiElementDebugId::kUrlBar, UiElementDebugId::kLoadingIndicator}; 201 UiElementDebugId::kUrlBar, UiElementDebugId::kLoadingIndicator};
185 std::set<UiElementDebugId> visible_in_fullscreen = { 202 std::set<UiElementDebugId> visible_in_fullscreen = {
186 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, 203 UiElementDebugId::kContentQuad, UiElementDebugId::kCloseButton,
187 UiElementDebugId::kCeiling, UiElementDebugId::kFloor}; 204 UiElementDebugId::kBackplane, UiElementDebugId::kCeiling,
205 UiElementDebugId::kFloor};
188 206
189 MakeManager(kNotInCct, kNotInWebVr); 207 MakeManager(kNotInCct, kNotInWebVr);
190 208
191 // Hold onto the background color to make sure it changes. 209 // Hold onto the background color to make sure it changes.
192 SkColor initial_background = scene_->GetBackgroundColor(); 210 SkColor initial_background = scene_->GetWorldBackgroundColor();
193 211
194 for (const auto& element : scene_->GetUiElements()) { 212 for (const auto& element : scene_->GetUiElements()) {
195 SCOPED_TRACE(element->debug_id()); 213 SCOPED_TRACE(element->debug_id());
196 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != 214 bool should_be_visible = visible_in_browsing.find(element->debug_id()) !=
197 visible_in_browsing.end(); 215 visible_in_browsing.end();
198 EXPECT_EQ(should_be_visible, element->visible()); 216 EXPECT_EQ(should_be_visible, element->visible());
199 } 217 }
200 218
201 // Transistion to fullscreen. 219 // Transistion to fullscreen.
202 manager_->SetFullscreen(true); 220 manager_->SetFullscreen(true);
203 221
204 // Content elements should be visible, control elements should be hidden. 222 // Content elements should be visible, control elements should be hidden.
205 for (const auto& element : scene_->GetUiElements()) { 223 for (const auto& element : scene_->GetUiElements()) {
206 SCOPED_TRACE(element->debug_id()); 224 SCOPED_TRACE(element->debug_id());
207 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) != 225 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) !=
208 visible_in_fullscreen.end(); 226 visible_in_fullscreen.end();
209 EXPECT_EQ(should_be_visible, element->visible()); 227 EXPECT_EQ(should_be_visible, element->visible());
210 } 228 }
211 229
212 { 230 {
213 SCOPED_TRACE("Entered Fullsceen"); 231 SCOPED_TRACE("Entered Fullsceen");
214 // Make sure background has changed for fullscreen. 232 // Make sure background has changed for fullscreen.
215 EXPECT_NE(initial_background, scene_->GetBackgroundColor()); 233 EXPECT_NE(initial_background, scene_->GetWorldBackgroundColor());
216 } 234 }
217 235
218 // Exit fullscreen. 236 // Exit fullscreen.
219 manager_->SetFullscreen(false); 237 manager_->SetFullscreen(false);
220 238
221 // Everything should return to original state after leaving fullscreen. 239 // Everything should return to original state after leaving fullscreen.
222 for (const auto& element : scene_->GetUiElements()) { 240 for (const auto& element : scene_->GetUiElements()) {
223 SCOPED_TRACE(element->debug_id()); 241 SCOPED_TRACE(element->debug_id());
224 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != 242 bool should_be_visible = visible_in_browsing.find(element->debug_id()) !=
225 visible_in_browsing.end(); 243 visible_in_browsing.end();
226 EXPECT_EQ(should_be_visible, element->visible()); 244 EXPECT_EQ(should_be_visible, element->visible());
227 } 245 }
228 { 246 {
229 SCOPED_TRACE("Exited Fullsceen"); 247 SCOPED_TRACE("Exited Fullsceen");
230 EXPECT_EQ(initial_background, scene_->GetBackgroundColor()); 248 EXPECT_EQ(initial_background, scene_->GetWorldBackgroundColor());
231 } 249 }
232 } 250 }
233 251
234 TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) { 252 TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) {
235 MakeManager(kNotInCct, kInWebVr); 253 MakeManager(kNotInCct, kInWebVr);
236 254
237 manager_->SetWebVrSecureOrigin(true); 255 manager_->SetWebVrSecureOrigin(true);
238 manager_->SetAudioCapturingIndicator(true); 256 manager_->SetAudioCapturingIndicator(true);
239 manager_->SetVideoCapturingIndicator(true); 257 manager_->SetVideoCapturingIndicator(true);
240 manager_->SetScreenCapturingIndicator(true); 258 manager_->SetScreenCapturingIndicator(true);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 307
290 manager_->SetAudioCapturingIndicator(false); 308 manager_->SetAudioCapturingIndicator(false);
291 manager_->SetVideoCapturingIndicator(false); 309 manager_->SetVideoCapturingIndicator(false);
292 manager_->SetScreenCapturingIndicator(false); 310 manager_->SetScreenCapturingIndicator(false);
293 311
294 EXPECT_FALSE(IsVisible(kAudioCaptureIndicator)); 312 EXPECT_FALSE(IsVisible(kAudioCaptureIndicator));
295 EXPECT_FALSE(IsVisible(kVideoCaptureIndicator)); 313 EXPECT_FALSE(IsVisible(kVideoCaptureIndicator));
296 EXPECT_FALSE(IsVisible(kScreenCaptureIndicator)); 314 EXPECT_FALSE(IsVisible(kScreenCaptureIndicator));
297 } 315 }
298 } // namespace vr_shell 316 } // 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_shell_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698