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

Side by Side 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, 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/ui_elements/transience_manager.h"
6
7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace vr_shell {
15
16 TEST(TransienceManager, Visibility) {
17 base::MessageLoop message_loop_;
18 base::ScopedMockTimeMessageLoopTaskRunner task_runner_;
19
20 UiElement element;
21
22 TransienceManager transience(&element, base::TimeDelta::FromSeconds(10));
23 EXPECT_EQ(element.visible(), false);
24
25 transience.KickVisibilityIfEnabled();
26 EXPECT_EQ(element.visible(), false);
27
28 // Enable and disable, making sure the element appears and disappears.
29 transience.SetEnabled(true);
30 EXPECT_EQ(element.visible(), true);
31 transience.SetEnabled(false);
32 EXPECT_EQ(element.visible(), false);
33
34 // Enable, and ensure that the element transiently disappears.
35 transience.SetEnabled(true);
36 EXPECT_EQ(element.visible(), true);
37 task_runner_->FastForwardUntilNoTasksRemain();
38 EXPECT_EQ(element.visible(), false);
39
40 // Kick visibility, and ensure that the element transiently disappears.
41 transience.KickVisibilityIfEnabled();
42 EXPECT_EQ(element.visible(), true);
43 task_runner_->FastForwardUntilNoTasksRemain();
44 EXPECT_EQ(element.visible(), false);
45
46 // Kick visibility, and ensure that ending visibility hides the element.
47 transience.KickVisibilityIfEnabled();
48 EXPECT_EQ(element.visible(), true);
49 transience.EndVisibilityIfEnabled();
50 EXPECT_EQ(element.visible(), false);
51
52 // Kick visibility, and ensure that disabling hides the element.
53 transience.KickVisibilityIfEnabled();
54 EXPECT_EQ(element.visible(), true);
55 transience.SetEnabled(false);
56 EXPECT_EQ(element.visible(), false);
57 }
58
59 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698