OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/gamepad/gamepad_consumer.h" | 10 #include "content/browser/gamepad/gamepad_consumer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 test_data_.items[0].buttons[0].pressed = true; | 86 test_data_.items[0].buttons[0].pressed = true; |
87 } | 87 } |
88 | 88 |
89 GamepadServiceTest::~GamepadServiceTest() { | 89 GamepadServiceTest::~GamepadServiceTest() { |
90 delete service_; | 90 delete service_; |
91 } | 91 } |
92 | 92 |
93 void GamepadServiceTest::SetUp() { | 93 void GamepadServiceTest::SetUp() { |
94 fetcher_ = new MockGamepadDataFetcher(test_data_); | 94 fetcher_ = new MockGamepadDataFetcher(test_data_); |
95 service_ = new GamepadService(scoped_ptr<GamepadDataFetcher>(fetcher_)); | 95 service_ = new GamepadService(scoped_ptr<GamepadDataFetcher>(fetcher_)); |
96 service_->provider()->SetSanitizationEnabled(false); | |
97 connection_listener_.reset((new ConnectionListener)); | 96 connection_listener_.reset((new ConnectionListener)); |
98 service_->ConsumerBecameActive(connection_listener_.get()); | 97 service_->ConsumerBecameActive(connection_listener_.get()); |
99 } | 98 } |
100 | 99 |
101 void GamepadServiceTest::SetPadsConnected(bool connected) { | 100 void GamepadServiceTest::SetPadsConnected(bool connected) { |
102 for (int i = 0; i < kNumberOfGamepads; ++i) { | 101 for (int i = 0; i < kNumberOfGamepads; ++i) { |
103 test_data_.items[i].connected = connected; | 102 test_data_.items[i].connected = connected; |
104 } | 103 } |
105 fetcher_->SetTestData(test_data_); | 104 fetcher_->SetTestData(test_data_); |
106 } | 105 } |
(...skipping 18 matching lines...) Expand all Loading... |
125 WaitForData(); | 124 WaitForData(); |
126 EXPECT_EQ(0, GetConnectedCounter()); | 125 EXPECT_EQ(0, GetConnectedCounter()); |
127 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter()); | 126 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter()); |
128 | 127 |
129 WaitForData(); | 128 WaitForData(); |
130 EXPECT_EQ(0, GetConnectedCounter()); | 129 EXPECT_EQ(0, GetConnectedCounter()); |
131 EXPECT_EQ(0, GetDisconnectedCounter()); | 130 EXPECT_EQ(0, GetDisconnectedCounter()); |
132 } | 131 } |
133 | 132 |
134 } // namespace content | 133 } // namespace content |
OLD | NEW |