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

Side by Side Diff: device/gamepad/gamepad_provider_unittest.cc

Issue 2820563003: Fix race condition in flaky GamepadProvider tests (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gamepad/gamepad_provider.h" 5 #include "device/gamepad/gamepad_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/threading/platform_thread.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "device/gamepad/gamepad_data_fetcher.h" 14 #include "device/gamepad/gamepad_data_fetcher.h"
14 #include "device/gamepad/gamepad_test_helpers.h" 15 #include "device/gamepad/gamepad_test_helpers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace device { 18 namespace device {
18 19
19 namespace { 20 namespace {
20 21
21 using blink::WebGamepads; 22 using blink::WebGamepads;
(...skipping 20 matching lines...) Expand all
42 // Main test fixture 43 // Main test fixture
43 class GamepadProviderTest : public testing::Test, public GamepadTestHelper { 44 class GamepadProviderTest : public testing::Test, public GamepadTestHelper {
44 public: 45 public:
45 GamepadProvider* CreateProvider(const WebGamepads& test_data) { 46 GamepadProvider* CreateProvider(const WebGamepads& test_data) {
46 mock_data_fetcher_ = new MockGamepadDataFetcher(test_data); 47 mock_data_fetcher_ = new MockGamepadDataFetcher(test_data);
47 provider_.reset(new GamepadProvider( 48 provider_.reset(new GamepadProvider(
48 nullptr, std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_))); 49 nullptr, std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_)));
49 return provider_.get(); 50 return provider_.get();
50 } 51 }
51 52
53 // Sleep until the shared memory buffer's seqlock advances the buffer version,
54 // indicating that the gamepad provider has written to it after polling the
55 // gamepad fetchers. The buffer will report an odd value for the version if
56 // the buffer is not in a consistent state, so we also require that the value
57 // is even before continuing.
58 void WaitForData(GamepadHardwareBuffer* buffer) {
59 const base::subtle::Atomic32 initial_version = buffer->seqlock.ReadBegin();
60 base::subtle::Atomic32 current_version;
61 do {
62 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
63 current_version = buffer->seqlock.ReadBegin();
64 } while (current_version % 2 || current_version == initial_version);
65 }
66
52 void ReadGamepadHardwareBuffer(GamepadHardwareBuffer* buffer, 67 void ReadGamepadHardwareBuffer(GamepadHardwareBuffer* buffer,
53 WebGamepads* output) { 68 WebGamepads* output) {
54 memset(output, 0, sizeof(WebGamepads)); 69 memset(output, 0, sizeof(WebGamepads));
55 base::subtle::Atomic32 version; 70 base::subtle::Atomic32 version;
56 do { 71 do {
57 version = buffer->seqlock.ReadBegin(); 72 version = buffer->seqlock.ReadBegin();
58 memcpy(output, &buffer->data, sizeof(WebGamepads)); 73 memcpy(output, &buffer->data, sizeof(WebGamepads));
59 } while (buffer->seqlock.ReadRetry(version)); 74 } while (buffer->seqlock.ReadRetry(version));
60 } 75 }
61 76
62 protected: 77 protected:
63 GamepadProviderTest() {} 78 GamepadProviderTest() {}
64 79
65 std::unique_ptr<GamepadProvider> provider_; 80 std::unique_ptr<GamepadProvider> provider_;
66 81
67 // Pointer owned by the provider. 82 // Pointer owned by the provider.
68 MockGamepadDataFetcher* mock_data_fetcher_; 83 MockGamepadDataFetcher* mock_data_fetcher_;
69 84
70 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest); 85 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest);
71 }; 86 };
72 87
73 // Test is flaky. crbug.com/705367 88 TEST_F(GamepadProviderTest, PollingAccess) {
74 TEST_F(GamepadProviderTest, DISABLED_PollingAccess) {
75 WebGamepads test_data; 89 WebGamepads test_data;
76 memset(&test_data, 0, sizeof(WebGamepads)); 90 memset(&test_data, 0, sizeof(WebGamepads));
77 test_data.items[0].connected = true; 91 test_data.items[0].connected = true;
78 test_data.items[0].timestamp = 0; 92 test_data.items[0].timestamp = 0;
79 test_data.items[0].buttons_length = 1; 93 test_data.items[0].buttons_length = 1;
80 test_data.items[0].axes_length = 2; 94 test_data.items[0].axes_length = 2;
81 test_data.items[0].buttons[0].value = 1.f; 95 test_data.items[0].buttons[0].value = 1.f;
82 test_data.items[0].buttons[0].pressed = true; 96 test_data.items[0].buttons[0].pressed = true;
83 test_data.items[0].axes[0] = -1.f; 97 test_data.items[0].axes[0] = -1.f;
84 test_data.items[0].axes[1] = .5f; 98 test_data.items[0].axes[1] = .5f;
85 99
86 GamepadProvider* provider = CreateProvider(test_data); 100 GamepadProvider* provider = CreateProvider(test_data);
87 provider->SetSanitizationEnabled(false); 101 provider->SetSanitizationEnabled(false);
88 provider->Resume(); 102 provider->Resume();
89 103
90 base::RunLoop().RunUntilIdle(); 104 base::RunLoop().RunUntilIdle();
91 105
92 mock_data_fetcher_->WaitForDataRead();
93
94 // Renderer-side, pull data out of poll buffer. 106 // Renderer-side, pull data out of poll buffer.
95 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 107 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
96 base::GetCurrentProcessHandle()); 108 base::GetCurrentProcessHandle());
97 std::unique_ptr<base::SharedMemory> shared_memory( 109 std::unique_ptr<base::SharedMemory> shared_memory(
98 new base::SharedMemory(handle, true)); 110 new base::SharedMemory(handle, true));
99 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 111 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
100 112
101 GamepadHardwareBuffer* buffer = 113 GamepadHardwareBuffer* buffer =
102 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 114 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
115
116 // Wait until the shared memory buffer has been written at least once.
117 WaitForData(buffer);
118
103 WebGamepads output; 119 WebGamepads output;
104 ReadGamepadHardwareBuffer(buffer, &output); 120 ReadGamepadHardwareBuffer(buffer, &output);
105 121
106 EXPECT_EQ(1u, output.items[0].buttons_length); 122 EXPECT_EQ(1u, output.items[0].buttons_length);
107 EXPECT_EQ(1.f, output.items[0].buttons[0].value); 123 EXPECT_EQ(1.f, output.items[0].buttons[0].value);
108 EXPECT_EQ(true, output.items[0].buttons[0].pressed); 124 EXPECT_EQ(true, output.items[0].buttons[0].pressed);
109 EXPECT_EQ(2u, output.items[0].axes_length); 125 EXPECT_EQ(2u, output.items[0].axes_length);
110 EXPECT_EQ(-1.f, output.items[0].axes[0]); 126 EXPECT_EQ(-1.f, output.items[0].axes[0]);
111 EXPECT_EQ(0.5f, output.items[0].axes[1]); 127 EXPECT_EQ(0.5f, output.items[0].axes[1]);
112 } 128 }
113 129
114 // Flaky on all platforms: http://crbug.com/692219 130 TEST_F(GamepadProviderTest, ConnectDisconnectMultiple) {
115 TEST_F(GamepadProviderTest, DISABLED_ConnectDisconnectMultiple) {
116 WebGamepads test_data; 131 WebGamepads test_data;
117 test_data.items[0].connected = true; 132 test_data.items[0].connected = true;
118 test_data.items[0].timestamp = 0; 133 test_data.items[0].timestamp = 0;
119 test_data.items[0].axes_length = 2; 134 test_data.items[0].axes_length = 2;
120 test_data.items[0].axes[0] = -1.f; 135 test_data.items[0].axes[0] = -1.f;
121 test_data.items[0].axes[1] = .5f; 136 test_data.items[0].axes[1] = .5f;
122 137
123 test_data.items[1].connected = true; 138 test_data.items[1].connected = true;
124 test_data.items[1].timestamp = 0; 139 test_data.items[1].timestamp = 0;
125 test_data.items[1].axes_length = 2; 140 test_data.items[1].axes_length = 2;
126 test_data.items[1].axes[0] = 1.f; 141 test_data.items[1].axes[0] = 1.f;
127 test_data.items[1].axes[1] = -.5f; 142 test_data.items[1].axes[1] = -.5f;
128 143
129 WebGamepads test_data_onedisconnected; 144 WebGamepads test_data_onedisconnected;
130 test_data_onedisconnected.items[1].connected = true; 145 test_data_onedisconnected.items[1].connected = true;
131 test_data_onedisconnected.items[1].timestamp = 0; 146 test_data_onedisconnected.items[1].timestamp = 0;
132 test_data_onedisconnected.items[1].axes_length = 2; 147 test_data_onedisconnected.items[1].axes_length = 2;
133 test_data_onedisconnected.items[1].axes[0] = 1.f; 148 test_data_onedisconnected.items[1].axes[0] = 1.f;
134 test_data_onedisconnected.items[1].axes[1] = -.5f; 149 test_data_onedisconnected.items[1].axes[1] = -.5f;
135 150
136 GamepadProvider* provider = CreateProvider(test_data); 151 GamepadProvider* provider = CreateProvider(test_data);
137 provider->SetSanitizationEnabled(false); 152 provider->SetSanitizationEnabled(false);
138 provider->Resume(); 153 provider->Resume();
139 154
140 base::RunLoop().RunUntilIdle(); 155 base::RunLoop().RunUntilIdle();
141 156
142 mock_data_fetcher_->WaitForDataRead();
143
144 // Renderer-side, pull data out of poll buffer. 157 // Renderer-side, pull data out of poll buffer.
145 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 158 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
146 base::GetCurrentProcessHandle()); 159 base::GetCurrentProcessHandle());
147 std::unique_ptr<base::SharedMemory> shared_memory( 160 std::unique_ptr<base::SharedMemory> shared_memory(
148 new base::SharedMemory(handle, true)); 161 new base::SharedMemory(handle, true));
149 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 162 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
150 163
151 GamepadHardwareBuffer* buffer = 164 GamepadHardwareBuffer* buffer =
152 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 165 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
166
167 // Wait until the shared memory buffer has been written at least once.
168 WaitForData(buffer);
169
153 WebGamepads output; 170 WebGamepads output;
154 ReadGamepadHardwareBuffer(buffer, &output); 171 ReadGamepadHardwareBuffer(buffer, &output);
155 172
156 EXPECT_EQ(2u, output.items[0].axes_length); 173 EXPECT_EQ(2u, output.items[0].axes_length);
157 EXPECT_EQ(-1.f, output.items[0].axes[0]); 174 EXPECT_EQ(-1.f, output.items[0].axes[0]);
158 EXPECT_EQ(0.5f, output.items[0].axes[1]); 175 EXPECT_EQ(0.5f, output.items[0].axes[1]);
159 EXPECT_EQ(2u, output.items[1].axes_length); 176 EXPECT_EQ(2u, output.items[1].axes_length);
160 EXPECT_EQ(1.f, output.items[1].axes[0]); 177 EXPECT_EQ(1.f, output.items[1].axes[0]);
161 EXPECT_EQ(-0.5f, output.items[1].axes[1]); 178 EXPECT_EQ(-0.5f, output.items[1].axes[1]);
162 179
163 mock_data_fetcher_->SetTestData(test_data_onedisconnected); 180 mock_data_fetcher_->SetTestData(test_data_onedisconnected);
164 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 181
182 // The provider polls the data on the background thread and then issues
183 // the callback on the client thread. Waiting for it to poll twice ensures
184 // that it was able to issue callbacks for the first poll.
185 WaitForData(buffer);
186 WaitForData(buffer);
bajones 2017/04/14 03:06:18 This sequence and comment is repeated often enough
mattreynolds 2017/04/14 18:05:48 Done.
187
165 ReadGamepadHardwareBuffer(buffer, &output); 188 ReadGamepadHardwareBuffer(buffer, &output);
166 189
167 EXPECT_EQ(0u, output.items[0].axes_length); 190 EXPECT_EQ(0u, output.items[0].axes_length);
168 EXPECT_EQ(2u, output.items[1].axes_length); 191 EXPECT_EQ(2u, output.items[1].axes_length);
169 EXPECT_EQ(1.f, output.items[1].axes[0]); 192 EXPECT_EQ(1.f, output.items[1].axes[0]);
170 EXPECT_EQ(-0.5f, output.items[1].axes[1]); 193 EXPECT_EQ(-0.5f, output.items[1].axes[1]);
171 } 194 }
172 195
173 // Tests that waiting for a user gesture works properly. 196 // Tests that waiting for a user gesture works properly.
174 TEST_F(GamepadProviderTest, UserGesture) { 197 TEST_F(GamepadProviderTest, UserGesture) {
(...skipping 10 matching lines...) Expand all
185 WebGamepads button_down_data = no_button_data; 208 WebGamepads button_down_data = no_button_data;
186 button_down_data.items[0].buttons[0].value = 1.f; 209 button_down_data.items[0].buttons[0].value = 1.f;
187 button_down_data.items[0].buttons[0].pressed = true; 210 button_down_data.items[0].buttons[0].pressed = true;
188 211
189 UserGestureListener listener; 212 UserGestureListener listener;
190 GamepadProvider* provider = CreateProvider(no_button_data); 213 GamepadProvider* provider = CreateProvider(no_button_data);
191 provider->SetSanitizationEnabled(false); 214 provider->SetSanitizationEnabled(false);
192 provider->Resume(); 215 provider->Resume();
193 216
194 provider->RegisterForUserGesture(listener.GetClosure()); 217 provider->RegisterForUserGesture(listener.GetClosure());
195 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 218
219 base::RunLoop().RunUntilIdle();
220
221 // Renderer-side, pull data out of poll buffer.
222 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
223 base::GetCurrentProcessHandle());
224 std::unique_ptr<base::SharedMemory> shared_memory(
225 new base::SharedMemory(handle, true));
226 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
227
228 GamepadHardwareBuffer* buffer =
229 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
230
231 // Wait until the shared memory buffer has been written at least once.
232 WaitForData(buffer);
196 233
197 // It should not have issued our callback. 234 // It should not have issued our callback.
198 base::RunLoop().RunUntilIdle();
199 EXPECT_FALSE(listener.has_user_gesture()); 235 EXPECT_FALSE(listener.has_user_gesture());
200 236
201 // Set a button down and wait for it to be read twice. 237 // Set a button down.
202 mock_data_fetcher_->SetTestData(button_down_data); 238 mock_data_fetcher_->SetTestData(button_down_data);
203 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 239
240 // The provider polls the data on the background thread and then issues
241 // the callback on the client thread. Waiting for it to poll twice ensures
242 // that it was able to issue callbacks for the first poll.
243 WaitForData(buffer);
244 WaitForData(buffer);
204 245
205 // It should have issued our callback. 246 // It should have issued our callback.
206 base::RunLoop().RunUntilIdle(); 247 base::RunLoop().RunUntilIdle();
207 EXPECT_TRUE(listener.has_user_gesture()); 248 EXPECT_TRUE(listener.has_user_gesture());
208 } 249 }
209 250
210 // Flaky on CrOS and Linux: http://crbug.com/640086, https://crbug.com/702712
211 #if defined(OS_LINUX) || defined(OS_CHROMEOS)
212 #define MAYBE_Sanitization DISABLED_Sanitization
213 #else
214 #define MAYBE_Sanitization Sanitization
215 #endif
216 // Tests that waiting for a user gesture works properly. 251 // Tests that waiting for a user gesture works properly.
217 TEST_F(GamepadProviderTest, MAYBE_Sanitization) { 252 TEST_F(GamepadProviderTest, Sanitization) {
218 WebGamepads active_data; 253 WebGamepads active_data;
219 active_data.items[0].connected = true; 254 active_data.items[0].connected = true;
220 active_data.items[0].timestamp = 0; 255 active_data.items[0].timestamp = 0;
221 active_data.items[0].buttons_length = 1; 256 active_data.items[0].buttons_length = 1;
222 active_data.items[0].axes_length = 1; 257 active_data.items[0].axes_length = 1;
223 active_data.items[0].buttons[0].value = 1.f; 258 active_data.items[0].buttons[0].value = 1.f;
224 active_data.items[0].buttons[0].pressed = true; 259 active_data.items[0].buttons[0].pressed = true;
225 active_data.items[0].axes[0] = -1.f; 260 active_data.items[0].axes[0] = -1.f;
226 261
227 WebGamepads zero_data; 262 WebGamepads zero_data;
228 zero_data.items[0].connected = true; 263 zero_data.items[0].connected = true;
229 zero_data.items[0].timestamp = 0; 264 zero_data.items[0].timestamp = 0;
230 zero_data.items[0].buttons_length = 1; 265 zero_data.items[0].buttons_length = 1;
231 zero_data.items[0].axes_length = 1; 266 zero_data.items[0].axes_length = 1;
232 zero_data.items[0].buttons[0].value = 0.f; 267 zero_data.items[0].buttons[0].value = 0.f;
233 zero_data.items[0].buttons[0].pressed = false; 268 zero_data.items[0].buttons[0].pressed = false;
234 zero_data.items[0].axes[0] = 0.f; 269 zero_data.items[0].axes[0] = 0.f;
235 270
236 UserGestureListener listener; 271 UserGestureListener listener;
237 GamepadProvider* provider = CreateProvider(active_data); 272 GamepadProvider* provider = CreateProvider(active_data);
238 provider->SetSanitizationEnabled(true); 273 provider->SetSanitizationEnabled(true);
239 provider->Resume(); 274 provider->Resume();
240 275
241 base::RunLoop().RunUntilIdle(); 276 base::RunLoop().RunUntilIdle();
242 277
243 mock_data_fetcher_->WaitForDataRead();
244
245 // Renderer-side, pull data out of poll buffer. 278 // Renderer-side, pull data out of poll buffer.
246 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 279 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
247 base::GetCurrentProcessHandle()); 280 base::GetCurrentProcessHandle());
248 std::unique_ptr<base::SharedMemory> shared_memory( 281 std::unique_ptr<base::SharedMemory> shared_memory(
249 new base::SharedMemory(handle, true)); 282 new base::SharedMemory(handle, true));
250 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 283 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
251 284
252 GamepadHardwareBuffer* buffer = 285 GamepadHardwareBuffer* buffer =
253 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 286 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
287
288 // Wait until the shared memory buffer has been written at least once.
289 WaitForData(buffer);
290
254 WebGamepads output; 291 WebGamepads output;
255 ReadGamepadHardwareBuffer(buffer, &output); 292 ReadGamepadHardwareBuffer(buffer, &output);
256 293
257 // Initial data should all be zeroed out due to sanitization, even though the 294 // Initial data should all be zeroed out due to sanitization, even though the
258 // gamepad reported input 295 // gamepad reported input
259 EXPECT_EQ(1u, output.items[0].buttons_length); 296 EXPECT_EQ(1u, output.items[0].buttons_length);
260 EXPECT_EQ(0.f, output.items[0].buttons[0].value); 297 EXPECT_EQ(0.f, output.items[0].buttons[0].value);
261 EXPECT_FALSE(output.items[0].buttons[0].pressed); 298 EXPECT_FALSE(output.items[0].buttons[0].pressed);
262 EXPECT_EQ(1u, output.items[0].axes_length); 299 EXPECT_EQ(1u, output.items[0].axes_length);
263 EXPECT_EQ(0.f, output.items[0].axes[0]); 300 EXPECT_EQ(0.f, output.items[0].axes[0]);
264 301
265 // Zero out the inputs 302 // Zero out the inputs
266 mock_data_fetcher_->SetTestData(zero_data); 303 mock_data_fetcher_->SetTestData(zero_data);
267 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 304
305 // The provider polls the data on the background thread and then issues
306 // the callback on the client thread. Waiting for it to poll twice ensures
307 // that it was able to issue callbacks for the first poll.
308 WaitForData(buffer);
309 WaitForData(buffer);
268 310
269 // Read updated data from shared memory 311 // Read updated data from shared memory
270 ReadGamepadHardwareBuffer(buffer, &output); 312 ReadGamepadHardwareBuffer(buffer, &output);
271 313
272 // Should still read zero, which is now an accurate reflection of the data 314 // Should still read zero, which is now an accurate reflection of the data
273 EXPECT_EQ(1u, output.items[0].buttons_length); 315 EXPECT_EQ(1u, output.items[0].buttons_length);
274 EXPECT_EQ(0.f, output.items[0].buttons[0].value); 316 EXPECT_EQ(0.f, output.items[0].buttons[0].value);
275 EXPECT_FALSE(output.items[0].buttons[0].pressed); 317 EXPECT_FALSE(output.items[0].buttons[0].pressed);
276 EXPECT_EQ(1u, output.items[0].axes_length); 318 EXPECT_EQ(1u, output.items[0].axes_length);
277 EXPECT_EQ(0.f, output.items[0].axes[0]); 319 EXPECT_EQ(0.f, output.items[0].axes[0]);
278 320
279 // Re-set the active inputs 321 // Re-set the active inputs
280 mock_data_fetcher_->SetTestData(active_data); 322 mock_data_fetcher_->SetTestData(active_data);
281 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 323
324 // Wait for two more polls.
325 WaitForData(buffer);
326 WaitForData(buffer);
282 327
283 // Read updated data from shared memory 328 // Read updated data from shared memory
284 ReadGamepadHardwareBuffer(buffer, &output); 329 ReadGamepadHardwareBuffer(buffer, &output);
285 330
286 // Should now accurately reflect the reported data. 331 // Should now accurately reflect the reported data.
287 EXPECT_EQ(1u, output.items[0].buttons_length); 332 EXPECT_EQ(1u, output.items[0].buttons_length);
288 EXPECT_EQ(1.f, output.items[0].buttons[0].value); 333 EXPECT_EQ(1.f, output.items[0].buttons[0].value);
289 EXPECT_TRUE(output.items[0].buttons[0].pressed); 334 EXPECT_TRUE(output.items[0].buttons[0].pressed);
290 EXPECT_EQ(1u, output.items[0].axes_length); 335 EXPECT_EQ(1u, output.items[0].axes_length);
291 EXPECT_EQ(-1.f, output.items[0].axes[0]); 336 EXPECT_EQ(-1.f, output.items[0].axes[0]);
292 } 337 }
293 338
294 } // namespace 339 } // namespace
295 340
296 } // namespace device 341 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698