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