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