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

Unified Diff: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc

Issue 2888283005: VR: Fix HTTP warning staying visible after exiting WebVR. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a83988e4bfc991a2918484f6c1b357c563c12b6a 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"
@@ -52,23 +55,47 @@ class MockBrowserInterface : public VrBrowserInterface {
class UiSceneManagerTest : public testing::Test {
public:
void SetUp() override {
- browser_ = base::MakeUnique<MockBrowserInterface>();
- scene_ = base::MakeUnique<UiScene>();
// TODO(mthiesse): When we have UI to test for CCT, we'll need to modify
mthiesse 2017/05/18 23:47:09 Seems like you can remove this TODO now?
cjgrant 2017/05/19 14:19:13 Done, and I also added a test for the button. PTAL
// setup to allow us to test CCT mode.
- bool in_cct = false;
- bool in_web_vr = true;
+ browser_ = base::MakeUnique<MockBrowserInterface>();
+ scene_ = base::MakeUnique<UiScene>();
+ }
+
+ protected:
+ enum InCct {
+ kNotInCct = false,
+ kInCct = true,
+ };
+
+ enum InWebVr {
+ kNotInWebVr = false,
+ kInWebVr = true,
+ };
+
+ void MakeManager(InCct in_cct, InWebVr in_web_vr) {
manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(),
in_cct, in_web_vr);
}
- protected:
+ bool IsVisible(UiElementIdentifier identifier) {
+ for (auto& element : scene_->GetUiElements()) {
+ if (element->identifier() != identifier)
+ continue;
+ return element->visible();
+ }
+ ADD_FAILURE();
+ return 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 +103,34 @@ TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) {
manager_->OnAppButtonClicked();
}
+TEST_F(UiSceneManagerTest, WebVrWarningsShowWhenInitiallyInWebVr) {
+ MakeManager(kNotInCct, kInWebVr);
+
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), true);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), true);
+
+ manager_->SetWebVrSecureOrigin(true);
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), false);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), false);
+
+ manager_->SetWebVrSecureOrigin(false);
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), true);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), true);
+
+ manager_->SetWebVrMode(false);
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), false);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), false);
+}
+
+TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) {
+ MakeManager(kNotInCct, kNotInWebVr);
+
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), false);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), false);
+
+ manager_->SetWebVrMode(true);
+ EXPECT_EQ(IsVisible(kWebVrPermanentHttpSecurityWarning), true);
+ EXPECT_EQ(IsVisible(kWebVrTransientHttpSecurityWarning), true);
+}
+
} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698