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

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

Issue 2960533002: VR: Add support for time-aware unit tests. (Closed)
Patch Set: Fix nits. Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/test/scoped_task_environment.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
10 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" 11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h"
11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 12 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
12 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" 13 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h"
13 #include "chrome/browser/android/vr_shell/ui_scene.h" 14 #include "chrome/browser/android/vr_shell/ui_scene.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace vr_shell { 18 namespace vr_shell {
18 19
19 namespace { 20 namespace {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool visible) { 96 bool visible) {
96 for (const auto& element : scene_->GetUiElements()) { 97 for (const auto& element : scene_->GetUiElements()) {
97 if (debug_ids.find(element->debug_id()) != debug_ids.end() && 98 if (debug_ids.find(element->debug_id()) != debug_ids.end() &&
98 element->visible() != visible) { 99 element->visible() != visible) {
99 return false; 100 return false;
100 } 101 }
101 } 102 }
102 return true; 103 return true;
103 } 104 }
104 105
105 base::test::ScopedTaskEnvironment scoped_task_environment_; 106 base::MessageLoop message_loop_;
106 std::unique_ptr<MockBrowserInterface> browser_; 107 std::unique_ptr<MockBrowserInterface> browser_;
107 std::unique_ptr<UiScene> scene_; 108 std::unique_ptr<UiScene> scene_;
108 std::unique_ptr<UiSceneManager> manager_; 109 std::unique_ptr<UiSceneManager> manager_;
109 }; 110 };
110 111
111 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { 112 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) {
112 MakeManager(kNotInCct, kInWebVr); 113 MakeManager(kNotInCct, kInWebVr);
113 114
114 // Clicking app button should trigger to exit presentation. 115 // Clicking app button should trigger to exit presentation.
115 EXPECT_CALL(*browser_, ExitPresent()).Times(1); 116 EXPECT_CALL(*browser_, ExitPresent()).Times(1);
(...skipping 25 matching lines...) Expand all
141 MakeManager(kNotInCct, kNotInWebVr); 142 MakeManager(kNotInCct, kNotInWebVr);
142 143
143 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 144 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
144 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 145 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
145 146
146 manager_->SetWebVrMode(true, false, false); 147 manager_->SetWebVrMode(true, false, false);
147 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 148 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
148 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 149 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
149 } 150 }
150 151
152 TEST_F(UiSceneManagerTest, WebVrTransientWarningTimesOut) {
153 base::ScopedMockTimeMessageLoopTaskRunner task_runner_;
154
155 MakeManager(kNotInCct, kInWebVr);
156 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
157
158 // Note: Fast-forwarding appears broken in conjunction with restarting timers.
159 // In this test, we can fast-forward by the appropriate time interval, but in
160 // other cases (until the bug is addressed), we could work around the problem
161 // by using FastForwardUntilNoTasksRemain() instead.
162 // See http://crbug.com/736558.
163 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(31));
164 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
165 }
166
151 TEST_F(UiSceneManagerTest, ToastVisibility) { 167 TEST_F(UiSceneManagerTest, ToastVisibility) {
152 // Tests toast not showing when directly entering VR though WebVR 168 // Tests toast not showing when directly entering VR though WebVR
153 // presentation. 169 // presentation.
154 MakeManager(kNotInCct, kInWebVr); 170 MakeManager(kNotInCct, kInWebVr);
155 EXPECT_FALSE(IsVisible(kPresentationToast)); 171 EXPECT_FALSE(IsVisible(kPresentationToast));
156 172
157 MakeManager(kNotInCct, kNotInWebVr); 173 MakeManager(kNotInCct, kNotInWebVr);
158 EXPECT_FALSE(IsVisible(kPresentationToast)); 174 EXPECT_FALSE(IsVisible(kPresentationToast));
159 175
160 manager_->SetFullscreen(true); 176 manager_->SetFullscreen(true);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 421
406 // Ensure they can be turned off. 422 // Ensure they can be turned off.
407 manager_->SetAudioCapturingIndicator(false); 423 manager_->SetAudioCapturingIndicator(false);
408 manager_->SetVideoCapturingIndicator(false); 424 manager_->SetVideoCapturingIndicator(false);
409 manager_->SetScreenCapturingIndicator(false); 425 manager_->SetScreenCapturingIndicator(false);
410 manager_->SetLocationAccessIndicator(false); 426 manager_->SetLocationAccessIndicator(false);
411 EXPECT_TRUE(VerifyVisibility(indicators, false)); 427 EXPECT_TRUE(VerifyVisibility(indicators, false));
412 } 428 }
413 429
414 } // namespace vr_shell 430 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698