| OLD | NEW |
| 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_elements/transience_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/transience_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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/test/scoped_mock_time_message_loop_task_runner.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" | 11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace vr_shell { | 14 namespace vr_shell { |
| 15 | 15 |
| 16 TEST(TransienceManager, Visibility) { | 16 TEST(TransienceManager, Visibility) { |
| 17 base::MessageLoop message_loop_; | 17 base::MessageLoop message_loop_; |
| 18 base::ScopedMockTimeMessageLoopTaskRunner task_runner_; | 18 base::ScopedMockTimeMessageLoopTaskRunner task_runner_; |
| 19 | 19 |
| 20 UiElement element; | 20 UiElement element(1); |
| 21 | 21 |
| 22 TransienceManager transience(&element, base::TimeDelta::FromSeconds(10)); | 22 TransienceManager transience(&element, base::TimeDelta::FromSeconds(10)); |
| 23 EXPECT_EQ(element.visible(), false); | 23 EXPECT_EQ(element.visible(), false); |
| 24 | 24 |
| 25 transience.KickVisibilityIfEnabled(); | 25 transience.KickVisibilityIfEnabled(); |
| 26 EXPECT_EQ(element.visible(), false); | 26 EXPECT_EQ(element.visible(), false); |
| 27 | 27 |
| 28 // Enable and disable, making sure the element appears and disappears. | 28 // Enable and disable, making sure the element appears and disappears. |
| 29 transience.SetEnabled(true); | 29 transience.SetEnabled(true); |
| 30 EXPECT_EQ(element.visible(), true); | 30 EXPECT_EQ(element.visible(), true); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 EXPECT_EQ(element.visible(), false); | 50 EXPECT_EQ(element.visible(), false); |
| 51 | 51 |
| 52 // Kick visibility, and ensure that disabling hides the element. | 52 // Kick visibility, and ensure that disabling hides the element. |
| 53 transience.KickVisibilityIfEnabled(); | 53 transience.KickVisibilityIfEnabled(); |
| 54 EXPECT_EQ(element.visible(), true); | 54 EXPECT_EQ(element.visible(), true); |
| 55 transience.SetEnabled(false); | 55 transience.SetEnabled(false); |
| 56 EXPECT_EQ(element.visible(), false); | 56 EXPECT_EQ(element.visible(), false); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace vr_shell | 59 } // namespace vr_shell |
| OLD | NEW |