| 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 42b7aa3379aedabfc1693eb17f17446ab20cdbc1..6b29dd241c0b53fe1354d14ff21489bc5fd279ef 100644
|
| --- a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
|
| +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc
|
| @@ -20,6 +20,14 @@
|
| using device::BluetoothAdapter;
|
| using device::BluetoothUUID;
|
|
|
| +namespace {
|
| +
|
| +void DoNothingDBusErrorCallback(const std::string& error_name,
|
| + const std::string& error_message) {
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| namespace chromeos {
|
|
|
| class BluetoothAdapterProfileChromeOSTest : public testing::Test {
|
| @@ -94,7 +102,7 @@
|
| close(fd->TakeValue());
|
| callback.Run(SUCCESS);
|
| if (device_path_.value() != "")
|
| - ASSERT_EQ(device_path_, device_path);
|
| + ASSERT_TRUE(device_path == device_path_);
|
| }
|
|
|
| void RequestDisconnection(const dbus::ObjectPath& device_path,
|
| @@ -119,17 +127,6 @@
|
|
|
| BluetoothAdapterProfileChromeOS* profile_;
|
|
|
| - void ProfileSuccessCallback(BluetoothAdapterProfileChromeOS* profile) {
|
| - profile_ = profile;
|
| - ++success_callback_count_;
|
| - }
|
| -
|
| - void MatchedProfileCallback(BluetoothAdapterProfileChromeOS* profile) {
|
| - VLOG(1) << "Matched Profile Callback";
|
| - ASSERT_EQ(profile_, profile);
|
| - ++success_callback_count_;
|
| - }
|
| -
|
| void DBusConnectSuccessCallback() { ++success_callback_count_; }
|
|
|
| void DBusErrorCallback(const std::string& error_name,
|
| @@ -138,11 +135,6 @@
|
| ++error_callback_count_;
|
| }
|
|
|
| - void BasicErrorCallback(const std::string& error_message) {
|
| - VLOG(1) << "Error: " << error_message;
|
| - ++error_callback_count_;
|
| - }
|
| -
|
| protected:
|
| base::MessageLoop message_loop_;
|
|
|
| @@ -158,18 +150,13 @@
|
|
|
| options.require_authentication.reset(new bool(false));
|
|
|
| - BluetoothAdapterProfileChromeOS::Register(
|
| - uuid, options,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback,
|
| - base::Unretained(this)),
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback,
|
| - base::Unretained(this)));
|
| + profile_ = BluetoothAdapterProfileChromeOS::Register(
|
| + static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
|
| + base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback));
|
|
|
| message_loop_.RunUntilIdle();
|
|
|
| EXPECT_TRUE(profile_);
|
| - EXPECT_EQ(1U, success_callback_count_);
|
| - EXPECT_EQ(0U, error_callback_count_);
|
|
|
| EXPECT_EQ(0U, profile_->DelegateCount());
|
|
|
| @@ -197,10 +184,11 @@
|
|
|
| options.require_authentication.reset(new bool(false));
|
|
|
| - BluetoothAdapterProfileChromeOS::Register(
|
| - uuid, options,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback,
|
| - base::Unretained(this)),
|
| + profile_ = BluetoothAdapterProfileChromeOS::Register(
|
| + static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
|
| + base::Bind(
|
| + &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
|
| + base::Unretained(this)),
|
| base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback,
|
| base::Unretained(this)));
|
|
|
| @@ -236,17 +224,16 @@
|
| options.require_authentication.reset(new bool(false));
|
|
|
| profile_ = BluetoothAdapterProfileChromeOS::Register(
|
| - uuid, options,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback,
|
| - base::Unretained(this)),
|
| + static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options,
|
| + base::Bind(
|
| + &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
|
| + base::Unretained(this)),
|
| base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback,
|
| base::Unretained(this)));
|
|
|
| message_loop_.RunUntilIdle();
|
|
|
| ASSERT_TRUE(profile_);
|
| - ASSERT_EQ(1U, success_callback_count_);
|
| - ASSERT_EQ(0U, error_callback_count_);
|
|
|
| profile_->SetDelegate(fake_delegate_paired_.device_path_,
|
| &fake_delegate_paired_);
|
| @@ -307,75 +294,4 @@
|
| delete profile_;
|
| };
|
|
|
| -TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) {
|
| - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid);
|
| - BluetoothProfileManagerClient::Options options;
|
| - BluetoothAdapterChromeOS* adapter =
|
| - static_cast<BluetoothAdapterChromeOS*>(adapter_.get());
|
| -
|
| - options.require_authentication.reset(new bool(false));
|
| -
|
| - success_callback_count_ = 0;
|
| - error_callback_count_ = 0;
|
| -
|
| - adapter->UseProfile(
|
| - uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback,
|
| - base::Unretained(this)),
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback,
|
| - base::Unretained(this)));
|
| -
|
| - adapter->UseProfile(
|
| - uuid, fake_delegate_autopair_.device_path_, options,
|
| - &fake_delegate_autopair_,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback,
|
| - base::Unretained(this)),
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback,
|
| - base::Unretained(this)));
|
| -
|
| - message_loop_.RunUntilIdle();
|
| -
|
| - EXPECT_TRUE(profile_);
|
| - EXPECT_EQ(2U, success_callback_count_);
|
| - EXPECT_EQ(0U, error_callback_count_);
|
| -
|
| - adapter->ReleaseProfile(fake_delegate_paired_.device_path_, profile_);
|
| - adapter->ReleaseProfile(fake_delegate_autopair_.device_path_, profile_);
|
| -
|
| - message_loop_.RunUntilIdle();
|
| -};
|
| -
|
| -TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) {
|
| - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid);
|
| - BluetoothProfileManagerClient::Options options;
|
| - BluetoothAdapterChromeOS* adapter =
|
| - static_cast<BluetoothAdapterChromeOS*>(adapter_.get());
|
| -
|
| - options.require_authentication.reset(new bool(false));
|
| -
|
| - success_callback_count_ = 0;
|
| - error_callback_count_ = 0;
|
| -
|
| - adapter->UseProfile(
|
| - uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback,
|
| - base::Unretained(this)),
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback,
|
| - base::Unretained(this)));
|
| -
|
| - adapter->UseProfile(
|
| - uuid, fake_delegate_autopair_.device_path_, options,
|
| - &fake_delegate_autopair_,
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback,
|
| - base::Unretained(this)),
|
| - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback,
|
| - base::Unretained(this)));
|
| -
|
| - message_loop_.RunUntilIdle();
|
| -
|
| - EXPECT_FALSE(profile_);
|
| - EXPECT_EQ(0U, success_callback_count_);
|
| - EXPECT_EQ(2U, error_callback_count_);
|
| -};
|
| -
|
| } // namespace chromeos
|
|
|