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

Side by Side Diff: content/browser/gamepad/gamepad_test_helpers.cc

Issue 362123002: Gamepad: don't notify about connected pads twice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more build fix (kNumberOfGamepads) Created 6 years, 5 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 (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 "content/browser/gamepad/gamepad_test_helpers.h" 5 #include "content/browser/gamepad/gamepad_test_helpers.h"
6 6
7 #include "content/browser/gamepad/gamepad_service.h" 7 #include "content/browser/gamepad/gamepad_service.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 12 matching lines...) Expand all
23 base::AutoLock lock(lock_); 23 base::AutoLock lock(lock_);
24 *pads = test_data_; 24 *pads = test_data_;
25 } 25 }
26 read_data_.Signal(); 26 read_data_.Signal();
27 } 27 }
28 28
29 void MockGamepadDataFetcher::WaitForDataRead() { 29 void MockGamepadDataFetcher::WaitForDataRead() {
30 return read_data_.Wait(); 30 return read_data_.Wait();
31 } 31 }
32 32
33 void MockGamepadDataFetcher::WaitForDataReadAndCallbacksIssued() {
34 // The provider will read the data on the background thread (setting the
35 // event) and *then* will issue the callback on the client thread. Waiting for
36 // it to read twice is a simple way to ensure that it was able to issue
37 // callbacks for the first read (if it issued one).
38 WaitForDataRead();
39 WaitForDataRead();
40 }
41
33 void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) { 42 void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) {
34 base::AutoLock lock(lock_); 43 base::AutoLock lock(lock_);
35 test_data_ = new_data; 44 test_data_ = new_data;
36 } 45 }
37 46
38 GamepadTestHelper::GamepadTestHelper() { 47 GamepadTestHelper::GamepadTestHelper() {
39 } 48 }
40 49
41 GamepadTestHelper::~GamepadTestHelper() { 50 GamepadTestHelper::~GamepadTestHelper() {
42 } 51 }
43 52
44 GamepadServiceTestConstructor::GamepadServiceTestConstructor( 53 GamepadServiceTestConstructor::GamepadServiceTestConstructor(
45 const blink::WebGamepads& test_data) { 54 const blink::WebGamepads& test_data) {
46 data_fetcher_ = new MockGamepadDataFetcher(test_data); 55 data_fetcher_ = new MockGamepadDataFetcher(test_data);
47 gamepad_service_ = 56 gamepad_service_ =
48 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); 57 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_));
49 } 58 }
50 59
51 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() { 60 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
52 delete gamepad_service_; 61 delete gamepad_service_;
53 } 62 }
54 63
55 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_test_helpers.h ('k') | content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698