Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f5f9033e0c4db514bc0022962c048076f037ff6 |
| --- /dev/null |
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc |
| @@ -0,0 +1,65 @@ |
| +// 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_scene_manager.h" |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/android/vr_shell/ui_scene.h" |
| +#include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace vr_shell { |
| + |
| +namespace { |
| + |
| +class MockBrowserInterface : public VrBrowserInterface { |
| + public: |
| + MockBrowserInterface() : weak_ptr_factory_(this) {} |
| + ~MockBrowserInterface() override {} |
| + |
| + base::WeakPtr<VrBrowserInterface> GetWeakPtr() { |
| + return weak_ptr_factory_.GetWeakPtr(); |
| + } |
| + |
| + MOCK_METHOD1(OnContentPaused, void(bool)); |
| + |
| + private: |
| + base::WeakPtrFactory<VrBrowserInterface> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); |
| +}; |
| + |
| +} // namespace |
| + |
| +class UiSceneManagerTest : public testing::Test { |
| + public: |
| + void SetUp() override { |
| + browser_ = base::MakeUnique<MockBrowserInterface>(); |
| + scene_ = base::MakeUnique<UiScene>(); |
| + manager_ = |
| + base::MakeUnique<UiSceneManager>(browser_->GetWeakPtr(), scene_.get()); |
| + } |
| + |
| + protected: |
| + std::unique_ptr<MockBrowserInterface> browser_; |
| + std::unique_ptr<UiScene> scene_; |
| + std::unique_ptr<UiSceneManager> manager_; |
| +}; |
| + |
| +TEST_F(UiSceneManagerTest, ContentPausesOnAppButtonClick) { |
| + EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); |
| + |
| + // Clicking app button once should pause content rendering. |
| + EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1); |
| + manager_->OnAppButtonClicked(); |
| + EXPECT_FALSE(scene_->GetWebVrRenderingEnabled()); |
| + |
| + // Clicking it again should resume content rendering. |
| + EXPECT_CALL(*browser_, OnContentPaused(false)).Times(1); |
|
cjgrant
2017/05/03 14:40:38
This looks good, but I think it touches on the ord
ymalik
2017/05/03 20:26:38
Totally. In fact it helped me find a bug in the co
|
| + manager_->OnAppButtonClicked(); |
| + EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); |
| +} |
| + |
| +} // namespace vr_shell |