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

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

Issue 910433002: Fix crash on second failed connect to a paired device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bugfix unit tests Created 5 years, 10 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_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // Cleanup the socket. 521 // Cleanup the socket.
522 socket->Disconnect( 522 socket->Disconnect(
523 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, 523 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback,
524 base::Unretained(this))); 524 base::Unretained(this)));
525 525
526 message_loop_.RunUntilIdle(); 526 message_loop_.RunUntilIdle();
527 527
528 EXPECT_EQ(1U, success_callback_count_); 528 EXPECT_EQ(1U, success_callback_count_);
529 } 529 }
530 530
531 TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) {
532 BluetoothDevice* device = adapter_->GetDevice(
533 FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress);
534 ASSERT_TRUE(device != NULL);
535
536 device->ConnectToService(
537 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid),
538 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback,
539 base::Unretained(this)),
540 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
541 base::Unretained(this)));
542 message_loop_.Run();
543
544 EXPECT_EQ(0U, success_callback_count_);
545 EXPECT_EQ(1U, error_callback_count_);
546 EXPECT_TRUE(last_socket_.get() == NULL);
547
548 device->ConnectToService(
549 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid),
550 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback,
551 base::Unretained(this)),
552 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
553 base::Unretained(this)));
554 message_loop_.Run();
555
556 EXPECT_EQ(0U, success_callback_count_);
557 EXPECT_EQ(2U, error_callback_count_);
558 EXPECT_TRUE(last_socket_.get() == NULL);
559 }
560
531 } // namespace chromeos 561 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698