Chromium Code Reviews| 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 namespace vr_shell { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 class MockBrowserInterface : public VrBrowserInterface { | |
| 18 public: | |
| 19 MockBrowserInterface() : weak_ptr_factory_(this) {} | |
| 20 ~MockBrowserInterface() override {} | |
| 21 | |
| 22 base::WeakPtr<VrBrowserInterface> GetWeakPtr() { | |
| 23 return weak_ptr_factory_.GetWeakPtr(); | |
| 24 } | |
| 25 | |
| 26 MOCK_METHOD1(OnContentPaused, void(bool)); | |
| 27 | |
| 28 private: | |
| 29 base::WeakPtrFactory<VrBrowserInterface> weak_ptr_factory_; | |
| 30 | |
| 31 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); | |
| 32 }; | |
| 33 | |
| 34 } // namespace | |
| 35 | |
| 36 class UiSceneManagerTest : public testing::Test { | |
| 37 public: | |
| 38 void SetUp() override { | |
| 39 browser_ = base::MakeUnique<MockBrowserInterface>(); | |
| 40 scene_ = base::MakeUnique<UiScene>(); | |
| 41 manager_ = | |
| 42 base::MakeUnique<UiSceneManager>(browser_->GetWeakPtr(), scene_.get()); | |
| 43 } | |
| 44 | |
| 45 protected: | |
| 46 std::unique_ptr<MockBrowserInterface> browser_; | |
| 47 std::unique_ptr<UiScene> scene_; | |
| 48 std::unique_ptr<UiSceneManager> manager_; | |
| 49 }; | |
| 50 | |
| 51 TEST_F(UiSceneManagerTest, ContentPausesOnAppButtonClick) { | |
| 52 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); | |
| 53 | |
| 54 // Clicking app button once should pause content rendering. | |
| 55 EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1); | |
| 56 manager_->OnAppButtonClicked(); | |
| 57 EXPECT_FALSE(scene_->GetWebVrRenderingEnabled()); | |
| 58 | |
| 59 // Clicking it again should resume content rendering. | |
| 60 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
| |
| 61 manager_->OnAppButtonClicked(); | |
| 62 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); | |
| 63 } | |
| 64 | |
| 65 } // namespace vr_shell | |
| OLD | NEW |