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

Unified Diff: device/vr/vr_device_manager_unittest.cc

Issue 2488273002: Revert of mojo VR interface simplified (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/vr/vr_device_manager.cc ('k') | device/vr/vr_device_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/vr_device_manager_unittest.cc
diff --git a/device/vr/vr_device_manager_unittest.cc b/device/vr/vr_device_manager_unittest.cc
index 5298f726a17313bb70a791181e91fa221c31a409..454f6c4b41fb0ab3a99e37cbc5dab326909f4fee 100644
--- a/device/vr/vr_device_manager_unittest.cc
+++ b/device/vr/vr_device_manager_unittest.cc
@@ -32,7 +32,6 @@
protected:
FakeVRDeviceProvider* provider_;
std::unique_ptr<VRDeviceManager> device_manager_;
- std::unique_ptr<VRServiceImpl> vr_service_;
DISALLOW_COPY_AND_ASSIGN(VRDeviceManagerTest);
};
@@ -45,7 +44,6 @@
std::unique_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider());
provider_ = provider.get();
device_manager_.reset(new VRDeviceManager(std::move(provider)));
- vr_service_.reset(new VRServiceImpl());
}
TEST_F(VRDeviceManagerTest, InitializationTest) {
@@ -55,15 +53,18 @@
// initialized yet or the providesr have been released.
// The mojom::VRService should initialize each of it's providers upon it's own
// initialization.
- device_manager_->GetVRDevices(vr_service_.get());
+ mojo::Array<VRDisplayPtr> webvr_devices;
+ webvr_devices = device_manager_->GetVRDevices();
EXPECT_TRUE(provider_->IsInitialized());
}
TEST_F(VRDeviceManagerTest, GetDevicesBasicTest) {
- bool success = device_manager_->GetVRDevices(vr_service_.get());
+ mojo::Array<VRDisplayPtr> webvr_devices;
+ webvr_devices = device_manager_->GetVRDevices();
// Calling GetVRDevices should initialize the providers.
EXPECT_TRUE(provider_->IsInitialized());
- EXPECT_FALSE(success);
+ // Should successfully return zero devices when none are available.
+ EXPECT_EQ(0u, webvr_devices.size());
// GetDeviceByIndex should return nullptr if an invalid index in queried.
VRDevice* queried_device = GetDevice(1);
@@ -71,21 +72,31 @@
std::unique_ptr<FakeVRDevice> device1(new FakeVRDevice(provider_));
provider_->AddDevice(device1.get());
- success = device_manager_->GetVRDevices(vr_service_.get());
- EXPECT_TRUE(success);
+ webvr_devices = device_manager_->GetVRDevices();
// Should have successfully returned one device.
- EXPECT_EQ(device1.get(), GetDevice(device1->id()));
+ EXPECT_EQ(1u, webvr_devices.size());
+ // The WebVRDevice index should match the device id.
+ EXPECT_EQ(webvr_devices[0]->index, device1->id());
std::unique_ptr<FakeVRDevice> device2(new FakeVRDevice(provider_));
provider_->AddDevice(device2.get());
- success = device_manager_->GetVRDevices(vr_service_.get());
- EXPECT_TRUE(success);
+ webvr_devices = device_manager_->GetVRDevices();
+ // Should have successfully returned two devices.
+ EXPECT_EQ(2u, webvr_devices.size());
+ // NOTE: Returned WebVRDevices are not required to be in any particular order.
// Querying the WebVRDevice index should return the correct device.
- VRDevice* queried_device1 = GetDevice(device1->id());
- EXPECT_EQ(device1.get(), queried_device1);
- VRDevice* queried_device2 = GetDevice(device2->id());
- EXPECT_EQ(device2.get(), queried_device2);
+ queried_device = GetDevice(device1->id());
+ EXPECT_EQ(device1.get(), queried_device);
+ queried_device = GetDevice(device2->id());
+ EXPECT_EQ(device2.get(), queried_device);
+
+ provider_->RemoveDevice(device1.get());
+ webvr_devices = device_manager_->GetVRDevices();
+ // Should have successfully returned one device.
+ EXPECT_EQ(1u, webvr_devices.size());
+ // The WebVRDevice index should match the only remaining device id.
+ EXPECT_EQ(webvr_devices[0]->index, device2->id());
}
} // namespace device
« no previous file with comments | « device/vr/vr_device_manager.cc ('k') | device/vr/vr_device_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698