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

Unified Diff: chrome/browser/android/vr_shell/ui_elements/transience_manager_unittest.cc

Issue 2955023002: VR: Factor transient timing out of UiSceneManager. (Closed)
Patch Set: Rebase again onto ExclusivePresentationToast class/file rename. 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
Index: chrome/browser/android/vr_shell/ui_elements/transience_manager_unittest.cc
diff --git a/chrome/browser/android/vr_shell/ui_elements/transience_manager_unittest.cc b/chrome/browser/android/vr_shell/ui_elements/transience_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6fc1e724b309130b6f2f213de9ec43df62708ecc
--- /dev/null
+++ b/chrome/browser/android/vr_shell/ui_elements/transience_manager_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/ui_elements/transience_manager.h"
+
+#include "base/macros.h"
+#include "base/memory/ptr_util.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_elements/ui_element.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace vr_shell {
+
+TEST(TransienceManager, Visibility) {
+ base::MessageLoop message_loop_;
+ base::ScopedMockTimeMessageLoopTaskRunner task_runner_;
+
+ UiElement element;
+
+ TransienceManager transience(&element, base::TimeDelta::FromSeconds(10));
+ EXPECT_EQ(element.visible(), false);
+
+ transience.KickVisibilityIfEnabled();
+ EXPECT_EQ(element.visible(), false);
+
+ // Enable and disable, making sure the element appears and disappears.
+ transience.SetEnabled(true);
+ EXPECT_EQ(element.visible(), true);
+ transience.SetEnabled(false);
+ EXPECT_EQ(element.visible(), false);
+
+ // Enable, and ensure that the element transiently disappears.
+ transience.SetEnabled(true);
+ EXPECT_EQ(element.visible(), true);
+ task_runner_->FastForwardUntilNoTasksRemain();
+ EXPECT_EQ(element.visible(), false);
+
+ // Kick visibility, and ensure that the element transiently disappears.
+ transience.KickVisibilityIfEnabled();
+ EXPECT_EQ(element.visible(), true);
+ task_runner_->FastForwardUntilNoTasksRemain();
+ EXPECT_EQ(element.visible(), false);
+
+ // Kick visibility, and ensure that ending visibility hides the element.
+ transience.KickVisibilityIfEnabled();
+ EXPECT_EQ(element.visible(), true);
+ transience.EndVisibilityIfEnabled();
+ EXPECT_EQ(element.visible(), false);
+
+ // Kick visibility, and ensure that disabling hides the element.
+ transience.KickVisibilityIfEnabled();
+ EXPECT_EQ(element.visible(), true);
+ transience.SetEnabled(false);
+ EXPECT_EQ(element.visible(), false);
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698