Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: device/bluetooth/bluetooth_task_manager_win_unittest.cc

Issue 1107433002: Update {virtual,override} to follow C++11 style in device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync and git cl format Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_socket_win.h ('k') | device/hid/hid_connection_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ~BluetoothTaskObserver() override {}
24 }
25 24
26 virtual void AdapterStateChanged( 25 void AdapterStateChanged(
27 const device::BluetoothTaskManagerWin::AdapterState& state) override { 26 const device::BluetoothTaskManagerWin::AdapterState& state) override {
28 num_adapter_state_changed_++; 27 num_adapter_state_changed_++;
29 } 28 }
30 29
31 virtual void DiscoveryStarted(bool success) override { 30 void DiscoveryStarted(bool success) override { num_discovery_started_++; }
32 num_discovery_started_++;
33 }
34 31
35 virtual void DiscoveryStopped() override { 32 void DiscoveryStopped() override { num_discovery_stopped_++; }
36 num_discovery_stopped_++;
37 }
38 33
39 int num_adapter_state_changed() const { 34 int num_adapter_state_changed() const {
40 return num_adapter_state_changed_; 35 return num_adapter_state_changed_;
41 } 36 }
42 37
43 int num_discovery_started() const { 38 int num_discovery_started() const {
44 return num_discovery_started_; 39 return num_discovery_started_;
45 } 40 }
46 41
47 int num_discovery_stopped() const { 42 int num_discovery_stopped() const {
(...skipping 13 matching lines...) Expand all
61 class BluetoothTaskManagerWinTest : public testing::Test { 56 class BluetoothTaskManagerWinTest : public testing::Test {
62 public: 57 public:
63 BluetoothTaskManagerWinTest() 58 BluetoothTaskManagerWinTest()
64 : ui_task_runner_(new base::TestSimpleTaskRunner()), 59 : ui_task_runner_(new base::TestSimpleTaskRunner()),
65 bluetooth_task_runner_(new base::TestSimpleTaskRunner()), 60 bluetooth_task_runner_(new base::TestSimpleTaskRunner()),
66 task_manager_(new BluetoothTaskManagerWin(ui_task_runner_)), 61 task_manager_(new BluetoothTaskManagerWin(ui_task_runner_)),
67 has_bluetooth_stack_(device::bluetooth_init_win::HasBluetoothStack()) { 62 has_bluetooth_stack_(device::bluetooth_init_win::HasBluetoothStack()) {
68 task_manager_->InitializeWithBluetoothTaskRunner(bluetooth_task_runner_); 63 task_manager_->InitializeWithBluetoothTaskRunner(bluetooth_task_runner_);
69 } 64 }
70 65
71 virtual void SetUp() { 66 void SetUp() override { task_manager_->AddObserver(&observer_); }
72 task_manager_->AddObserver(&observer_);
73 }
74 67
75 virtual void TearDown() { 68 void TearDown() override { task_manager_->RemoveObserver(&observer_); }
76 task_manager_->RemoveObserver(&observer_);
77 }
78 69
79 int GetPollingIntervalMs() const { 70 int GetPollingIntervalMs() const {
80 return BluetoothTaskManagerWin::kPollIntervalMs; 71 return BluetoothTaskManagerWin::kPollIntervalMs;
81 } 72 }
82 73
83 protected: 74 protected:
84 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_; 75 scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_;
85 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_; 76 scoped_refptr<base::TestSimpleTaskRunner> bluetooth_task_runner_;
86 scoped_refptr<BluetoothTaskManagerWin> task_manager_; 77 scoped_refptr<BluetoothTaskManagerWin> task_manager_;
87 BluetoothTaskObserver observer_; 78 BluetoothTaskObserver observer_;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 bluetooth_task_runner_->RunPendingTasks(); 127 bluetooth_task_runner_->RunPendingTasks();
137 ui_task_runner_->RunPendingTasks(); 128 ui_task_runner_->RunPendingTasks();
138 EXPECT_EQ(1, observer_.num_discovery_started()); 129 EXPECT_EQ(1, observer_.num_discovery_started());
139 task_manager_->PostStopDiscoveryTask(); 130 task_manager_->PostStopDiscoveryTask();
140 bluetooth_task_runner_->RunPendingTasks(); 131 bluetooth_task_runner_->RunPendingTasks();
141 ui_task_runner_->RunPendingTasks(); 132 ui_task_runner_->RunPendingTasks();
142 EXPECT_EQ(1, observer_.num_discovery_stopped()); 133 EXPECT_EQ(1, observer_.num_discovery_stopped());
143 } 134 }
144 135
145 } // namespace device 136 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_win.h ('k') | device/hid/hid_connection_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698