| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/bluetooth/bluez/bluetooth_adapter_profile_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_adapter_profile_bluez.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 void TearDown() override { | 73 void TearDown() override { |
| 74 profile_.reset(); | 74 profile_.reset(); |
| 75 adapter_ = nullptr; | 75 adapter_ = nullptr; |
| 76 bluez::BluezDBusManager::Shutdown(); | 76 bluez::BluezDBusManager::Shutdown(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 79 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
| 80 adapter_ = adapter; | 80 adapter_ = adapter; |
| 81 if (base::MessageLoop::current() && | 81 if (base::RunLoop::IsRunningOnCurrentThread()) |
| 82 base::MessageLoop::current()->is_running()) { | |
| 83 base::MessageLoop::current()->QuitWhenIdle(); | 82 base::MessageLoop::current()->QuitWhenIdle(); |
| 84 } | |
| 85 } | 83 } |
| 86 | 84 |
| 87 class FakeDelegate : public bluez::BluetoothProfileServiceProvider::Delegate { | 85 class FakeDelegate : public bluez::BluetoothProfileServiceProvider::Delegate { |
| 88 public: | 86 public: |
| 89 FakeDelegate(const std::string& device_path) : connections_(0) { | 87 FakeDelegate(const std::string& device_path) : connections_(0) { |
| 90 device_path_ = dbus::ObjectPath(device_path); | 88 device_path_ = dbus::ObjectPath(device_path); |
| 91 } | 89 } |
| 92 | 90 |
| 93 // bluez::BluetoothProfileServiceProvider::Delegate: | 91 // bluez::BluetoothProfileServiceProvider::Delegate: |
| 94 void Released() override { | 92 void Released() override { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 base::Unretained(this))); | 379 base::Unretained(this))); |
| 382 | 380 |
| 383 base::RunLoop().RunUntilIdle(); | 381 base::RunLoop().RunUntilIdle(); |
| 384 | 382 |
| 385 EXPECT_FALSE(profile_user_ptr_); | 383 EXPECT_FALSE(profile_user_ptr_); |
| 386 EXPECT_EQ(0U, success_callback_count_); | 384 EXPECT_EQ(0U, success_callback_count_); |
| 387 EXPECT_EQ(2U, error_callback_count_); | 385 EXPECT_EQ(2U, error_callback_count_); |
| 388 } | 386 } |
| 389 | 387 |
| 390 } // namespace bluez | 388 } // namespace bluez |
| OLD | NEW |