| OLD | NEW |
| (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_scene_manager.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 9 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 using testing::InSequence; |
| 14 |
| 15 namespace vr_shell { |
| 16 |
| 17 namespace { |
| 18 |
| 19 class MockBrowserInterface : public VrBrowserInterface { |
| 20 public: |
| 21 MockBrowserInterface() {} |
| 22 ~MockBrowserInterface() override {} |
| 23 |
| 24 MOCK_METHOD1(OnContentPaused, void(bool)); |
| 25 |
| 26 private: |
| 27 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); |
| 28 }; |
| 29 |
| 30 } // namespace |
| 31 |
| 32 class UiSceneManagerTest : public testing::Test { |
| 33 public: |
| 34 void SetUp() override { |
| 35 browser_ = base::MakeUnique<MockBrowserInterface>(); |
| 36 scene_ = base::MakeUnique<UiScene>(); |
| 37 manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get()); |
| 38 } |
| 39 |
| 40 protected: |
| 41 std::unique_ptr<MockBrowserInterface> browser_; |
| 42 std::unique_ptr<UiScene> scene_; |
| 43 std::unique_ptr<UiSceneManager> manager_; |
| 44 }; |
| 45 |
| 46 TEST_F(UiSceneManagerTest, ContentPausesOnAppButtonClick) { |
| 47 InSequence s; |
| 48 |
| 49 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); |
| 50 |
| 51 // Clicking app button once should pause content rendering. |
| 52 EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1); |
| 53 manager_->OnAppButtonClicked(); |
| 54 EXPECT_FALSE(scene_->GetWebVrRenderingEnabled()); |
| 55 |
| 56 // Clicking it again should resume content rendering. |
| 57 EXPECT_CALL(*browser_, OnContentPaused(false)).Times(1); |
| 58 manager_->OnAppButtonClicked(); |
| 59 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); |
| 60 } |
| 61 |
| 62 } // namespace vr_shell |
| OLD | NEW |