Chromium Code Reviews| Index: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| diff --git a/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| index da4e16c281db343319915ca08d677c5d04b1ab4c..454198c36d10b27bb969f0e338a5fc976ff1ec0f 100644 |
| --- a/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| @@ -83,6 +83,11 @@ class UiSceneManagerTest : public testing::Test { |
| std::unique_ptr<MockBrowserInterface> browser_; |
| std::unique_ptr<UiScene> scene_; |
| std::unique_ptr<UiSceneManager> manager_; |
| + |
| + bool ColorEquals(vr::Colorf expected, vr::Colorf actual) { |
| + return (expected.r == actual.r) && (expected.g == actual.g) && |
| + (expected.b == actual.b) && (expected.a == actual.a); |
| + } |
| }; |
| TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { |
| @@ -138,4 +143,74 @@ TEST_F(UiSceneManagerTest, CctButtonVisibleInCct) { |
| EXPECT_TRUE(IsVisible(kCloseButton)); |
| } |
| +TEST_F(UiSceneManagerTest, UiUpdatesForFullscreenChanges) { |
| + std::set<UiElementDebugId> visible_in_browsing = { |
| + UiElementDebugId::kContentQuad, UiElementDebugId::kCeiling, |
| + UiElementDebugId::kFloor, UiElementDebugId::kGrid, |
| + UiElementDebugId::kBrowserBar, UiElementDebugId::kLoadingIndicator}; |
| + std::set<UiElementDebugId> visible_in_fullscreen = { |
| + UiElementDebugId::kContentQuad}; |
| + std::set<UiElementDebugId> hidden_in_fullscreen = { |
| + UiElementDebugId::kBrowserBar, UiElementDebugId::kLoadingIndicator}; |
| + |
| + MakeManager(kNotInCct, kNotInWebVr); |
| + |
| + // Hold onto the background color to make sure it changes. |
| + vr::Colorf initialBackground = scene_->GetBackgroundColor(); |
|
cjgrant
2017/05/23 18:58:11
initial_background
amp
2017/05/23 20:56:02
Done.
|
| + |
| + for (const auto& element : scene_->GetUiElements()) { |
| + SCOPED_TRACE(element->debug_id()); |
| + bool should_be_visible = visible_in_browsing.find(element->debug_id()) != |
| + visible_in_browsing.end(); |
| + // Ignore elements not in the set. |
| + if (should_be_visible) { |
| + EXPECT_EQ(should_be_visible, element->visible()); |
| + } |
| + } |
| + |
| + // Transistion to fullscreen. |
| + manager_->SetFullscreen(true); |
| + |
| + // All elements should be hidden except for main content. |
|
cjgrant
2017/05/23 18:58:11
Did we say the floor would stay visible in fullscr
amp
2017/05/23 20:56:02
Yes, at the point this test was written it wasn't
|
| + for (const auto& element : scene_->GetUiElements()) { |
| + SCOPED_TRACE(element->debug_id()); |
| + bool should_be_visible = visible_in_fullscreen.find(element->debug_id()) != |
| + visible_in_fullscreen.end(); |
| + // Ignore elements not in the set. |
|
cjgrant
2017/05/23 18:58:11
Since this test is focused on fullscreen, why igno
amp
2017/05/23 20:56:02
I went this way because not every element has a de
cjgrant
2017/05/23 21:27:31
But in fullscreen, there are only a few things vis
|
| + if (should_be_visible) { |
| + EXPECT_EQ(should_be_visible, element->visible()); |
| + } |
| + bool should_be_hidden = hidden_in_fullscreen.find(element->debug_id()) != |
| + hidden_in_fullscreen.end(); |
| + // Ignore elements not in the set. |
| + if (should_be_hidden) { |
| + EXPECT_FALSE(element->visible()); |
| + } |
| + } |
| + |
| + { |
| + SCOPED_TRACE("Entered Fullsceen"); |
| + // Make sure background has changed for fullscreen. |
| + EXPECT_FALSE(ColorEquals(initialBackground, scene_->GetBackgroundColor())); |
| + } |
| + |
| + // Exit fullscreen. |
| + manager_->SetFullscreen(false); |
| + |
| + // Everything should return to original state after leaving fullscreen. |
| + for (const auto& element : scene_->GetUiElements()) { |
| + SCOPED_TRACE(element->debug_id()); |
| + bool should_be_visible = visible_in_browsing.find(element->debug_id()) != |
| + visible_in_browsing.end(); |
| + // Ignore elements not in the set. |
| + if (should_be_visible) { |
| + EXPECT_EQ(should_be_visible, element->visible()); |
| + } |
| + } |
| + { |
| + SCOPED_TRACE("Exited Fullsceen"); |
| + EXPECT_TRUE(ColorEquals(initialBackground, scene_->GetBackgroundColor())); |
| + } |
| +} |
| + |
| } // namespace vr_shell |