summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-18 03:51:42 +0000
committerbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-18 03:51:42 +0000
commit4d247c5ec7442f5a85e56aae400a91d5b50feb11 (patch)
tree4c2a5b5e09253741baeebf6ac8e483dcc765194a /chrome/browser/extensions
parentff21f1f64c6d297d0d10bf0d3a08677a9c505346 (diff)
downloadchromium_src-4d247c5ec7442f5a85e56aae400a91d5b50feb11.zip
chromium_src-4d247c5ec7442f5a85e56aae400a91d5b50feb11.tar.gz
chromium_src-4d247c5ec7442f5a85e56aae400a91d5b50feb11.tar.bz2
Change Bluetooth API to use options dictionaries.
TEST=ran the api tests BUG=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=142617 Review URL: https://chromiumcodereview.appspot.com/10535181 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_api.cc228
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_api.h46
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc70
3 files changed, 143 insertions, 201 deletions
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index 92ca8a3..9e7eebd 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -26,9 +26,6 @@
#include "chrome/browser/chromeos/extensions/bluetooth_event_router.h"
#include "chromeos/dbus/bluetooth_out_of_band_client.h"
-using chromeos::BluetoothAdapter;
-using chromeos::BluetoothDevice;
-
namespace {
chromeos::ExtensionBluetoothEventRouter* GetEventRouter(Profile* profile) {
@@ -65,8 +62,6 @@ base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device) {
namespace {
-const char kCouldNotClearOutOfBandPairingData[] =
- "Could not clear Out Of Band Pairing Data";
const char kCouldNotGetLocalOutOfBandPairingData[] =
"Could not get local Out Of Band Pairing Data";
const char kCouldNotSetOutOfBandPairingData[] =
@@ -79,16 +74,11 @@ const char kSocketNotFoundError[] = "Socket not found: invalid socket id";
namespace Connect = extensions::api::experimental_bluetooth::Connect;
namespace Disconnect = extensions::api::experimental_bluetooth::Disconnect;
-namespace GetDevicesWithServiceName =
- extensions::api::experimental_bluetooth::GetDevicesWithServiceName;
-namespace GetDevicesWithServiceUUID =
- extensions::api::experimental_bluetooth::GetDevicesWithServiceUUID;
+namespace GetDevices = extensions::api::experimental_bluetooth::GetDevices;
namespace Read = extensions::api::experimental_bluetooth::Read;
-namespace Write = extensions::api::experimental_bluetooth::Write;
namespace SetOutOfBandPairingData =
extensions::api::experimental_bluetooth::SetOutOfBandPairingData;
-namespace ClearOutOfBandPairingData =
- extensions::api::experimental_bluetooth::ClearOutOfBandPairingData;
+namespace Write = extensions::api::experimental_bluetooth::Write;
namespace extensions {
namespace api {
@@ -110,67 +100,70 @@ bool BluetoothGetAddressFunction::RunImpl() {
return true;
}
-bool BluetoothGetDevicesWithServiceUUIDFunction::RunImpl() {
- scoped_ptr<GetDevicesWithServiceUUID::Params> params(
- GetDevicesWithServiceUUID::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
-
- const BluetoothAdapter::ConstDeviceList& devices =
- GetAdapter(profile())->GetDevices();
- ListValue* matches = new ListValue;
- for (BluetoothAdapter::ConstDeviceList::const_iterator i =
- devices.begin(); i != devices.end(); ++i) {
- if ((*i)->ProvidesServiceWithUUID(params->uuid))
- matches->Append(BluetoothDeviceToValue(**i));
- }
- result_.reset(matches);
-
- return true;
-}
-
-BluetoothGetDevicesWithServiceNameFunction::
- BluetoothGetDevicesWithServiceNameFunction() : callbacks_pending_(0) {}
+BluetoothGetDevicesFunction::BluetoothGetDevicesFunction()
+ : callbacks_pending_(0) {}
-void BluetoothGetDevicesWithServiceNameFunction::AddDeviceIfTrue(
- ListValue* list, const BluetoothDevice* device, bool result) {
+void BluetoothGetDevicesFunction::AddDeviceIfTrueCallback(
+ ListValue* list,
+ const chromeos::BluetoothDevice* device,
+ bool shouldAdd) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (result)
+ if (shouldAdd)
list->Append(BluetoothDeviceToValue(*device));
callbacks_pending_--;
- if (callbacks_pending_ == 0) {
+ if (callbacks_pending_ == -1) {
SendResponse(true);
Release(); // Added in RunImpl
}
}
-bool BluetoothGetDevicesWithServiceNameFunction::RunImpl() {
+bool BluetoothGetDevicesFunction::RunImpl() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ scoped_ptr<GetDevices::Params> params(GetDevices::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
+ const experimental_bluetooth::GetDevicesOptions& options = params->options;
+
ListValue* matches = new ListValue;
result_.reset(matches);
- BluetoothAdapter::DeviceList devices =
- GetMutableAdapter(profile())->GetDevices();
- if (devices.empty()) {
- SendResponse(true);
- return true;
- }
+ CHECK_EQ(0, callbacks_pending_);
- callbacks_pending_ = devices.size();
- AddRef(); // Released in AddDeviceIfTrue when callbacks_pending_ == 0
+ // This will be released when callbacks_pending_ == -1. The count is checked
+ // for -1 because of the extra decrement after the for-loop, which ensures
+ // that all requests have been made before the Release happens.
+ AddRef();
- scoped_ptr<GetDevicesWithServiceName::Params> params(
- GetDevicesWithServiceName::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
- for (BluetoothAdapter::DeviceList::iterator i = devices.begin();
+ chromeos::BluetoothAdapter::DeviceList devices =
+ GetMutableAdapter(profile())->GetDevices();
+ for (chromeos::BluetoothAdapter::DeviceList::iterator i = devices.begin();
i != devices.end(); ++i) {
- (*i)->ProvidesServiceWithName(params->name,
- base::Bind(&BluetoothGetDevicesWithServiceNameFunction::AddDeviceIfTrue,
+ chromeos::BluetoothDevice* device = *i;
+
+ if (options.uuid.get() != NULL &&
+ !(device->ProvidesServiceWithUUID(*(options.uuid))))
+ continue;
+
+ if (options.name.get() == NULL) {
+ matches->Append(BluetoothDeviceToValue(*device));
+ continue;
+ }
+
+ callbacks_pending_++;
+ device->ProvidesServiceWithName(
+ *(options.name),
+ base::Bind(&BluetoothGetDevicesFunction::AddDeviceIfTrueCallback,
this,
matches,
- *i));
+ device));
+ }
+ callbacks_pending_--;
+
+ if (callbacks_pending_ == -1) {
+ SendResponse(true);
+ Release();
}
return true;
@@ -200,9 +193,10 @@ void BluetoothConnectFunction::ConnectToServiceCallback(
bool BluetoothConnectFunction::RunImpl() {
scoped_ptr<Connect::Params> params(Connect::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
+ const experimental_bluetooth::ConnectOptions& options = params->options;
chromeos::BluetoothDevice* device =
- GetMutableAdapter(profile())->GetDevice(params->device.address);
+ GetMutableAdapter(profile())->GetDevice(options.device_address);
if (!device) {
SendResponse(false);
SetError(kInvalidDevice);
@@ -210,25 +204,27 @@ bool BluetoothConnectFunction::RunImpl() {
}
AddRef(); // Released in ConnectToServiceCallback
- device->ConnectToService(params->service,
+ device->ConnectToService(options.service_uuid,
base::Bind(&BluetoothConnectFunction::ConnectToServiceCallback,
this,
device,
- params->service));
+ options.service_uuid));
return true;
}
bool BluetoothDisconnectFunction::RunImpl() {
scoped_ptr<Disconnect::Params> params(Disconnect::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
- return GetEventRouter(profile())->ReleaseSocket(params->socket.id);
+ const experimental_bluetooth::DisconnectOptions& options = params->options;
+ return GetEventRouter(profile())->ReleaseSocket(options.socket_id);
}
bool BluetoothReadFunction::Prepare() {
scoped_ptr<Read::Params> params(Read::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
+ const experimental_bluetooth::ReadOptions& options = params->options;
- socket_ = GetEventRouter(profile())->GetSocket(params->socket.id);
+ socket_ = GetEventRouter(profile())->GetSocket(options.socket_id);
if (socket_.get() == NULL) {
SetError(kSocketNotFoundError);
return false;
@@ -280,10 +276,10 @@ bool BluetoothReadFunction::Respond() {
bool BluetoothWriteFunction::Prepare() {
// TODO(bryeung): update to new-style parameter passing when ArrayBuffer
// support is added
- DictionaryValue* socket;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &socket));
+ DictionaryValue* options;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options));
int socket_id;
- EXTENSION_FUNCTION_VALIDATE(socket->GetInteger("id", &socket_id));
+ EXTENSION_FUNCTION_VALIDATE(options->GetInteger("socketId", &socket_id));
socket_ = GetEventRouter(profile())->GetSocket(socket_id);
if (socket_.get() == NULL) {
@@ -292,7 +288,7 @@ bool BluetoothWriteFunction::Prepare() {
}
base::BinaryValue* tmp_data;
- EXTENSION_FUNCTION_VALIDATE(args_->GetBinary(1, &tmp_data));
+ EXTENSION_FUNCTION_VALIDATE(options->GetBinary("data", &tmp_data));
data_to_write_ = tmp_data;
success_ = false;
@@ -339,27 +335,10 @@ void BluetoothSetOutOfBandPairingDataFunction::OnErrorCallback() {
bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() {
// TODO(bryeung): update to new-style parameter passing when ArrayBuffer
// support is added
+ DictionaryValue* options;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options));
std::string address;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &address));
- DictionaryValue* data_in;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &data_in));
-
- chromeos::BluetoothOutOfBandPairingData data_out;
-
- base::BinaryValue* tmp_data;
- EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("hash", &tmp_data));
- EXTENSION_FUNCTION_VALIDATE(
- tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize);
- memcpy(data_out.hash,
- reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()),
- chromeos::kBluetoothOutOfBandPairingDataSize);
-
- EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("randomizer", &tmp_data));
- EXTENSION_FUNCTION_VALIDATE(
- tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize);
- memcpy(data_out.randomizer,
- reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()),
- chromeos::kBluetoothOutOfBandPairingDataSize);
+ EXTENSION_FUNCTION_VALIDATE(options->GetString("deviceAddress", &address));
chromeos::BluetoothDevice* device =
GetMutableAdapter(profile())->GetDevice(address);
@@ -369,13 +348,41 @@ bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() {
return false;
}
- AddRef();
- device->SetOutOfBandPairingData(
- data_out,
- base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnSuccessCallback,
- this),
- base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnErrorCallback,
- this));
+ AddRef(); // Released in OnSuccessCallback or OnErrorCallback
+ if (options->HasKey("data")) {
+ DictionaryValue* data_in;
+ EXTENSION_FUNCTION_VALIDATE(options->GetDictionary("data", &data_in));
+
+ chromeos::BluetoothOutOfBandPairingData data_out;
+
+ base::BinaryValue* tmp_data;
+ EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("hash", &tmp_data));
+ EXTENSION_FUNCTION_VALIDATE(
+ tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize);
+ memcpy(data_out.hash,
+ reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()),
+ chromeos::kBluetoothOutOfBandPairingDataSize);
+
+ EXTENSION_FUNCTION_VALIDATE(data_in->GetBinary("randomizer", &tmp_data));
+ EXTENSION_FUNCTION_VALIDATE(
+ tmp_data->GetSize() == chromeos::kBluetoothOutOfBandPairingDataSize);
+ memcpy(data_out.randomizer,
+ reinterpret_cast<uint8_t*>(tmp_data->GetBuffer()),
+ chromeos::kBluetoothOutOfBandPairingDataSize);
+
+ device->SetOutOfBandPairingData(
+ data_out,
+ base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnSuccessCallback,
+ this),
+ base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnErrorCallback,
+ this));
+ } else {
+ device->ClearOutOfBandPairingData(
+ base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnSuccessCallback,
+ this),
+ base::Bind(&BluetoothSetOutOfBandPairingDataFunction::OnErrorCallback,
+ this));
+ }
return true;
}
@@ -417,39 +424,6 @@ bool BluetoothGetLocalOutOfBandPairingDataFunction::RunImpl() {
return true;
}
-void BluetoothClearOutOfBandPairingDataFunction::OnSuccessCallback() {
- SendResponse(true);
- Release(); // Added in RunImpl
-}
-
-void BluetoothClearOutOfBandPairingDataFunction::OnErrorCallback() {
- SetError(kCouldNotClearOutOfBandPairingData);
- SendResponse(false);
- Release(); // Added in RunImpl
-}
-
-bool BluetoothClearOutOfBandPairingDataFunction::RunImpl() {
- scoped_ptr<ClearOutOfBandPairingData::Params> params(
- ClearOutOfBandPairingData::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
-
- chromeos::BluetoothDevice* device =
- GetMutableAdapter(profile())->GetDevice(params->address);
- if (!device) {
- SendResponse(false);
- SetError(kInvalidDevice);
- return false;
- }
-
- AddRef(); // Released in one of the callbacks below
- device->ClearOutOfBandPairingData(
- base::Bind(&BluetoothClearOutOfBandPairingDataFunction::OnSuccessCallback,
- this),
- base::Bind(&BluetoothClearOutOfBandPairingDataFunction::OnErrorCallback,
- this));
- return true;
-}
-
#else
// -----------------------------------------------------------------------------
@@ -470,12 +444,7 @@ bool BluetoothGetAddressFunction::RunImpl() {
return false;
}
-bool BluetoothGetDevicesWithServiceUUIDFunction::RunImpl() {
- NOTREACHED() << "Not implemented yet";
- return false;
-}
-
-bool BluetoothGetDevicesWithServiceNameFunction::RunImpl() {
+bool BluetoothGetDevicesFunction::RunImpl() {
NOTREACHED() << "Not implemented yet";
return false;
}
@@ -524,11 +493,6 @@ bool BluetoothGetLocalOutOfBandPairingDataFunction::RunImpl() {
return false;
}
-bool BluetoothClearOutOfBandPairingDataFunction::RunImpl() {
- NOTREACHED() << "Not implemented yet";
- return false;
-}
-
#endif
BluetoothReadFunction::BluetoothReadFunction() {}
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
index 4096d96..669873a 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
@@ -60,39 +60,25 @@ class BluetoothGetAddressFunction : public SyncExtensionFunction {
virtual bool RunImpl() OVERRIDE;
};
-class BluetoothGetDevicesWithServiceUUIDFunction
- : public SyncExtensionFunction {
+class BluetoothGetDevicesFunction : public AsyncExtensionFunction {
public:
- DECLARE_EXTENSION_FUNCTION_NAME(
- "experimental.bluetooth.getDevicesWithServiceUUID")
-
- protected:
- virtual ~BluetoothGetDevicesWithServiceUUIDFunction() {}
-
- // ExtensionFunction:
- virtual bool RunImpl() OVERRIDE;
-};
-
-class BluetoothGetDevicesWithServiceNameFunction
- : public AsyncExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION_NAME(
- "experimental.bluetooth.getDevicesWithServiceName")
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getDevices")
#if defined(OS_CHROMEOS)
- BluetoothGetDevicesWithServiceNameFunction();
+ BluetoothGetDevicesFunction();
#endif
protected:
- virtual ~BluetoothGetDevicesWithServiceNameFunction() {}
+ virtual ~BluetoothGetDevicesFunction() {}
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
private:
#if defined(OS_CHROMEOS)
- void AddDeviceIfTrue(
- ListValue* list, const chromeos::BluetoothDevice* device, bool result);
+ void AddDeviceIfTrueCallback(ListValue* list,
+ const chromeos::BluetoothDevice* device,
+ bool shouldAdd);
int callbacks_pending_;
#endif
@@ -204,24 +190,6 @@ class BluetoothGetLocalOutOfBandPairingDataFunction
virtual bool RunImpl() OVERRIDE;
};
-class BluetoothClearOutOfBandPairingDataFunction
- : public AsyncExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION_NAME(
- "experimental.bluetooth.clearOutOfBandPairingData")
-
- protected:
- virtual ~BluetoothClearOutOfBandPairingDataFunction() {}
-
-#if defined(OS_CHROMEOS)
- void OnSuccessCallback();
- void OnErrorCallback();
-#endif
-
- // ExtensionFunction:
- virtual bool RunImpl() OVERRIDE;
-};
-
} // namespace api
} // namespace extensions
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
index 28eb44f..e445920 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
@@ -133,7 +133,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, IsPowered) {
expectBooleanResult(true, is_powered, "[]");
}
-IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) {
+IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
testing::NiceMock<chromeos::MockBluetoothDevice> device1(
mock_adapter_, "d1", "11:12:13:14:15:16",
true /* paired */, false /* bonded */, true /* connected */);
@@ -152,12 +152,13 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) {
EXPECT_CALL(*mock_adapter_, GetDevices())
.WillOnce(testing::Return(devices));
- scoped_refptr<api::BluetoothGetDevicesWithServiceUUIDFunction> get_devices;
+ scoped_refptr<api::BluetoothGetDevicesFunction> get_devices;
- get_devices =
- setupFunction(new api::BluetoothGetDevicesWithServiceUUIDFunction);
- scoped_ptr<base::Value> result(
- utils::RunFunctionAndReturnResult(get_devices, "[\"foo\"]", browser()));
+ get_devices = setupFunction(new api::BluetoothGetDevicesFunction);
+ scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult(
+ get_devices,
+ "[{\"uuid\":\"foo\"}]",
+ browser()));
ASSERT_EQ(base::Value::TYPE_LIST, result->GetType());
base::ListValue* list;
@@ -185,6 +186,20 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) {
bool connected;
ASSERT_TRUE(device->GetBoolean("connected", &connected));
EXPECT_FALSE(connected);
+
+ // Try again with no options
+ testing::Mock::VerifyAndClearExpectations(mock_adapter_);
+ EXPECT_CALL(*mock_adapter_, GetDevices())
+ .WillOnce(testing::Return(devices));
+
+ get_devices = setupFunction(new api::BluetoothGetDevicesFunction);
+ result.reset(
+ utils::RunFunctionAndReturnResult(get_devices, "[{}]", browser()));
+
+ ASSERT_EQ(base::Value::TYPE_LIST, result->GetType());
+ ASSERT_TRUE(result->GetAsList(&list));
+
+ EXPECT_EQ(2u, list->GetSize());
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) {
@@ -226,13 +241,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) {
EXPECT_FALSE(error.empty());
}
-IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DISABLED_SetOutOfBandPairingData) {
- // TODO(bryeung): Fill in this test once it is possible to include an
- // ArrayBuffer in the arguments to the RunFunctionAnd* methods.
- // crbug.com/132796
-}
-
-IN_PROC_BROWSER_TEST_F(BluetoothApiTest, ClearOutOfBandPairingData) {
+IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) {
std::string device_address("11:12:13:14:15:16");
testing::NiceMock<chromeos::MockBluetoothDevice> device(
mock_adapter_, "d1", device_address,
@@ -240,21 +249,19 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, ClearOutOfBandPairingData) {
EXPECT_CALL(*mock_adapter_, GetDevice(device_address))
.WillOnce(testing::Return(&device));
EXPECT_CALL(device,
- ClearOutOfBandPairingData(
- testing::Truly(CallClosure),
- testing::_));
+ ClearOutOfBandPairingData(testing::Truly(CallClosure),
+ testing::_));
- char buf[32];
- snprintf(buf, sizeof(buf), "[\"%s\"]", device_address.c_str());
+ char buf[64];
+ snprintf(buf, sizeof(buf),
+ "[{\"deviceAddress\":\"%s\"}]", device_address.c_str());
std::string params(buf);
- scoped_refptr<api::BluetoothClearOutOfBandPairingDataFunction>
- clear_oob_function;
- clear_oob_function = setupFunction(
- new api::BluetoothClearOutOfBandPairingDataFunction);
+ scoped_refptr<api::BluetoothSetOutOfBandPairingDataFunction> set_oob_function;
+ set_oob_function = setupFunction(
+ new api::BluetoothSetOutOfBandPairingDataFunction);
// There isn't actually a result.
- (void)utils::RunFunctionAndReturnResult(
- clear_oob_function, params, browser());
+ (void)utils::RunFunctionAndReturnResult(set_oob_function, params, browser());
// Try again with an error
testing::Mock::VerifyAndClearExpectations(mock_adapter_);
@@ -262,13 +269,16 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, ClearOutOfBandPairingData) {
EXPECT_CALL(*mock_adapter_, GetDevice(device_address))
.WillOnce(testing::Return(&device));
EXPECT_CALL(device,
- ClearOutOfBandPairingData(
- testing::_,
- testing::Truly(CallClosure)));
+ ClearOutOfBandPairingData(testing::_,
+ testing::Truly(CallClosure)));
- clear_oob_function = setupFunction(
- new api::BluetoothClearOutOfBandPairingDataFunction);
+ set_oob_function = setupFunction(
+ new api::BluetoothSetOutOfBandPairingDataFunction);
std::string error(
- utils::RunFunctionAndReturnError(clear_oob_function, params, browser()));
+ utils::RunFunctionAndReturnError(set_oob_function, params, browser()));
EXPECT_FALSE(error.empty());
+
+ // TODO(bryeung): Also test setting the data when there is support for
+ // ArrayBuffers in the arguments to the RunFunctionAnd* methods.
+ // crbug.com/132796
}