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

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

Issue 2746233002: Fixes 2D-to-WebVR site transitions when browsing in VR. (Closed)
Patch Set: Fixed export Created 3 years, 9 months 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
« no previous file with comments | « device/vr/vr_display_impl.cc ('k') | device/vr/vr_service.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_display_impl.h" 5 #include "device/vr/vr_display_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "device/vr/test/fake_vr_device.h" 10 #include "device/vr/test/fake_vr_device.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void ExitPresent(VRDisplayImpl* display_impl) { display_impl->ExitPresent(); } 60 void ExitPresent(VRDisplayImpl* display_impl) { display_impl->ExitPresent(); }
61 61
62 void TearDown() override { base::RunLoop().RunUntilIdle(); } 62 void TearDown() override { base::RunLoop().RunUntilIdle(); }
63 63
64 VRDevice* device() { return device_; } 64 VRDevice* device() { return device_; }
65 65
66 bool presenting() { return !!device_->presenting_display_; } 66 bool presenting() { return !!device_->presenting_display_; }
67 67
68 VRDisplayImpl* GetVRDisplayImpl(VRServiceImpl* service, VRDevice* device) {
69 return service->GetVRDisplayImplForTesting(device);
70 }
71
68 base::MessageLoop message_loop_; 72 base::MessageLoop message_loop_;
69 bool is_request_presenting_success_ = false; 73 bool is_request_presenting_success_ = false;
70 FakeVRDeviceProvider* provider_; 74 FakeVRDeviceProvider* provider_;
71 FakeVRDevice* device_; 75 FakeVRDevice* device_;
72 std::vector<FakeVRServiceClient*> clients_; 76 std::vector<FakeVRServiceClient*> clients_;
73 std::unique_ptr<VRDeviceManager> device_manager_; 77 std::unique_ptr<VRDeviceManager> device_manager_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(VRDisplayImplTest); 79 DISALLOW_COPY_AND_ASSIGN(VRDisplayImplTest);
76 }; 80 };
77 81
78 TEST_F(VRDisplayImplTest, DevicePresentationIsolation) { 82 TEST_F(VRDisplayImplTest, DevicePresentationIsolation) {
79 auto service_1 = BindService(); 83 auto service_1 = BindService();
80 auto service_2 = BindService(); 84 auto service_2 = BindService();
81 85
82 VRDisplayImpl* display_1 = service_1->GetVRDisplayImpl(device()); 86 VRDisplayImpl* display_1 = GetVRDisplayImpl(service_1.get(), device());
83 VRDisplayImpl* display_2 = service_2->GetVRDisplayImpl(device()); 87 VRDisplayImpl* display_2 = GetVRDisplayImpl(service_2.get(), device());
84 88
85 // When not presenting either service should be able to access the device. 89 // When not presenting either service should be able to access the device.
86 EXPECT_TRUE(device()->IsAccessAllowed(display_1)); 90 EXPECT_TRUE(device()->IsAccessAllowed(display_1));
87 EXPECT_TRUE(device()->IsAccessAllowed(display_2)); 91 EXPECT_TRUE(device()->IsAccessAllowed(display_2));
88 92
89 // Begin presenting to the fake device with service 1. 93 // Begin presenting to the fake device with service 1.
90 RequestPresent(display_1); 94 RequestPresent(display_1);
91 EXPECT_TRUE(is_request_presenting_success_); 95 EXPECT_TRUE(is_request_presenting_success_);
92 EXPECT_TRUE(presenting()); 96 EXPECT_TRUE(presenting());
93 97
(...skipping 27 matching lines...) Expand all
121 auto service_2 = BindService(); 125 auto service_2 = BindService();
122 126
123 device()->OnChanged(); 127 device()->OnChanged();
124 128
125 base::RunLoop().RunUntilIdle(); 129 base::RunLoop().RunUntilIdle();
126 130
127 for (auto* client : clients_) 131 for (auto* client : clients_)
128 EXPECT_TRUE(client->CheckDeviceId(device()->id())); 132 EXPECT_TRUE(client->CheckDeviceId(device()->id()));
129 } 133 }
130 } 134 }
OLDNEW
« no previous file with comments | « device/vr/vr_display_impl.cc ('k') | device/vr/vr_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698