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_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/run_loop.h" | 7 #include "base/run_loop.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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 ASSERT_FALSE(gatt_conn_.get()); | 201 ASSERT_FALSE(gatt_conn_.get()); |
202 ASSERT_EQ(0, success_callback_count_); | 202 ASSERT_EQ(0, success_callback_count_); |
203 ASSERT_EQ(0, error_callback_count_); | 203 ASSERT_EQ(0, error_callback_count_); |
204 | 204 |
205 device->CreateGattConnection( | 205 device->CreateGattConnection( |
206 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, | 206 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, |
207 base::Unretained(this)), | 207 base::Unretained(this)), |
208 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, | 208 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, |
209 base::Unretained(this))); | 209 base::Unretained(this))); |
210 | 210 |
211 EXPECT_EQ(1, success_callback_count_); | 211 EXPECT_EQ(1, success_callback_count_--); |
Jeffrey Yasskin
2015/08/19 20:43:46
I think it'd be easier to read to assign success_c
scheib
2015/09/13 02:39:56
I think the extra lines and code dilute the test i
| |
212 EXPECT_EQ(0, error_callback_count_); | 212 EXPECT_EQ(0, error_callback_count_); |
213 EXPECT_TRUE(device->IsConnected()); | 213 EXPECT_TRUE(device->IsConnected()); |
214 ASSERT_TRUE(gatt_conn_.get()); | 214 ASSERT_TRUE(gatt_conn_.get()); |
215 EXPECT_TRUE(gatt_conn_->IsConnected()); | 215 EXPECT_TRUE(gatt_conn_->IsConnected()); |
216 EXPECT_EQ(FakeBluetoothDeviceClient::kLowEnergyAddress, | 216 EXPECT_EQ(FakeBluetoothDeviceClient::kLowEnergyAddress, |
217 gatt_conn_->GetDeviceAddress()); | 217 gatt_conn_->GetDeviceAddress()); |
218 | 218 |
219 gatt_conn_->Disconnect( | 219 gatt_conn_->Disconnect(); |
220 base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, | |
221 base::Unretained(this))); | |
222 EXPECT_EQ(2, success_callback_count_); | |
223 EXPECT_EQ(0, error_callback_count_); | |
224 EXPECT_TRUE(device->IsConnected()); | 220 EXPECT_TRUE(device->IsConnected()); |
225 EXPECT_FALSE(gatt_conn_->IsConnected()); | 221 EXPECT_FALSE(gatt_conn_->IsConnected()); |
226 | 222 |
227 device->CreateGattConnection( | 223 device->CreateGattConnection( |
228 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, | 224 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, |
229 base::Unretained(this)), | 225 base::Unretained(this)), |
230 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, | 226 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, |
231 base::Unretained(this))); | 227 base::Unretained(this))); |
232 | 228 |
233 EXPECT_EQ(3, success_callback_count_); | 229 EXPECT_EQ(1, success_callback_count_--); |
234 EXPECT_EQ(0, error_callback_count_); | 230 EXPECT_EQ(0, error_callback_count_); |
235 EXPECT_TRUE(device->IsConnected()); | 231 EXPECT_TRUE(device->IsConnected()); |
236 ASSERT_TRUE(gatt_conn_.get()); | 232 ASSERT_TRUE(gatt_conn_.get()); |
237 EXPECT_TRUE(gatt_conn_->IsConnected()); | 233 EXPECT_TRUE(gatt_conn_->IsConnected()); |
238 | 234 |
239 device->Disconnect( | 235 device->Disconnect( |
240 base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, | 236 base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, |
241 base::Unretained(this)), | 237 base::Unretained(this)), |
242 base::Bind(&BluetoothGattChromeOSTest::ErrorCallback, | 238 base::Bind(&BluetoothGattChromeOSTest::ErrorCallback, |
243 base::Unretained(this))); | 239 base::Unretained(this))); |
244 | 240 |
245 EXPECT_EQ(4, success_callback_count_); | 241 EXPECT_EQ(1, success_callback_count_--); |
246 EXPECT_EQ(0, error_callback_count_); | 242 EXPECT_EQ(0, error_callback_count_); |
247 ASSERT_TRUE(gatt_conn_.get()); | 243 ASSERT_TRUE(gatt_conn_.get()); |
248 EXPECT_FALSE(gatt_conn_->IsConnected()); | 244 EXPECT_FALSE(gatt_conn_->IsConnected()); |
249 | 245 |
250 device->CreateGattConnection( | 246 device->CreateGattConnection( |
251 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, | 247 base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, |
252 base::Unretained(this)), | 248 base::Unretained(this)), |
253 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, | 249 base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, |
254 base::Unretained(this))); | 250 base::Unretained(this))); |
255 | 251 |
256 EXPECT_EQ(5, success_callback_count_); | 252 EXPECT_EQ(1, success_callback_count_--); |
257 EXPECT_EQ(0, error_callback_count_); | 253 EXPECT_EQ(0, error_callback_count_); |
258 EXPECT_TRUE(device->IsConnected()); | 254 EXPECT_TRUE(device->IsConnected()); |
259 EXPECT_TRUE(gatt_conn_->IsConnected()); | 255 EXPECT_TRUE(gatt_conn_->IsConnected()); |
260 | 256 |
261 fake_bluetooth_device_client_->RemoveDevice( | 257 fake_bluetooth_device_client_->RemoveDevice( |
262 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 258 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
263 dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); | 259 dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); |
264 ASSERT_TRUE(gatt_conn_.get()); | 260 ASSERT_TRUE(gatt_conn_.get()); |
265 EXPECT_FALSE(gatt_conn_->IsConnected()); | 261 EXPECT_FALSE(gatt_conn_->IsConnected()); |
266 } | 262 } |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1232 | 1228 |
1233 EXPECT_EQ(1, success_callback_count_); | 1229 EXPECT_EQ(1, success_callback_count_); |
1234 EXPECT_EQ(0, error_callback_count_); | 1230 EXPECT_EQ(0, error_callback_count_); |
1235 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); | 1231 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); |
1236 EXPECT_TRUE(characteristic->IsNotifying()); | 1232 EXPECT_TRUE(characteristic->IsNotifying()); |
1237 EXPECT_EQ(1U, update_sessions_.size()); | 1233 EXPECT_EQ(1U, update_sessions_.size()); |
1238 EXPECT_TRUE(update_sessions_[0]->IsActive()); | 1234 EXPECT_TRUE(update_sessions_[0]->IsActive()); |
1239 } | 1235 } |
1240 | 1236 |
1241 } // namespace chromeos | 1237 } // namespace chromeos |
OLD | NEW |