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

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc

Issue 2866853002: VR: Wire VrShell UI-related state to the scene manager. (Closed)
Patch Set: Rebase; remove now-unused source file. Created 3 years, 7 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
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_scene_manager.h" 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/browser/android/vr_shell/ui_scene.h" 8 #include "chrome/browser/android/vr_shell/ui_scene.h"
9 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 9 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using testing::InSequence; 13 using testing::InSequence;
14 14
15 namespace vr_shell { 15 namespace vr_shell {
16 16
17 namespace { 17 namespace {
18 18
19 class MockBrowserInterface : public VrBrowserInterface { 19 class MockBrowserInterface : public VrBrowserInterface {
20 public: 20 public:
21 MockBrowserInterface() {} 21 MockBrowserInterface() {}
22 ~MockBrowserInterface() override {} 22 ~MockBrowserInterface() override {}
23 23
24 MOCK_METHOD1(ContentSurfaceChanged, void(jobject));
25 MOCK_METHOD0(GvrDelegateReady, void());
26 MOCK_METHOD1(UpdateGamepadData, void(device::GvrGamepadData));
27 MOCK_METHOD1(AppButtonGesturePerformed, void(UiInterface::Direction));
28
29 MOCK_METHOD0(AppButtonClicked, void());
30 MOCK_METHOD0(ForceExitVr, void());
31 MOCK_METHOD2(
32 RunVRDisplayInfoCallback,
33 void(const base::Callback<void(device::mojom::VRDisplayInfoPtr)>&,
34 device::mojom::VRDisplayInfoPtr*));
24 MOCK_METHOD1(OnContentPaused, void(bool)); 35 MOCK_METHOD1(OnContentPaused, void(bool));
25 36
37 // Stub this as scoped pointers don't work as mock method parameters.
38 void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent>) {}
39
26 private: 40 private:
27 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); 41 DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
28 }; 42 };
29 43
30 } // namespace 44 } // namespace
31 45
32 class UiSceneManagerTest : public testing::Test { 46 class UiSceneManagerTest : public testing::Test {
33 public: 47 public:
34 void SetUp() override { 48 void SetUp() override {
35 browser_ = base::MakeUnique<MockBrowserInterface>(); 49 browser_ = base::MakeUnique<MockBrowserInterface>();
36 scene_ = base::MakeUnique<UiScene>(); 50 scene_ = base::MakeUnique<UiScene>();
37 // TODO(mthiesse): When we have UI to test for CCT, we'll need to modify 51 // TODO(mthiesse): When we have UI to test for CCT, we'll need to modify
38 // setup to allow us to test CCT mode. 52 // setup to allow us to test CCT mode.
39 bool in_cct = false; 53 bool in_cct = false;
40 manager_ = 54 bool in_web_vr = true;
41 base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(), in_cct); 55 manager_ = base::MakeUnique<UiSceneManager>(browser_.get(), scene_.get(),
56 in_cct, in_web_vr);
42 } 57 }
43 58
44 protected: 59 protected:
45 std::unique_ptr<MockBrowserInterface> browser_; 60 std::unique_ptr<MockBrowserInterface> browser_;
46 std::unique_ptr<UiScene> scene_; 61 std::unique_ptr<UiScene> scene_;
47 std::unique_ptr<UiSceneManager> manager_; 62 std::unique_ptr<UiSceneManager> manager_;
48 }; 63 };
49 64
50 TEST_F(UiSceneManagerTest, ContentPausesOnAppButtonClick) { 65 TEST_F(UiSceneManagerTest, ContentPausesOnAppButtonClick) {
51 InSequence s; 66 InSequence s;
52 67
53 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); 68 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled());
54 69
55 // Clicking app button once should pause content rendering. 70 // Clicking app button once should pause content rendering.
56 EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1); 71 EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1);
57 manager_->OnAppButtonClicked(); 72 manager_->OnAppButtonClicked();
58 EXPECT_FALSE(scene_->GetWebVrRenderingEnabled()); 73 EXPECT_FALSE(scene_->GetWebVrRenderingEnabled());
59 74
60 // Clicking it again should resume content rendering. 75 // Clicking it again should resume content rendering.
61 EXPECT_CALL(*browser_, OnContentPaused(false)).Times(1); 76 EXPECT_CALL(*browser_, OnContentPaused(false)).Times(1);
62 manager_->OnAppButtonClicked(); 77 manager_->OnAppButtonClicked();
63 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled()); 78 EXPECT_TRUE(scene_->GetWebVrRenderingEnabled());
64 } 79 }
65 80
66 } // namespace vr_shell 81 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.cc ('k') | chrome/browser/android/vr_shell/vr_browser_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698