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

Side by Side 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: Remove CCT TODO and add a test for it; fix EXPECTs on booleans; cleanup. 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 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"
9 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
10 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_identifiers.h"
8 #include "chrome/browser/android/vr_shell/ui_scene.h" 11 #include "chrome/browser/android/vr_shell/ui_scene.h"
9 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 12 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
10 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 using testing::InSequence; 16 using testing::InSequence;
14 17
15 namespace vr_shell { 18 namespace vr_shell {
16 19
17 namespace { 20 namespace {
(...skipping 26 matching lines...) Expand all
44 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent>) {} 47 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent>) {}
45 48
46 private: 49 private:
47 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); 50 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
48 }; 51 };
49 52
50 } // namespace 53 } // namespace
51 54
52 class UiSceneManagerTest : public testing::Test { 55 class UiSceneManagerTest : public testing::Test {
53 public: 56 public:
54 void SetUp() override { 57 void SetUp() override { browser_ = base::MakeUnique<MockBrowserInterface>(); }
55 browser_ = base::MakeUnique<MockBrowserInterface>(); 58
59 protected:
60 enum InCct {
Ian Vollick 2017/05/19 14:42:32 I think you can do enum InCct : bool to specify st
61 kNotInCct = false,
62 kInCct = true,
63 };
64
65 enum InWebVr {
66 kNotInWebVr = false,
67 kInWebVr = true,
68 };
69
70 void MakeManager(InCct in_cct, InWebVr in_web_vr) {
56 scene_ = base::MakeUnique<UiScene>(); 71 scene_ = base::MakeUnique<UiScene>();
57 // TODO(mthiesse): When we have UI to test for CCT, we'll need to modify
58 // setup to allow us to test CCT mode.
59 bool in_cct = false;
60 bool in_web_vr = true;
61 manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(), 72 manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(),
62 in_cct, in_web_vr); 73 in_cct, in_web_vr);
63 } 74 }
64 75
65 protected: 76 bool IsVisible(UiElementIdentifier identifier) {
77 UiElement* element = scene_->GetUiElementByIdentifier(identifier);
78 return element ? element->visible() : false;
79 }
80
81 base::test::ScopedTaskEnvironment scoped_task_environment_;
66 std::unique_ptr<MockBrowserInterface> browser_; 82 std::unique_ptr<MockBrowserInterface> browser_;
67 std::unique_ptr<UiScene> scene_; 83 std::unique_ptr<UiScene> scene_;
68 std::unique_ptr<UiSceneManager> manager_; 84 std::unique_ptr<UiSceneManager> manager_;
69 }; 85 };
70 86
71 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { 87 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) {
88 MakeManager(kNotInCct, kInWebVr);
89
72 // Clicking app button should trigger to exit presentation. 90 // Clicking app button should trigger to exit presentation.
73 EXPECT_CALL(*browser_, ExitPresent()).Times(1); 91 EXPECT_CALL(*browser_, ExitPresent()).Times(1);
74 // And also trigger exit fullscreen. 92 // And also trigger exit fullscreen.
75 EXPECT_CALL(*browser_, ExitFullscreen()).Times(1); 93 EXPECT_CALL(*browser_, ExitFullscreen()).Times(1);
76 manager_->OnAppButtonClicked(); 94 manager_->OnAppButtonClicked();
77 } 95 }
78 96
97 TEST_F(UiSceneManagerTest, WebVrWarningsShowWhenInitiallyInWebVr) {
98 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
99
100 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
101 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
102
103 manager_->SetWebVrSecureOrigin(true);
104 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
105 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
106
107 manager_->SetWebVrSecureOrigin(false);
108 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
109 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
110
111 manager_->SetWebVrMode(false);
112 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
113 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
114 }
115
116 TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) {
117 MakeManager(kNotInCct, kNotInWebVr);
118
119 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
120 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
121
122 manager_->SetWebVrMode(true);
123 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
124 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
125 }
126
127 TEST_F(UiSceneManagerTest, CctButtonVisibleInCct) {
128 MakeManager(kInCct, kNotInWebVr);
129 EXPECT_TRUE(IsVisible(kCloseButton));
130
131 MakeManager(kNotInCct, kNotInWebVr);
132 EXPECT_FALSE(IsVisible(kCloseButton));
133
134 MakeManager(kInCct, kInWebVr);
135 EXPECT_FALSE(IsVisible(kCloseButton));
136 manager_->SetWebVrMode(false);
137 EXPECT_TRUE(IsVisible(kCloseButton));
138 }
139
79 } // namespace vr_shell 140 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698