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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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 38b82414712b3d60651a222fd83c09b15bff338c..fc142a2a59446b6d2109390607d45f07893e1d07 100644
--- a/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc
+++ b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc
@@ -6,7 +6,8 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "base/test/scoped_task_environment.h"
+#include "base/message_loop/message_loop.h"
+#include "base/test/scoped_mock_time_message_loop_task_runner.h"
#include "chrome/browser/android/vr_shell/ui_browser_interface.h"
#include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
#include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h"
@@ -102,7 +103,7 @@ class UiSceneManagerTest : public testing::Test {
return true;
}
- base::test::ScopedTaskEnvironment scoped_task_environment_;
+ base::MessageLoop message_loop_;
std::unique_ptr<MockBrowserInterface> browser_;
std::unique_ptr<UiScene> scene_;
std::unique_ptr<UiSceneManager> manager_;
@@ -148,6 +149,21 @@ TEST_F(UiSceneManagerTest, WebVrWarningsDoNotShowWhenInitiallyOutsideWebVr) {
EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
}
+TEST_F(UiSceneManagerTest, WebVrTransientWarningTimesOut) {
+ base::ScopedMockTimeMessageLoopTaskRunner task_runner_;
+
+ MakeManager(kNotInCct, kInWebVr);
+ EXPECT_TRUE(IsVisible(kWebVrTransientHttpSecurityWarning));
+
+ // Note: Fast-forwarding appears broken in conjunction with restarting timers.
+ // In this test, we can fast-forward by the appropriate time interval, but in
+ // other cases (until the bug is addressed), we could work around the problem
+ // by using FastForwardUntilNoTasksRemain() instead.
+ // See http://crbug.com/736558.
+ task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(31));
+ EXPECT_FALSE(IsVisible(kWebVrTransientHttpSecurityWarning));
+}
+
TEST_F(UiSceneManagerTest, ToastVisibility) {
// Tests toast not showing when directly entering VR though WebVR
// presentation.
« 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