| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/gamepad/gamepad_consumer.h" | 7 #include "content/browser/gamepad/gamepad_consumer.h" |
| 8 #include "content/browser/gamepad/gamepad_service.h" | 8 #include "content/browser/gamepad/gamepad_service.h" |
| 9 #include "content/browser/gamepad/gamepad_test_helpers.h" | 9 #include "content/browser/gamepad/gamepad_test_helpers.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 int disconnected_counter() const { return disconnected_counter_; } | 42 int disconnected_counter() const { return disconnected_counter_; } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 int connected_counter_; | 45 int connected_counter_; |
| 46 int disconnected_counter_; | 46 int disconnected_counter_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 class GamepadServiceTest : public testing::Test { | 49 class GamepadServiceTest : public testing::Test { |
| 50 protected: | 50 protected: |
| 51 GamepadServiceTest(); | 51 GamepadServiceTest(); |
| 52 virtual ~GamepadServiceTest() override; | 52 ~GamepadServiceTest() override; |
| 53 | 53 |
| 54 void SetPadsConnected(bool connected); | 54 void SetPadsConnected(bool connected); |
| 55 void WaitForData(); | 55 void WaitForData(); |
| 56 | 56 |
| 57 int GetConnectedCounter() const { | 57 int GetConnectedCounter() const { |
| 58 return connection_listener_->connected_counter(); | 58 return connection_listener_->connected_counter(); |
| 59 } | 59 } |
| 60 int GetDisconnectedCounter() const { | 60 int GetDisconnectedCounter() const { |
| 61 return connection_listener_->disconnected_counter(); | 61 return connection_listener_->disconnected_counter(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void SetUp() override; | 64 void SetUp() override; |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 MockGamepadDataFetcher* fetcher_; | 67 MockGamepadDataFetcher* fetcher_; |
| 68 GamepadService* service_; | 68 GamepadService* service_; |
| 69 scoped_ptr<ConnectionListener> connection_listener_; | 69 scoped_ptr<ConnectionListener> connection_listener_; |
| 70 TestBrowserThreadBundle browser_thread_; | 70 TestBrowserThreadBundle browser_thread_; |
| 71 WebGamepads test_data_; | 71 WebGamepads test_data_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest); | 73 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTest); |
| 74 }; | 74 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 WaitForData(); | 121 WaitForData(); |
| 122 EXPECT_EQ(0, GetConnectedCounter()); | 122 EXPECT_EQ(0, GetConnectedCounter()); |
| 123 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter()); | 123 EXPECT_EQ(kNumberOfGamepads, GetDisconnectedCounter()); |
| 124 | 124 |
| 125 WaitForData(); | 125 WaitForData(); |
| 126 EXPECT_EQ(0, GetConnectedCounter()); | 126 EXPECT_EQ(0, GetConnectedCounter()); |
| 127 EXPECT_EQ(0, GetDisconnectedCounter()); | 127 EXPECT_EQ(0, GetDisconnectedCounter()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace content | 130 } // namespace content |
| OLD | NEW |