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

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

Issue 2906423002: [vr] Migrate from vr::Colorf to SkColor (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/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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 bool IsVisible(UiElementDebugId debug_id) { 78 bool IsVisible(UiElementDebugId debug_id) {
79 UiElement* element = scene_->GetUiElementByDebugId(debug_id); 79 UiElement* element = scene_->GetUiElementByDebugId(debug_id);
80 return element ? element->visible() : false; 80 return element ? element->visible() : false;
81 } 81 }
82 82
83 base::test::ScopedTaskEnvironment scoped_task_environment_; 83 base::test::ScopedTaskEnvironment scoped_task_environment_;
84 std::unique_ptr<MockBrowserInterface> browser_; 84 std::unique_ptr<MockBrowserInterface> browser_;
85 std::unique_ptr<UiScene> scene_; 85 std::unique_ptr<UiScene> scene_;
86 std::unique_ptr<UiSceneManager> manager_; 86 std::unique_ptr<UiSceneManager> manager_;
87
88 bool ColorEquals(vr::Colorf expected, vr::Colorf actual) {
89 return (expected.r == actual.r) && (expected.g == actual.g) &&
90 (expected.b == actual.b) && (expected.a == actual.a);
91 }
92 }; 87 };
93 88
94 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { 89 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) {
95 MakeManager(kNotInCct, kInWebVr); 90 MakeManager(kNotInCct, kInWebVr);
96 91
97 // Clicking app button should trigger to exit presentation. 92 // Clicking app button should trigger to exit presentation.
98 EXPECT_CALL(*browser_, ExitPresent()).Times(1); 93 EXPECT_CALL(*browser_, ExitPresent()).Times(1);
99 // And also trigger exit fullscreen. 94 // And also trigger exit fullscreen.
100 EXPECT_CALL(*browser_, ExitFullscreen()).Times(1); 95 EXPECT_CALL(*browser_, ExitFullscreen()).Times(1);
101 manager_->OnAppButtonClicked(); 96 manager_->OnAppButtonClicked();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 UiElementDebugId::kFloorGrid, UiElementDebugId::kUrlBar, 146 UiElementDebugId::kFloorGrid, UiElementDebugId::kUrlBar,
152 UiElementDebugId::kLoadingIndicator}; 147 UiElementDebugId::kLoadingIndicator};
153 std::set<UiElementDebugId> visible_in_fullscreen = { 148 std::set<UiElementDebugId> visible_in_fullscreen = {
154 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane, 149 UiElementDebugId::kContentQuad, UiElementDebugId::kBackplane,
155 UiElementDebugId::kCeiling, UiElementDebugId::kFloor, 150 UiElementDebugId::kCeiling, UiElementDebugId::kFloor,
156 UiElementDebugId::kFloorGrid}; 151 UiElementDebugId::kFloorGrid};
157 152
158 MakeManager(kNotInCct, kNotInWebVr); 153 MakeManager(kNotInCct, kNotInWebVr);
159 154
160 // Hold onto the background color to make sure it changes. 155 // Hold onto the background color to make sure it changes.
161 vr::Colorf initial_background = scene_->GetBackgroundColor(); 156 SkColor initial_background = scene_->GetBackgroundColor();
162 157
163 for (const auto& element : scene_->GetUiElements()) { 158 for (const auto& element : scene_->GetUiElements()) {
164 SCOPED_TRACE(element->debug_id()); 159 SCOPED_TRACE(element->debug_id());
165 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != 160 bool should_be_visible = visible_in_browsing.find(element->debug_id()) !=
166 visible_in_browsing.end(); 161 visible_in_browsing.end();
167 EXPECT_EQ(should_be_visible, element->visible()); 162 EXPECT_EQ(should_be_visible, element->visible());
168 } 163 }
169 164
170 // Transistion to fullscreen. 165 // Transistion to fullscreen.
171 manager_->SetFullscreen(true); 166 manager_->SetFullscreen(true);
172 167
173 // Content elements should be visible, control elements should be hidden. 168 // Content elements should be visible, control elements should be hidden.
174 for (const auto& element : scene_->GetUiElements()) { 169 for (const auto& element : scene_->GetUiElements()) {
175 SCOPED_TRACE(element->debug_id()); 170 SCOPED_TRACE(element->debug_id());
176 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) != 171 bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) !=
177 visible_in_fullscreen.end(); 172 visible_in_fullscreen.end();
178 EXPECT_EQ(should_be_visible, element->visible()); 173 EXPECT_EQ(should_be_visible, element->visible());
179 } 174 }
180 175
181 { 176 {
182 SCOPED_TRACE("Entered Fullsceen"); 177 SCOPED_TRACE("Entered Fullsceen");
183 // Make sure background has changed for fullscreen. 178 // Make sure background has changed for fullscreen.
184 EXPECT_FALSE(ColorEquals(initial_background, scene_->GetBackgroundColor())); 179 EXPECT_NE(initial_background, scene_->GetBackgroundColor());
185 } 180 }
186 181
187 // Exit fullscreen. 182 // Exit fullscreen.
188 manager_->SetFullscreen(false); 183 manager_->SetFullscreen(false);
189 184
190 // Everything should return to original state after leaving fullscreen. 185 // Everything should return to original state after leaving fullscreen.
191 for (const auto& element : scene_->GetUiElements()) { 186 for (const auto& element : scene_->GetUiElements()) {
192 SCOPED_TRACE(element->debug_id()); 187 SCOPED_TRACE(element->debug_id());
193 bool should_be_visible = visible_in_browsing.find(element->debug_id()) != 188 bool should_be_visible = visible_in_browsing.find(element->debug_id()) !=
194 visible_in_browsing.end(); 189 visible_in_browsing.end();
195 EXPECT_EQ(should_be_visible, element->visible()); 190 EXPECT_EQ(should_be_visible, element->visible());
196 } 191 }
197 { 192 {
198 SCOPED_TRACE("Exited Fullsceen"); 193 SCOPED_TRACE("Exited Fullsceen");
199 EXPECT_TRUE(ColorEquals(initial_background, scene_->GetBackgroundColor())); 194 EXPECT_EQ(initial_background, scene_->GetBackgroundColor());
200 } 195 }
201 } 196 }
202 197
203 } // namespace vr_shell 198 } // 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