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

Unified Diff: device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc

Issue 935383003: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
index 6b29dd241c0b53fe1354d14ff21489bc5fd279ef..678fc49409084f652727530e9ee9cfdfa627393c 100644
--- a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
@@ -63,6 +63,9 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test {
ASSERT_TRUE(adapter_->IsInitialized());
ASSERT_TRUE(adapter_->IsPresent());
+ adapter_ptr_factory_ = new base::WeakPtrFactory<BluetoothAdapterChromeOS>(
+ static_cast<BluetoothAdapterChromeOS*>(adapter_.get()));
+
// Turn on the adapter.
adapter_->SetPowered(true, base::Bind(&base::DoNothing),
base::Bind(&base::DoNothing));
@@ -138,6 +141,7 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test {
protected:
base::MessageLoop message_loop_;
+ base::WeakPtrFactory<BluetoothAdapterChromeOS>* adapter_ptr_factory_;
scoped_refptr<BluetoothAdapter> adapter_;
unsigned int success_callback_count_;
@@ -151,7 +155,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) {
options.require_authentication.reset(new bool(false));
profile_ = BluetoothAdapterProfileChromeOS::Register(
- static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
+ adapter_ptr_factory_->GetWeakPtr(), uuid, options,
base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback));
message_loop_.RunUntilIdle();
@@ -185,7 +189,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) {
options.require_authentication.reset(new bool(false));
profile_ = BluetoothAdapterProfileChromeOS::Register(
- static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
+ adapter_ptr_factory_->GetWeakPtr(), uuid, options,
base::Bind(
&BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
base::Unretained(this)),
@@ -224,7 +228,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) {
options.require_authentication.reset(new bool(false));
profile_ = BluetoothAdapterProfileChromeOS::Register(
- static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
+ adapter_ptr_factory_->GetWeakPtr(), uuid, options,
base::Bind(
&BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
base::Unretained(this)),

Powered by Google App Engine
This is Rietveld 408576698