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

Unified Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 982593002: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits, remove test debug logging Created 5 years, 9 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_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc
index 7da63b789c4de98ae3c903bcf58f45763f4fbe95..396b23d4ef4277782e8bb771cab87883f3d841b5 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -324,7 +324,8 @@ class BluetoothChromeOSTest : public testing::Test {
QuitMessageLoop();
}
- void ProfileRegisteredCallback(BluetoothAdapterProfileChromeOS*) {
+ void ProfileRegisteredCallback(BluetoothAdapterProfileChromeOS* profile) {
+ adapter_profile_ = profile;
++callback_count_;
QuitMessageLoop();
}
@@ -426,6 +427,7 @@ class BluetoothChromeOSTest : public testing::Test {
enum BluetoothDevice::ConnectErrorCode last_connect_error_;
std::string last_client_error_;
ScopedVector<BluetoothDiscoverySession> discovery_sessions_;
+ BluetoothAdapterProfileChromeOS* adapter_profile_;
private:
// Some tests use a message loop since background processing is simulated;
@@ -3188,6 +3190,8 @@ TEST_F(BluetoothChromeOSTest, Shutdown) {
EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path());
+ adapter_profile_ = NULL;
+
FakeBluetoothProfileServiceProviderDelegate profile_delegate;
adapter_chrome_os->UseProfile(
BluetoothUUID(), dbus::ObjectPath(""),
@@ -3196,11 +3200,10 @@ TEST_F(BluetoothChromeOSTest, Shutdown) {
base::Unretained(this)),
base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
base::Unretained(this)));
- base::MessageLoop::current()->Run();
- EXPECT_EQ(1, callback_count_--) << "UseProfile error";
- EXPECT_EQ(0, error_callback_count_) << "UseProfile error";
- adapter_chrome_os->ReleaseProfile(BluetoothUUID());
+ EXPECT_FALSE(adapter_profile_) << "UseProfile error";
+ EXPECT_EQ(0, callback_count_) << "UseProfile error";
+ EXPECT_EQ(1, error_callback_count_--) << "UseProfile error";
// Protected and private methods:
@@ -3258,6 +3261,8 @@ TEST_F(BluetoothChromeOSTest, Shutdown) {
// OnStopDiscovery tested in Shutdown_OnStopDiscovery
// OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError
+ adapter_profile_ = NULL;
+
// OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require
// UseProfile to be set first, do so again here just before calling them.
adapter_chrome_os->UseProfile(
@@ -3268,14 +3273,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) {
base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
base::Unretained(this)));
- adapter_chrome_os->OnRegisterProfile(
- BluetoothUUID(), dbus::ObjectPath(""), &profile_delegate,
- base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback,
- base::Unretained(this)),
- base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
- base::Unretained(this)));
- EXPECT_EQ(1, callback_count_--) << "OnRegisterProfile error";
- EXPECT_EQ(1, error_callback_count_--) << "OnRegisterProfile error";
+ EXPECT_FALSE(adapter_profile_) << "UseProfile error";
+ EXPECT_EQ(0, callback_count_) << "UseProfile error";
+ EXPECT_EQ(1, error_callback_count_--) << "UseProfile error";
adapter_chrome_os->SetProfileDelegate(
BluetoothUUID(), dbus::ObjectPath(""), &profile_delegate,
@@ -3286,13 +3286,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) {
EXPECT_EQ(0, callback_count_) << "SetProfileDelegate error";
EXPECT_EQ(1, error_callback_count_--) << "SetProfileDelegate error";
- adapter_chrome_os->OnRegisterProfileError(
- BluetoothUUID(),
- base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
- base::Unretained(this)),
- "", "");
+ adapter_chrome_os->OnRegisterProfileError(BluetoothUUID(), "", "");
EXPECT_EQ(0, callback_count_) << "OnRegisterProfileError error";
- EXPECT_EQ(1, error_callback_count_--) << "OnRegisterProfileError error";
+ EXPECT_EQ(0, error_callback_count_) << "OnRegisterProfileError error";
adapter_chrome_os->ProcessQueuedDiscoveryRequests();
« no previous file with comments | « device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc ('k') | device/bluetooth/bluetooth_socket_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698