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

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

Issue 2820563003: Fix race condition in flaky GamepadProvider tests (Closed)
Patch Set: add WaitForDataAndCallbacksIssued 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
67 // The provider polls the data on the background thread and then issues
68 // the callback on the client thread. Waiting for it to poll twice ensures
69 // that it was able to issue callbacks for the first poll.
70 void WaitForDataAndCallbacksIssued(GamepadHardwareBuffer* buffer) {
71 WaitForData(buffer);
72 WaitForData(buffer);
73 }
74
52 void ReadGamepadHardwareBuffer(GamepadHardwareBuffer* buffer, 75 void ReadGamepadHardwareBuffer(GamepadHardwareBuffer* buffer,
53 WebGamepads* output) { 76 WebGamepads* output) {
54 memset(output, 0, sizeof(WebGamepads)); 77 memset(output, 0, sizeof(WebGamepads));
55 base::subtle::Atomic32 version; 78 base::subtle::Atomic32 version;
56 do { 79 do {
57 version = buffer->seqlock.ReadBegin(); 80 version = buffer->seqlock.ReadBegin();
58 memcpy(output, &buffer->data, sizeof(WebGamepads)); 81 memcpy(output, &buffer->data, sizeof(WebGamepads));
59 } while (buffer->seqlock.ReadRetry(version)); 82 } while (buffer->seqlock.ReadRetry(version));
60 } 83 }
61 84
62 protected: 85 protected:
63 GamepadProviderTest() {} 86 GamepadProviderTest() {}
64 87
65 std::unique_ptr<GamepadProvider> provider_; 88 std::unique_ptr<GamepadProvider> provider_;
66 89
67 // Pointer owned by the provider. 90 // Pointer owned by the provider.
68 MockGamepadDataFetcher* mock_data_fetcher_; 91 MockGamepadDataFetcher* mock_data_fetcher_;
69 92
70 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest); 93 DISALLOW_COPY_AND_ASSIGN(GamepadProviderTest);
71 }; 94 };
72 95
73 // Test is flaky. crbug.com/705367 96 TEST_F(GamepadProviderTest, PollingAccess) {
74 TEST_F(GamepadProviderTest, DISABLED_PollingAccess) {
75 WebGamepads test_data; 97 WebGamepads test_data;
76 memset(&test_data, 0, sizeof(WebGamepads)); 98 memset(&test_data, 0, sizeof(WebGamepads));
77 test_data.items[0].connected = true; 99 test_data.items[0].connected = true;
78 test_data.items[0].timestamp = 0; 100 test_data.items[0].timestamp = 0;
79 test_data.items[0].buttons_length = 1; 101 test_data.items[0].buttons_length = 1;
80 test_data.items[0].axes_length = 2; 102 test_data.items[0].axes_length = 2;
81 test_data.items[0].buttons[0].value = 1.f; 103 test_data.items[0].buttons[0].value = 1.f;
82 test_data.items[0].buttons[0].pressed = true; 104 test_data.items[0].buttons[0].pressed = true;
83 test_data.items[0].axes[0] = -1.f; 105 test_data.items[0].axes[0] = -1.f;
84 test_data.items[0].axes[1] = .5f; 106 test_data.items[0].axes[1] = .5f;
85 107
86 GamepadProvider* provider = CreateProvider(test_data); 108 GamepadProvider* provider = CreateProvider(test_data);
87 provider->SetSanitizationEnabled(false); 109 provider->SetSanitizationEnabled(false);
88 provider->Resume(); 110 provider->Resume();
89 111
90 base::RunLoop().RunUntilIdle(); 112 base::RunLoop().RunUntilIdle();
91 113
92 mock_data_fetcher_->WaitForDataRead();
93
94 // Renderer-side, pull data out of poll buffer. 114 // Renderer-side, pull data out of poll buffer.
95 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 115 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
96 base::GetCurrentProcessHandle()); 116 base::GetCurrentProcessHandle());
97 std::unique_ptr<base::SharedMemory> shared_memory( 117 std::unique_ptr<base::SharedMemory> shared_memory(
98 new base::SharedMemory(handle, true)); 118 new base::SharedMemory(handle, true));
99 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 119 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
100 120
101 GamepadHardwareBuffer* buffer = 121 GamepadHardwareBuffer* buffer =
102 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 122 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
123
124 // Wait until the shared memory buffer has been written at least once.
125 WaitForData(buffer);
126
103 WebGamepads output; 127 WebGamepads output;
104 ReadGamepadHardwareBuffer(buffer, &output); 128 ReadGamepadHardwareBuffer(buffer, &output);
105 129
106 EXPECT_EQ(1u, output.items[0].buttons_length); 130 EXPECT_EQ(1u, output.items[0].buttons_length);
107 EXPECT_EQ(1.f, output.items[0].buttons[0].value); 131 EXPECT_EQ(1.f, output.items[0].buttons[0].value);
108 EXPECT_EQ(true, output.items[0].buttons[0].pressed); 132 EXPECT_EQ(true, output.items[0].buttons[0].pressed);
109 EXPECT_EQ(2u, output.items[0].axes_length); 133 EXPECT_EQ(2u, output.items[0].axes_length);
110 EXPECT_EQ(-1.f, output.items[0].axes[0]); 134 EXPECT_EQ(-1.f, output.items[0].axes[0]);
111 EXPECT_EQ(0.5f, output.items[0].axes[1]); 135 EXPECT_EQ(0.5f, output.items[0].axes[1]);
112 } 136 }
113 137
114 // Flaky on all platforms: http://crbug.com/692219 138 TEST_F(GamepadProviderTest, ConnectDisconnectMultiple) {
115 TEST_F(GamepadProviderTest, DISABLED_ConnectDisconnectMultiple) {
116 WebGamepads test_data; 139 WebGamepads test_data;
117 test_data.items[0].connected = true; 140 test_data.items[0].connected = true;
118 test_data.items[0].timestamp = 0; 141 test_data.items[0].timestamp = 0;
119 test_data.items[0].axes_length = 2; 142 test_data.items[0].axes_length = 2;
120 test_data.items[0].axes[0] = -1.f; 143 test_data.items[0].axes[0] = -1.f;
121 test_data.items[0].axes[1] = .5f; 144 test_data.items[0].axes[1] = .5f;
122 145
123 test_data.items[1].connected = true; 146 test_data.items[1].connected = true;
124 test_data.items[1].timestamp = 0; 147 test_data.items[1].timestamp = 0;
125 test_data.items[1].axes_length = 2; 148 test_data.items[1].axes_length = 2;
126 test_data.items[1].axes[0] = 1.f; 149 test_data.items[1].axes[0] = 1.f;
127 test_data.items[1].axes[1] = -.5f; 150 test_data.items[1].axes[1] = -.5f;
128 151
129 WebGamepads test_data_onedisconnected; 152 WebGamepads test_data_onedisconnected;
130 test_data_onedisconnected.items[1].connected = true; 153 test_data_onedisconnected.items[1].connected = true;
131 test_data_onedisconnected.items[1].timestamp = 0; 154 test_data_onedisconnected.items[1].timestamp = 0;
132 test_data_onedisconnected.items[1].axes_length = 2; 155 test_data_onedisconnected.items[1].axes_length = 2;
133 test_data_onedisconnected.items[1].axes[0] = 1.f; 156 test_data_onedisconnected.items[1].axes[0] = 1.f;
134 test_data_onedisconnected.items[1].axes[1] = -.5f; 157 test_data_onedisconnected.items[1].axes[1] = -.5f;
135 158
136 GamepadProvider* provider = CreateProvider(test_data); 159 GamepadProvider* provider = CreateProvider(test_data);
137 provider->SetSanitizationEnabled(false); 160 provider->SetSanitizationEnabled(false);
138 provider->Resume(); 161 provider->Resume();
139 162
140 base::RunLoop().RunUntilIdle(); 163 base::RunLoop().RunUntilIdle();
141 164
142 mock_data_fetcher_->WaitForDataRead();
143
144 // Renderer-side, pull data out of poll buffer. 165 // Renderer-side, pull data out of poll buffer.
145 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 166 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
146 base::GetCurrentProcessHandle()); 167 base::GetCurrentProcessHandle());
147 std::unique_ptr<base::SharedMemory> shared_memory( 168 std::unique_ptr<base::SharedMemory> shared_memory(
148 new base::SharedMemory(handle, true)); 169 new base::SharedMemory(handle, true));
149 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 170 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
150 171
151 GamepadHardwareBuffer* buffer = 172 GamepadHardwareBuffer* buffer =
152 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 173 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
174
175 // Wait until the shared memory buffer has been written at least once.
176 WaitForData(buffer);
177
153 WebGamepads output; 178 WebGamepads output;
154 ReadGamepadHardwareBuffer(buffer, &output); 179 ReadGamepadHardwareBuffer(buffer, &output);
155 180
156 EXPECT_EQ(2u, output.items[0].axes_length); 181 EXPECT_EQ(2u, output.items[0].axes_length);
157 EXPECT_EQ(-1.f, output.items[0].axes[0]); 182 EXPECT_EQ(-1.f, output.items[0].axes[0]);
158 EXPECT_EQ(0.5f, output.items[0].axes[1]); 183 EXPECT_EQ(0.5f, output.items[0].axes[1]);
159 EXPECT_EQ(2u, output.items[1].axes_length); 184 EXPECT_EQ(2u, output.items[1].axes_length);
160 EXPECT_EQ(1.f, output.items[1].axes[0]); 185 EXPECT_EQ(1.f, output.items[1].axes[0]);
161 EXPECT_EQ(-0.5f, output.items[1].axes[1]); 186 EXPECT_EQ(-0.5f, output.items[1].axes[1]);
162 187
163 mock_data_fetcher_->SetTestData(test_data_onedisconnected); 188 mock_data_fetcher_->SetTestData(test_data_onedisconnected);
164 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 189
190 WaitForDataAndCallbacksIssued(buffer);
191
165 ReadGamepadHardwareBuffer(buffer, &output); 192 ReadGamepadHardwareBuffer(buffer, &output);
166 193
167 EXPECT_EQ(0u, output.items[0].axes_length); 194 EXPECT_EQ(0u, output.items[0].axes_length);
168 EXPECT_EQ(2u, output.items[1].axes_length); 195 EXPECT_EQ(2u, output.items[1].axes_length);
169 EXPECT_EQ(1.f, output.items[1].axes[0]); 196 EXPECT_EQ(1.f, output.items[1].axes[0]);
170 EXPECT_EQ(-0.5f, output.items[1].axes[1]); 197 EXPECT_EQ(-0.5f, output.items[1].axes[1]);
171 } 198 }
172 199
173 // Tests that waiting for a user gesture works properly. 200 // Tests that waiting for a user gesture works properly.
174 TEST_F(GamepadProviderTest, UserGesture) { 201 TEST_F(GamepadProviderTest, UserGesture) {
(...skipping 10 matching lines...) Expand all
185 WebGamepads button_down_data = no_button_data; 212 WebGamepads button_down_data = no_button_data;
186 button_down_data.items[0].buttons[0].value = 1.f; 213 button_down_data.items[0].buttons[0].value = 1.f;
187 button_down_data.items[0].buttons[0].pressed = true; 214 button_down_data.items[0].buttons[0].pressed = true;
188 215
189 UserGestureListener listener; 216 UserGestureListener listener;
190 GamepadProvider* provider = CreateProvider(no_button_data); 217 GamepadProvider* provider = CreateProvider(no_button_data);
191 provider->SetSanitizationEnabled(false); 218 provider->SetSanitizationEnabled(false);
192 provider->Resume(); 219 provider->Resume();
193 220
194 provider->RegisterForUserGesture(listener.GetClosure()); 221 provider->RegisterForUserGesture(listener.GetClosure());
195 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 222
223 base::RunLoop().RunUntilIdle();
224
225 // Renderer-side, pull data out of poll buffer.
226 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
227 base::GetCurrentProcessHandle());
228 std::unique_ptr<base::SharedMemory> shared_memory(
229 new base::SharedMemory(handle, true));
230 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
231
232 GamepadHardwareBuffer* buffer =
233 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
234
235 // Wait until the shared memory buffer has been written at least once.
236 WaitForData(buffer);
196 237
197 // It should not have issued our callback. 238 // It should not have issued our callback.
198 base::RunLoop().RunUntilIdle();
199 EXPECT_FALSE(listener.has_user_gesture()); 239 EXPECT_FALSE(listener.has_user_gesture());
200 240
201 // Set a button down and wait for it to be read twice. 241 // Set a button down.
202 mock_data_fetcher_->SetTestData(button_down_data); 242 mock_data_fetcher_->SetTestData(button_down_data);
203 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 243
244 // The user gesture listener callback is not called until after the buffer has
245 // been updated. Wait for the second update to ensure callbacks have fired.
246 WaitForDataAndCallbacksIssued(buffer);
204 247
205 // It should have issued our callback. 248 // It should have issued our callback.
206 base::RunLoop().RunUntilIdle(); 249 base::RunLoop().RunUntilIdle();
207 EXPECT_TRUE(listener.has_user_gesture()); 250 EXPECT_TRUE(listener.has_user_gesture());
208 } 251 }
209 252
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. 253 // Tests that waiting for a user gesture works properly.
217 TEST_F(GamepadProviderTest, MAYBE_Sanitization) { 254 TEST_F(GamepadProviderTest, Sanitization) {
218 WebGamepads active_data; 255 WebGamepads active_data;
219 active_data.items[0].connected = true; 256 active_data.items[0].connected = true;
220 active_data.items[0].timestamp = 0; 257 active_data.items[0].timestamp = 0;
221 active_data.items[0].buttons_length = 1; 258 active_data.items[0].buttons_length = 1;
222 active_data.items[0].axes_length = 1; 259 active_data.items[0].axes_length = 1;
223 active_data.items[0].buttons[0].value = 1.f; 260 active_data.items[0].buttons[0].value = 1.f;
224 active_data.items[0].buttons[0].pressed = true; 261 active_data.items[0].buttons[0].pressed = true;
225 active_data.items[0].axes[0] = -1.f; 262 active_data.items[0].axes[0] = -1.f;
226 263
227 WebGamepads zero_data; 264 WebGamepads zero_data;
228 zero_data.items[0].connected = true; 265 zero_data.items[0].connected = true;
229 zero_data.items[0].timestamp = 0; 266 zero_data.items[0].timestamp = 0;
230 zero_data.items[0].buttons_length = 1; 267 zero_data.items[0].buttons_length = 1;
231 zero_data.items[0].axes_length = 1; 268 zero_data.items[0].axes_length = 1;
232 zero_data.items[0].buttons[0].value = 0.f; 269 zero_data.items[0].buttons[0].value = 0.f;
233 zero_data.items[0].buttons[0].pressed = false; 270 zero_data.items[0].buttons[0].pressed = false;
234 zero_data.items[0].axes[0] = 0.f; 271 zero_data.items[0].axes[0] = 0.f;
235 272
236 UserGestureListener listener; 273 UserGestureListener listener;
237 GamepadProvider* provider = CreateProvider(active_data); 274 GamepadProvider* provider = CreateProvider(active_data);
238 provider->SetSanitizationEnabled(true); 275 provider->SetSanitizationEnabled(true);
239 provider->Resume(); 276 provider->Resume();
240 277
241 base::RunLoop().RunUntilIdle(); 278 base::RunLoop().RunUntilIdle();
242 279
243 mock_data_fetcher_->WaitForDataRead();
244
245 // Renderer-side, pull data out of poll buffer. 280 // Renderer-side, pull data out of poll buffer.
246 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( 281 base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess(
247 base::GetCurrentProcessHandle()); 282 base::GetCurrentProcessHandle());
248 std::unique_ptr<base::SharedMemory> shared_memory( 283 std::unique_ptr<base::SharedMemory> shared_memory(
249 new base::SharedMemory(handle, true)); 284 new base::SharedMemory(handle, true));
250 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); 285 EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer)));
251 286
252 GamepadHardwareBuffer* buffer = 287 GamepadHardwareBuffer* buffer =
253 static_cast<GamepadHardwareBuffer*>(shared_memory->memory()); 288 static_cast<GamepadHardwareBuffer*>(shared_memory->memory());
289
290 // Wait until the shared memory buffer has been written at least once.
291 WaitForData(buffer);
292
254 WebGamepads output; 293 WebGamepads output;
255 ReadGamepadHardwareBuffer(buffer, &output); 294 ReadGamepadHardwareBuffer(buffer, &output);
256 295
257 // Initial data should all be zeroed out due to sanitization, even though the 296 // Initial data should all be zeroed out due to sanitization, even though the
258 // gamepad reported input 297 // gamepad reported input
259 EXPECT_EQ(1u, output.items[0].buttons_length); 298 EXPECT_EQ(1u, output.items[0].buttons_length);
260 EXPECT_EQ(0.f, output.items[0].buttons[0].value); 299 EXPECT_EQ(0.f, output.items[0].buttons[0].value);
261 EXPECT_FALSE(output.items[0].buttons[0].pressed); 300 EXPECT_FALSE(output.items[0].buttons[0].pressed);
262 EXPECT_EQ(1u, output.items[0].axes_length); 301 EXPECT_EQ(1u, output.items[0].axes_length);
263 EXPECT_EQ(0.f, output.items[0].axes[0]); 302 EXPECT_EQ(0.f, output.items[0].axes[0]);
264 303
265 // Zero out the inputs 304 // Zero out the inputs
266 mock_data_fetcher_->SetTestData(zero_data); 305 mock_data_fetcher_->SetTestData(zero_data);
267 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 306
307 WaitForDataAndCallbacksIssued(buffer);
268 308
269 // Read updated data from shared memory 309 // Read updated data from shared memory
270 ReadGamepadHardwareBuffer(buffer, &output); 310 ReadGamepadHardwareBuffer(buffer, &output);
271 311
272 // Should still read zero, which is now an accurate reflection of the data 312 // Should still read zero, which is now an accurate reflection of the data
273 EXPECT_EQ(1u, output.items[0].buttons_length); 313 EXPECT_EQ(1u, output.items[0].buttons_length);
274 EXPECT_EQ(0.f, output.items[0].buttons[0].value); 314 EXPECT_EQ(0.f, output.items[0].buttons[0].value);
275 EXPECT_FALSE(output.items[0].buttons[0].pressed); 315 EXPECT_FALSE(output.items[0].buttons[0].pressed);
276 EXPECT_EQ(1u, output.items[0].axes_length); 316 EXPECT_EQ(1u, output.items[0].axes_length);
277 EXPECT_EQ(0.f, output.items[0].axes[0]); 317 EXPECT_EQ(0.f, output.items[0].axes[0]);
278 318
279 // Re-set the active inputs 319 // Re-set the active inputs
280 mock_data_fetcher_->SetTestData(active_data); 320 mock_data_fetcher_->SetTestData(active_data);
281 mock_data_fetcher_->WaitForDataReadAndCallbacksIssued(); 321
322 WaitForDataAndCallbacksIssued(buffer);
282 323
283 // Read updated data from shared memory 324 // Read updated data from shared memory
284 ReadGamepadHardwareBuffer(buffer, &output); 325 ReadGamepadHardwareBuffer(buffer, &output);
285 326
286 // Should now accurately reflect the reported data. 327 // Should now accurately reflect the reported data.
287 EXPECT_EQ(1u, output.items[0].buttons_length); 328 EXPECT_EQ(1u, output.items[0].buttons_length);
288 EXPECT_EQ(1.f, output.items[0].buttons[0].value); 329 EXPECT_EQ(1.f, output.items[0].buttons[0].value);
289 EXPECT_TRUE(output.items[0].buttons[0].pressed); 330 EXPECT_TRUE(output.items[0].buttons[0].pressed);
290 EXPECT_EQ(1u, output.items[0].axes_length); 331 EXPECT_EQ(1u, output.items[0].axes_length);
291 EXPECT_EQ(-1.f, output.items[0].axes[0]); 332 EXPECT_EQ(-1.f, output.items[0].axes[0]);
292 } 333 }
293 334
294 } // namespace 335 } // namespace
295 336
296 } // namespace device 337 } // 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