Add ICU message format support
[chromium-blink-merge.git] / content / browser / gamepad / gamepad_test_helpers.cc
blobfc79dcb5ee67ebf1648ad5620122d00d9e34bc00
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
3 // found in the LICENSE file.
5 #include "content/browser/gamepad/gamepad_test_helpers.h"
7 #include "content/browser/gamepad/gamepad_service.h"
9 namespace content {
11 MockGamepadDataFetcher::MockGamepadDataFetcher(
12 const blink::WebGamepads& test_data)
13 : test_data_(test_data),
14 read_data_(false, false) {
17 MockGamepadDataFetcher::~MockGamepadDataFetcher() {
20 void MockGamepadDataFetcher::GetGamepadData(blink::WebGamepads* pads,
21 bool devices_changed_hint) {
23 base::AutoLock lock(lock_);
24 *pads = test_data_;
26 read_data_.Signal();
29 void MockGamepadDataFetcher::WaitForDataRead() {
30 return read_data_.Wait();
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();
42 void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) {
43 base::AutoLock lock(lock_);
44 test_data_ = new_data;
47 GamepadTestHelper::GamepadTestHelper() {
50 GamepadTestHelper::~GamepadTestHelper() {
53 GamepadServiceTestConstructor::GamepadServiceTestConstructor(
54 const blink::WebGamepads& test_data) {
55 data_fetcher_ = new MockGamepadDataFetcher(test_data);
56 gamepad_service_ =
57 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_));
60 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
61 delete gamepad_service_;
64 } // namespace content