| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/test/test_pending_task.h" | 7 #include "base/test/test_pending_task.h" |
| 8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "device/bluetooth/bluetooth_init_win.h" | 9 #include "device/bluetooth/bluetooth_init_win.h" |
| 10 #include "device/bluetooth/bluetooth_task_manager_win.h" | 10 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class BluetoothTaskObserver : public device::BluetoothTaskManagerWin::Observer { | 15 class BluetoothTaskObserver : public device::BluetoothTaskManagerWin::Observer { |
| 16 public: | 16 public: |
| 17 BluetoothTaskObserver() | 17 BluetoothTaskObserver() |
| 18 : num_adapter_state_changed_(0), | 18 : num_adapter_state_changed_(0), |
| 19 num_discovery_started_(0), | 19 num_discovery_started_(0), |
| 20 num_discovery_stopped_(0) { | 20 num_discovery_stopped_(0) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 virtual ~BluetoothTaskObserver() { | 23 virtual ~BluetoothTaskObserver() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void AdapterStateChanged( | 26 virtual void AdapterStateChanged( |
| 27 const device::BluetoothTaskManagerWin::AdapterState& state) OVERRIDE { | 27 const device::BluetoothTaskManagerWin::AdapterState& state) override { |
| 28 num_adapter_state_changed_++; | 28 num_adapter_state_changed_++; |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual void DiscoveryStarted(bool success) OVERRIDE { | 31 virtual void DiscoveryStarted(bool success) override { |
| 32 num_discovery_started_++; | 32 num_discovery_started_++; |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void DiscoveryStopped() OVERRIDE { | 35 virtual void DiscoveryStopped() override { |
| 36 num_discovery_stopped_++; | 36 num_discovery_stopped_++; |
| 37 } | 37 } |
| 38 | 38 |
| 39 int num_adapter_state_changed() const { | 39 int num_adapter_state_changed() const { |
| 40 return num_adapter_state_changed_; | 40 return num_adapter_state_changed_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 int num_discovery_started() const { | 43 int num_discovery_started() const { |
| 44 return num_discovery_started_; | 44 return num_discovery_started_; |
| 45 } | 45 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bluetooth_task_runner_->RunPendingTasks(); | 136 bluetooth_task_runner_->RunPendingTasks(); |
| 137 ui_task_runner_->RunPendingTasks(); | 137 ui_task_runner_->RunPendingTasks(); |
| 138 EXPECT_EQ(1, observer_.num_discovery_started()); | 138 EXPECT_EQ(1, observer_.num_discovery_started()); |
| 139 task_manager_->PostStopDiscoveryTask(); | 139 task_manager_->PostStopDiscoveryTask(); |
| 140 bluetooth_task_runner_->RunPendingTasks(); | 140 bluetooth_task_runner_->RunPendingTasks(); |
| 141 ui_task_runner_->RunPendingTasks(); | 141 ui_task_runner_->RunPendingTasks(); |
| 142 EXPECT_EQ(1, observer_.num_discovery_stopped()); | 142 EXPECT_EQ(1, observer_.num_discovery_stopped()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace device | 145 } // namespace device |
| OLD | NEW |