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 2457c4f258e1dc291ac56052cd7e8bf312e8e67e..83d8eb1b5ff91be33a08e2bf9af774cfc66e39f3 100644 |
| --- a/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| @@ -5,6 +5,9 @@ |
| #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| #include "base/macros.h" |
| +#include "base/test/scoped_task_environment.h" |
| +#include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| +#include "chrome/browser/android/vr_shell/ui_elements/ui_element_identifiers.h" |
| #include "chrome/browser/android/vr_shell/ui_scene.h" |
| #include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| @@ -51,24 +54,39 @@ class MockBrowserInterface : public VrBrowserInterface { |
| class UiSceneManagerTest : public testing::Test { |
| public: |
| - void SetUp() override { |
| - browser_ = base::MakeUnique<MockBrowserInterface>(); |
| + void SetUp() override { browser_ = base::MakeUnique<MockBrowserInterface>(); } |
| + |
| + protected: |
| + enum InCct { |
|
Ian Vollick
2017/05/19 14:42:32
I think you can do enum InCct : bool to specify st
|
| + kNotInCct = false, |
| + kInCct = true, |
| + }; |
| + |
| + enum InWebVr { |
| + kNotInWebVr = false, |
| + kInWebVr = true, |
| + }; |
| + |
| + void MakeManager(InCct in_cct, InWebVr in_web_vr) { |
| scene_ = base::MakeUnique<UiScene>(); |
| - // TODO(mthiesse): When we have UI to test for CCT, we'll need to modify |
| - // setup to allow us to test CCT mode. |
| - bool in_cct = false; |
| - bool in_web_vr = true; |
| manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(), |
| in_cct, in_web_vr); |
| } |
| - protected: |
| + bool IsVisible(UiElementIdentifier identifier) { |
| + UiElement* element = scene_->GetUiElementByIdentifier(identifier); |
| + return element ? element->visible() : false; |
| + } |
| + |
| + base::test::ScopedTaskEnvironment scoped_task_environment_; |
| std::unique_ptr<MockBrowserInterface> browser_; |
| std::unique_ptr<UiScene> scene_; |
| std::unique_ptr<UiSceneManager> manager_; |
| }; |
| TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { |
| + MakeManager(kNotInCct, kInWebVr); |
| + |
| // Clicking app button should trigger to exit presentation. |
| EXPECT_CALL(*browser_, ExitPresent()).Times(1); |
| // And also trigger exit fullscreen. |
| @@ -76,4 +94,47 @@ TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { |
| manager_->OnAppButtonClicked(); |
| } |
| +TEST_F(UiSceneManagerTest, WebVrWarningsShowWhenInitiallyInWebVr) { |
| + MakeManager(kNotInCct, kInWebVr); |
|
Ian Vollick
2017/05/19 14:42:32
This probably isn't useful here, but it's kinda ne
cjgrant
2017/05/19 15:10:40
Yep, very handy (used in the scene tests), but not
|
| + |
| + EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| + |
| + manager_->SetWebVrSecureOrigin(true); |
| + EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| + |
| + manager_->SetWebVrSecureOrigin(false); |
| + EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| + |
| + manager_->SetWebVrMode(false); |
| + EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| +} |
| + |
| +TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) { |
| + MakeManager(kNotInCct, kNotInWebVr); |
| + |
| + EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| + |
| + manager_->SetWebVrMode(true); |
| + EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); |
| + EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); |
| +} |
| + |
| +TEST_F(UiSceneManagerTest, CctButtonVisibleInCct) { |
| + MakeManager(kInCct, kNotInWebVr); |
| + EXPECT_TRUE(IsVisible(kCloseButton)); |
| + |
| + MakeManager(kNotInCct, kNotInWebVr); |
| + EXPECT_FALSE(IsVisible(kCloseButton)); |
| + |
| + MakeManager(kInCct, kInWebVr); |
| + EXPECT_FALSE(IsVisible(kCloseButton)); |
| + manager_->SetWebVrMode(false); |
| + EXPECT_TRUE(IsVisible(kCloseButton)); |
| +} |
| + |
| } // namespace vr_shell |