| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "components/exo/buffer.h" | 8 #include "components/exo/buffer.h" |
| 9 #include "components/exo/gamepad.h" | 9 #include "components/exo/gamepad.h" |
| 10 #include "components/exo/gamepad_delegate.h" | 10 #include "components/exo/gamepad_delegate.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 std::unique_ptr<device::GamepadDataFetcher> MockDataFetcherFactory() { | 40 std::unique_ptr<device::GamepadDataFetcher> MockDataFetcherFactory() { |
| 41 blink::WebGamepads initial_data; | 41 blink::WebGamepads initial_data; |
| 42 std::unique_ptr<device::MockGamepadDataFetcher> fetcher( | 42 std::unique_ptr<device::MockGamepadDataFetcher> fetcher( |
| 43 new device::MockGamepadDataFetcher(initial_data)); | 43 new device::MockGamepadDataFetcher(initial_data)); |
| 44 mock_data_fetcher_ = fetcher.get(); | 44 mock_data_fetcher_ = fetcher.get(); |
| 45 return std::move(fetcher); | 45 return std::move(fetcher); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void InitializeGamepad(MockGamepadDelegate* delegate) { | 48 void InitializeGamepad(MockGamepadDelegate* delegate) { |
| 49 polling_task_runner_ = new base::TestSimpleTaskRunner(); | 49 polling_task_runner_ = new base::TestSimpleTaskRunner(); |
| 50 gamepad_.reset(new Gamepad(delegate, polling_task_runner_.get(), | 50 gamepad_.reset(new Gamepad(delegate, polling_task_runner_, |
| 51 base::Bind(&GamepadTest::MockDataFetcherFactory, | 51 base::Bind(&GamepadTest::MockDataFetcherFactory, |
| 52 base::Unretained(this)))); | 52 base::Unretained(this)))); |
| 53 // Run the polling task runner to have it create the data fetcher. | 53 // Run the polling task runner to have it create the data fetcher. |
| 54 polling_task_runner_->RunPendingTasks(); | 54 polling_task_runner_->RunPendingTasks(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DestroyGamepad(MockGamepadDelegate* delegate) { | 57 void DestroyGamepad(MockGamepadDelegate* delegate) { |
| 58 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1); | 58 EXPECT_CALL(*delegate, OnGamepadDestroying(testing::_)).Times(1); |
| 59 mock_data_fetcher_ = nullptr; | 59 mock_data_fetcher_ = nullptr; |
| 60 gamepad_.reset(); | 60 gamepad_.reset(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // scheduled in the next round. | 212 // scheduled in the next round. |
| 213 polling_task_runner_->RunPendingTasks(); | 213 polling_task_runner_->RunPendingTasks(); |
| 214 polling_task_runner_->RunPendingTasks(); | 214 polling_task_runner_->RunPendingTasks(); |
| 215 ASSERT_FALSE(polling_task_runner_->HasPendingTask()); | 215 ASSERT_FALSE(polling_task_runner_->HasPendingTask()); |
| 216 | 216 |
| 217 DestroyGamepad(&delegate); | 217 DestroyGamepad(&delegate); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace | 220 } // namespace |
| 221 } // namespace exo | 221 } // namespace exo |
| OLD | NEW |