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

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: 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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 void ExitPresent(VRDisplayImpl* display_impl) { display_impl->ExitPresent(); } 55 void ExitPresent(VRDisplayImpl* display_impl) { display_impl->ExitPresent(); }
56 56
57 void TearDown() override { base::RunLoop().RunUntilIdle(); } 57 void TearDown() override { base::RunLoop().RunUntilIdle(); }
58 58
59 VRDevice* device() { return device_; } 59 VRDevice* device() { return device_; }
60 60
61 bool presenting() { return !!device_->presenting_display_; } 61 bool presenting() { return !!device_->presenting_display_; }
62 62
63 VRDisplayImpl* GetVRDisplayImpl(VRServiceImpl* service, VRDevice* device) {
mthiesse 2017/03/13 22:17:29 Why add this function?
tiborg 2017/03/13 23:00:58 In C++ friend declarations are not inheritable. TE
64 return service->GetVRDisplayImpl(device);
65 }
66
63 base::MessageLoop message_loop_; 67 base::MessageLoop message_loop_;
64 bool is_request_presenting_success_ = false; 68 bool is_request_presenting_success_ = false;
65 FakeVRDeviceProvider* provider_; 69 FakeVRDeviceProvider* provider_;
66 FakeVRDevice* device_; 70 FakeVRDevice* device_;
67 std::vector<FakeVRServiceClient*> clients_; 71 std::vector<FakeVRServiceClient*> clients_;
68 std::unique_ptr<VRDeviceManager> device_manager_; 72 std::unique_ptr<VRDeviceManager> device_manager_;
69 73
70 DISALLOW_COPY_AND_ASSIGN(VRDisplayImplTest); 74 DISALLOW_COPY_AND_ASSIGN(VRDisplayImplTest);
71 }; 75 };
72 76
73 TEST_F(VRDisplayImplTest, DevicePresentationIsolation) { 77 TEST_F(VRDisplayImplTest, DevicePresentationIsolation) {
74 auto service_1 = BindService(); 78 auto service_1 = BindService();
75 auto service_2 = BindService(); 79 auto service_2 = BindService();
76 80
77 VRDisplayImpl* display_1 = service_1->GetVRDisplayImpl(device()); 81 VRDisplayImpl* display_1 = GetVRDisplayImpl(service_1.get(), device());
78 VRDisplayImpl* display_2 = service_2->GetVRDisplayImpl(device()); 82 VRDisplayImpl* display_2 = GetVRDisplayImpl(service_2.get(), device());
79 83
80 // When not presenting either service should be able to access the device. 84 // When not presenting either service should be able to access the device.
81 EXPECT_TRUE(device()->IsAccessAllowed(display_1)); 85 EXPECT_TRUE(device()->IsAccessAllowed(display_1));
82 EXPECT_TRUE(device()->IsAccessAllowed(display_2)); 86 EXPECT_TRUE(device()->IsAccessAllowed(display_2));
83 87
84 // Begin presenting to the fake device with service 1. 88 // Begin presenting to the fake device with service 1.
85 RequestPresent(display_1); 89 RequestPresent(display_1);
86 EXPECT_TRUE(is_request_presenting_success_); 90 EXPECT_TRUE(is_request_presenting_success_);
87 EXPECT_TRUE(presenting()); 91 EXPECT_TRUE(presenting());
88 92
(...skipping 27 matching lines...) Expand all
116 auto service_2 = BindService(); 120 auto service_2 = BindService();
117 121
118 device()->OnChanged(); 122 device()->OnChanged();
119 123
120 base::RunLoop().RunUntilIdle(); 124 base::RunLoop().RunUntilIdle();
121 125
122 for (auto* client : clients_) 126 for (auto* client : clients_)
123 EXPECT_TRUE(client->CheckDeviceId(device()->id())); 127 EXPECT_TRUE(client->CheckDeviceId(device()->id()));
124 } 128 }
125 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698