| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_vector.h" | 5 #include "base/memory/scoped_vector.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 last_device_(NULL), | 48 last_device_(NULL), |
| 49 adapter_(adapter) { | 49 adapter_(adapter) { |
| 50 adapter_->AddObserver(this); | 50 adapter_->AddObserver(this); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual ~TestObserver() { | 53 virtual ~TestObserver() { |
| 54 adapter_->RemoveObserver(this); | 54 adapter_->RemoveObserver(this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, | 57 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, |
| 58 bool present) OVERRIDE { | 58 bool present) override { |
| 59 EXPECT_EQ(adapter_.get(), adapter); | 59 EXPECT_EQ(adapter_.get(), adapter); |
| 60 | 60 |
| 61 ++present_changed_count_; | 61 ++present_changed_count_; |
| 62 last_present_ = present; | 62 last_present_ = present; |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, | 65 virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, |
| 66 bool powered) OVERRIDE { | 66 bool powered) override { |
| 67 EXPECT_EQ(adapter_.get(), adapter); | 67 EXPECT_EQ(adapter_.get(), adapter); |
| 68 | 68 |
| 69 ++powered_changed_count_; | 69 ++powered_changed_count_; |
| 70 last_powered_ = powered; | 70 last_powered_ = powered; |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void AdapterDiscoverableChanged(BluetoothAdapter* adapter, | 73 virtual void AdapterDiscoverableChanged(BluetoothAdapter* adapter, |
| 74 bool discoverable) OVERRIDE { | 74 bool discoverable) override { |
| 75 EXPECT_EQ(adapter_.get(), adapter); | 75 EXPECT_EQ(adapter_.get(), adapter); |
| 76 | 76 |
| 77 ++discoverable_changed_count_; | 77 ++discoverable_changed_count_; |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter, | 80 virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter, |
| 81 bool discovering) OVERRIDE { | 81 bool discovering) override { |
| 82 EXPECT_EQ(adapter_.get(), adapter); | 82 EXPECT_EQ(adapter_.get(), adapter); |
| 83 | 83 |
| 84 ++discovering_changed_count_; | 84 ++discovering_changed_count_; |
| 85 last_discovering_ = discovering; | 85 last_discovering_ = discovering; |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void DeviceAdded(BluetoothAdapter* adapter, | 88 virtual void DeviceAdded(BluetoothAdapter* adapter, |
| 89 BluetoothDevice* device) OVERRIDE { | 89 BluetoothDevice* device) override { |
| 90 EXPECT_EQ(adapter_.get(), adapter); | 90 EXPECT_EQ(adapter_.get(), adapter); |
| 91 | 91 |
| 92 ++device_added_count_; | 92 ++device_added_count_; |
| 93 last_device_ = device; | 93 last_device_ = device; |
| 94 last_device_address_ = device->GetAddress(); | 94 last_device_address_ = device->GetAddress(); |
| 95 | 95 |
| 96 QuitMessageLoop(); | 96 QuitMessageLoop(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void DeviceChanged(BluetoothAdapter* adapter, | 99 virtual void DeviceChanged(BluetoothAdapter* adapter, |
| 100 BluetoothDevice* device) OVERRIDE { | 100 BluetoothDevice* device) override { |
| 101 EXPECT_EQ(adapter_.get(), adapter); | 101 EXPECT_EQ(adapter_.get(), adapter); |
| 102 | 102 |
| 103 ++device_changed_count_; | 103 ++device_changed_count_; |
| 104 last_device_ = device; | 104 last_device_ = device; |
| 105 last_device_address_ = device->GetAddress(); | 105 last_device_address_ = device->GetAddress(); |
| 106 | 106 |
| 107 QuitMessageLoop(); | 107 QuitMessageLoop(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual void DeviceRemoved(BluetoothAdapter* adapter, | 110 virtual void DeviceRemoved(BluetoothAdapter* adapter, |
| 111 BluetoothDevice* device) OVERRIDE { | 111 BluetoothDevice* device) override { |
| 112 EXPECT_EQ(adapter_.get(), adapter); | 112 EXPECT_EQ(adapter_.get(), adapter); |
| 113 | 113 |
| 114 ++device_removed_count_; | 114 ++device_removed_count_; |
| 115 // Can't save device, it may be freed | 115 // Can't save device, it may be freed |
| 116 last_device_address_ = device->GetAddress(); | 116 last_device_address_ = device->GetAddress(); |
| 117 | 117 |
| 118 QuitMessageLoop(); | 118 QuitMessageLoop(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 int present_changed_count_; | 121 int present_changed_count_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 request_passkey_count_(0), | 153 request_passkey_count_(0), |
| 154 display_pincode_count_(0), | 154 display_pincode_count_(0), |
| 155 display_passkey_count_(0), | 155 display_passkey_count_(0), |
| 156 keys_entered_count_(0), | 156 keys_entered_count_(0), |
| 157 confirm_passkey_count_(0), | 157 confirm_passkey_count_(0), |
| 158 authorize_pairing_count_(0), | 158 authorize_pairing_count_(0), |
| 159 last_passkey_(9999999U), | 159 last_passkey_(9999999U), |
| 160 last_entered_(999U) {} | 160 last_entered_(999U) {} |
| 161 virtual ~TestPairingDelegate() {} | 161 virtual ~TestPairingDelegate() {} |
| 162 | 162 |
| 163 virtual void RequestPinCode(BluetoothDevice* device) OVERRIDE { | 163 virtual void RequestPinCode(BluetoothDevice* device) override { |
| 164 ++call_count_; | 164 ++call_count_; |
| 165 ++request_pincode_count_; | 165 ++request_pincode_count_; |
| 166 QuitMessageLoop(); | 166 QuitMessageLoop(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 virtual void RequestPasskey(BluetoothDevice* device) OVERRIDE { | 169 virtual void RequestPasskey(BluetoothDevice* device) override { |
| 170 ++call_count_; | 170 ++call_count_; |
| 171 ++request_passkey_count_; | 171 ++request_passkey_count_; |
| 172 QuitMessageLoop(); | 172 QuitMessageLoop(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual void DisplayPinCode(BluetoothDevice* device, | 175 virtual void DisplayPinCode(BluetoothDevice* device, |
| 176 const std::string& pincode) OVERRIDE { | 176 const std::string& pincode) override { |
| 177 ++call_count_; | 177 ++call_count_; |
| 178 ++display_pincode_count_; | 178 ++display_pincode_count_; |
| 179 last_pincode_ = pincode; | 179 last_pincode_ = pincode; |
| 180 QuitMessageLoop(); | 180 QuitMessageLoop(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 virtual void DisplayPasskey(BluetoothDevice* device, | 183 virtual void DisplayPasskey(BluetoothDevice* device, |
| 184 uint32 passkey) OVERRIDE { | 184 uint32 passkey) override { |
| 185 ++call_count_; | 185 ++call_count_; |
| 186 ++display_passkey_count_; | 186 ++display_passkey_count_; |
| 187 last_passkey_ = passkey; | 187 last_passkey_ = passkey; |
| 188 QuitMessageLoop(); | 188 QuitMessageLoop(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 virtual void KeysEntered(BluetoothDevice* device, uint32 entered) OVERRIDE { | 191 virtual void KeysEntered(BluetoothDevice* device, uint32 entered) override { |
| 192 ++call_count_; | 192 ++call_count_; |
| 193 ++keys_entered_count_; | 193 ++keys_entered_count_; |
| 194 last_entered_ = entered; | 194 last_entered_ = entered; |
| 195 QuitMessageLoop(); | 195 QuitMessageLoop(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 virtual void ConfirmPasskey(BluetoothDevice* device, | 198 virtual void ConfirmPasskey(BluetoothDevice* device, |
| 199 uint32 passkey) OVERRIDE { | 199 uint32 passkey) override { |
| 200 ++call_count_; | 200 ++call_count_; |
| 201 ++confirm_passkey_count_; | 201 ++confirm_passkey_count_; |
| 202 last_passkey_ = passkey; | 202 last_passkey_ = passkey; |
| 203 QuitMessageLoop(); | 203 QuitMessageLoop(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 virtual void AuthorizePairing(BluetoothDevice* device) OVERRIDE { | 206 virtual void AuthorizePairing(BluetoothDevice* device) override { |
| 207 ++call_count_; | 207 ++call_count_; |
| 208 ++authorize_pairing_count_; | 208 ++authorize_pairing_count_; |
| 209 QuitMessageLoop(); | 209 QuitMessageLoop(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 int call_count_; | 212 int call_count_; |
| 213 int request_pincode_count_; | 213 int request_pincode_count_; |
| 214 int request_passkey_count_; | 214 int request_passkey_count_; |
| 215 int display_pincode_count_; | 215 int display_pincode_count_; |
| 216 int display_passkey_count_; | 216 int display_passkey_count_; |
| (...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 // Unknown vendor specification identifier. | 3176 // Unknown vendor specification identifier. |
| 3177 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); | 3177 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); |
| 3178 | 3178 |
| 3179 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); | 3179 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); |
| 3180 EXPECT_EQ(0, device->GetVendorID()); | 3180 EXPECT_EQ(0, device->GetVendorID()); |
| 3181 EXPECT_EQ(0, device->GetProductID()); | 3181 EXPECT_EQ(0, device->GetProductID()); |
| 3182 EXPECT_EQ(0, device->GetDeviceID()); | 3182 EXPECT_EQ(0, device->GetDeviceID()); |
| 3183 } | 3183 } |
| 3184 | 3184 |
| 3185 } // namespace chromeos | 3185 } // namespace chromeos |
| OLD | NEW |