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

Side by Side Diff: device/vr/vr_service_impl_unittest.cc

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Add comments to VRDisplay Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "device/vr/vr_service_impl.h" 5 #include "device/vr/vr_service_impl.h"
6 6
7 #include "base/memory/ref_counted.h"
7 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "device/vr/test/fake_vr_device.h" 10 #include "device/vr/test/fake_vr_device.h"
10 #include "device/vr/test/fake_vr_device_provider.h" 11 #include "device/vr/test/fake_vr_device_provider.h"
11 #include "device/vr/vr_device_manager.h" 12 #include "device/vr/vr_device_manager.h"
12 #include "device/vr/vr_service.mojom.h" 13 #include "device/vr/vr_service.mojom.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 15
15 using ::testing::_; 16 using ::testing::_;
16 using ::testing::Mock; 17 using ::testing::Mock;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DISALLOW_COPY_AND_ASSIGN(VRServiceTestBinding); 63 DISALLOW_COPY_AND_ASSIGN(VRServiceTestBinding);
63 }; 64 };
64 65
65 class VRServiceImplTest : public testing::Test { 66 class VRServiceImplTest : public testing::Test {
66 public: 67 public:
67 VRServiceImplTest() {} 68 VRServiceImplTest() {}
68 ~VRServiceImplTest() override {} 69 ~VRServiceImplTest() override {}
69 70
70 protected: 71 protected:
71 void SetUp() override { 72 void SetUp() override {
72 std::unique_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider()); 73 FakeVRDeviceProvider* provider = new FakeVRDeviceProvider();
73 provider_ = provider.get(); 74 provider_ = provider;
74 device_manager_.reset(new VRDeviceManager(std::move(provider))); 75 device_manager_.reset(new VRDeviceManager(provider));
75 } 76 }
76 77
77 void TearDown() override { base::RunLoop().RunUntilIdle(); } 78 void TearDown() override { base::RunLoop().RunUntilIdle(); }
78 79
79 std::unique_ptr<VRServiceTestBinding> BindService() { 80 std::unique_ptr<VRServiceTestBinding> BindService() {
80 auto test_binding = base::WrapUnique(new VRServiceTestBinding()); 81 auto test_binding = base::WrapUnique(new VRServiceTestBinding());
81 test_binding->SetClient(); 82 test_binding->SetClient();
82 return test_binding; 83 return test_binding;
83 } 84 }
84 85
85 size_t ServiceCount() { return device_manager_->services_.size(); } 86 size_t ServiceCount() { return device_manager_->services_.size(); }
86 87
87 base::MessageLoop message_loop_; 88 base::MessageLoop message_loop_;
88 FakeVRDeviceProvider* provider_; 89 scoped_refptr<FakeVRDeviceProvider> provider_;
89 std::unique_ptr<VRDeviceManager> device_manager_; 90 std::unique_ptr<VRDeviceManager> device_manager_;
90 91
91 DISALLOW_COPY_AND_ASSIGN(VRServiceImplTest); 92 DISALLOW_COPY_AND_ASSIGN(VRServiceImplTest);
92 }; 93 };
93 94
94 // Ensure that services are registered with the device manager as they are 95 // Ensure that services are registered with the device manager as they are
95 // created and removed from the device manager as their connections are closed. 96 // created and removed from the device manager as their connections are closed.
96 TEST_F(VRServiceImplTest, DeviceManagerRegistration) { 97 TEST_F(VRServiceImplTest, DeviceManagerRegistration) {
97 EXPECT_EQ(0u, ServiceCount()); 98 EXPECT_EQ(0u, ServiceCount());
98 99
99 std::unique_ptr<VRServiceTestBinding> service_1 = BindService(); 100 std::unique_ptr<VRServiceTestBinding> service_1 = BindService();
100 101
101 EXPECT_EQ(1u, ServiceCount()); 102 EXPECT_EQ(1u, ServiceCount());
102 103
103 std::unique_ptr<VRServiceTestBinding> service_2 = BindService(); 104 std::unique_ptr<VRServiceTestBinding> service_2 = BindService();
104 105
105 EXPECT_EQ(2u, ServiceCount()); 106 EXPECT_EQ(2u, ServiceCount());
106 107
107 service_1->Close(); 108 service_1->Close();
108 109
109 EXPECT_EQ(1u, ServiceCount()); 110 EXPECT_EQ(1u, ServiceCount());
110 111
111 service_2->Close(); 112 service_2->Close();
112 113
113 EXPECT_EQ(0u, ServiceCount()); 114 EXPECT_EQ(0u, ServiceCount());
114 } 115 }
115 116
116 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698