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

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: Created 3 years, 6 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_;
107 base::ScopedMockTimeMessageLoopTaskRunner task_runner_;
bshe 2017/06/26 15:40:17 optional nit: should we define this in the test th
cjgrant 2017/06/26 16:26:35 Done.
106 std::unique_ptr<MockBrowserInterface> browser_; 108 std::unique_ptr<MockBrowserInterface> browser_;
107 std::unique_ptr<UiScene> scene_; 109 std::unique_ptr<UiScene> scene_;
108 std::unique_ptr<UiSceneManager> manager_; 110 std::unique_ptr<UiSceneManager> manager_;
109 }; 111 };
110 112
111 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) { 113 TEST_F(UiSceneManagerTest, ExitPresentAndFullscreenOnAppButtonClick) {
112 MakeManager(kNotInCct, kInWebVr); 114 MakeManager(kNotInCct, kInWebVr);
113 115
114 // Clicking app button should trigger to exit presentation. 116 // Clicking app button should trigger to exit presentation.
115 EXPECT_CALL(*browser_, ExitPresent()).Times(1); 117 EXPECT_CALL(*browser_, ExitPresent()).Times(1);
(...skipping 25 matching lines...) Expand all
141 MakeManager(kNotInCct, kNotInWebVr); 143 MakeManager(kNotInCct, kNotInWebVr);
142 144
143 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 145 EXPECT_FALSE(IsVisible(kWebVrPermanentHttpSecurityWarning));
144 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning)); 146 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
145 147
146 manager_->SetWebVrMode(true, false, false); 148 manager_->SetWebVrMode(true, false, false);
147 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning)); 149 EXPECT_TRUE(IsVisible(kWebVrPermanentHttpSecurityWarning));
148 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning)); 150 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
149 } 151 }
150 152
153 TEST_F(UiSceneManagerTest, WebVrTransientWarningTimesOut) {
154 MakeManager(kNotInCct, kInWebVr);
155
156 EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
157 // TODO(crbug.com/736558): Fast forwarding appears broken in conjunction with
ymalik 2017/06/26 14:55:21 Nit: Spoke offline, since there's nothing actionab
cjgrant 2017/06/26 16:26:35 Done. And improved the explanation.
158 // restarting timers. Here, we can fast forward by the appropriate time
159 // interval, but in other cases (until the bug is addressed), we could fast
160 // forward until all tasks are addresed.
161 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(31));
162 EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
163 }
164
151 TEST_F(UiSceneManagerTest, ToastVisibility) { 165 TEST_F(UiSceneManagerTest, ToastVisibility) {
152 // Tests toast not showing when directly entering VR though WebVR 166 // Tests toast not showing when directly entering VR though WebVR
153 // presentation. 167 // presentation.
154 MakeManager(kNotInCct, kInWebVr); 168 MakeManager(kNotInCct, kInWebVr);
155 EXPECT_FALSE(IsVisible(kPresentationToast)); 169 EXPECT_FALSE(IsVisible(kPresentationToast));
156 170
157 MakeManager(kNotInCct, kNotInWebVr); 171 MakeManager(kNotInCct, kNotInWebVr);
158 EXPECT_FALSE(IsVisible(kPresentationToast)); 172 EXPECT_FALSE(IsVisible(kPresentationToast));
159 173
160 manager_->SetFullscreen(true); 174 manager_->SetFullscreen(true);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 419
406 // Ensure they can be turned off. 420 // Ensure they can be turned off.
407 manager_->SetAudioCapturingIndicator(false); 421 manager_->SetAudioCapturingIndicator(false);
408 manager_->SetVideoCapturingIndicator(false); 422 manager_->SetVideoCapturingIndicator(false);
409 manager_->SetScreenCapturingIndicator(false); 423 manager_->SetScreenCapturingIndicator(false);
410 manager_->SetLocationAccessIndicator(false); 424 manager_->SetLocationAccessIndicator(false);
411 EXPECT_TRUE(VerifyVisibility(indicators, false)); 425 EXPECT_TRUE(VerifyVisibility(indicators, false));
412 } 426 }
413 427
414 } // namespace vr_shell 428 } // 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