| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/vr/vr_device_manager.h" | 5 #include "content/browser/vr/vr_device_manager.h" | 
| 6 | 6 | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 44   device_manager_.reset(new VRDeviceManager(std::move(provider))); | 44   device_manager_.reset(new VRDeviceManager(std::move(provider))); | 
| 45 } | 45 } | 
| 46 | 46 | 
| 47 TEST_F(VRDeviceManagerTest, InitializationTest) { | 47 TEST_F(VRDeviceManagerTest, InitializationTest) { | 
| 48   EXPECT_FALSE(provider_->IsInitialized()); | 48   EXPECT_FALSE(provider_->IsInitialized()); | 
| 49 | 49 | 
| 50   // Calling GetDevices should initialize the service if it hasn't been | 50   // Calling GetDevices should initialize the service if it hasn't been | 
| 51   // initialized yet or the providesr have been released. | 51   // initialized yet or the providesr have been released. | 
| 52   // The mojom::VRService should initialize each of it's providers upon it's own | 52   // The mojom::VRService should initialize each of it's providers upon it's own | 
| 53   // initialization. | 53   // initialization. | 
| 54   mojo::Array<mojom::VRDeviceInfoPtr> webvr_devices; | 54   mojo::Array<blink::mojom::VRDisplayPtr> webvr_devices; | 
| 55   webvr_devices = device_manager_->GetVRDevices(); | 55   webvr_devices = device_manager_->GetVRDevices(); | 
| 56   EXPECT_TRUE(provider_->IsInitialized()); | 56   EXPECT_TRUE(provider_->IsInitialized()); | 
| 57 } | 57 } | 
| 58 | 58 | 
| 59 TEST_F(VRDeviceManagerTest, GetDevicesBasicTest) { | 59 TEST_F(VRDeviceManagerTest, GetDevicesBasicTest) { | 
| 60   mojo::Array<mojom::VRDeviceInfoPtr> webvr_devices; | 60   mojo::Array<blink::mojom::VRDisplayPtr> webvr_devices; | 
| 61   webvr_devices = device_manager_->GetVRDevices(); | 61   webvr_devices = device_manager_->GetVRDevices(); | 
| 62   // Calling GetVRDevices should initialize the providers. | 62   // Calling GetVRDevices should initialize the providers. | 
| 63   EXPECT_TRUE(provider_->IsInitialized()); | 63   EXPECT_TRUE(provider_->IsInitialized()); | 
| 64   // Should successfully return zero devices when none are available. | 64   // Should successfully return zero devices when none are available. | 
| 65   EXPECT_EQ(0u, webvr_devices.size()); | 65   EXPECT_EQ(0u, webvr_devices.size()); | 
| 66 | 66 | 
| 67   // GetDeviceByIndex should return nullptr if an invalid index in queried. | 67   // GetDeviceByIndex should return nullptr if an invalid index in queried. | 
| 68   VRDevice* queried_device = device_manager_->GetDevice(1); | 68   VRDevice* queried_device = device_manager_->GetDevice(1); | 
| 69   EXPECT_EQ(nullptr, queried_device); | 69   EXPECT_EQ(nullptr, queried_device); | 
| 70 | 70 | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 91 | 91 | 
| 92   provider_->RemoveDevice(device1.get()); | 92   provider_->RemoveDevice(device1.get()); | 
| 93   webvr_devices = device_manager_->GetVRDevices(); | 93   webvr_devices = device_manager_->GetVRDevices(); | 
| 94   // Should have successfully returned one device. | 94   // Should have successfully returned one device. | 
| 95   EXPECT_EQ(1u, webvr_devices.size()); | 95   EXPECT_EQ(1u, webvr_devices.size()); | 
| 96   // The WebVRDevice index should match the only remaining device id. | 96   // The WebVRDevice index should match the only remaining device id. | 
| 97   EXPECT_EQ(webvr_devices[0]->index, device2->id()); | 97   EXPECT_EQ(webvr_devices[0]->index, device2->id()); | 
| 98 } | 98 } | 
| 99 | 99 | 
| 100 }  // namespace content | 100 }  // namespace content | 
| OLD | NEW | 
|---|