| Index: chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
|
| diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
|
| index db4332ad1c0096a1c18d4dcdaf64bab027fbc772..75ab69a8eef377cb880d09deceb38a7cf38a2320 100644
|
| --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
|
| +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
|
| @@ -25,6 +25,9 @@ namespace api = extensions::api;
|
|
|
| namespace {
|
|
|
| +static const char* kAddress = "01:02:03:04:05:06";
|
| +static const char* kName = "whatsinaname";
|
| +
|
| class BluetoothApiTest : public PlatformAppApiTest {
|
| public:
|
| BluetoothApiTest() : empty_extension_(utils::CreateEmptyExtension()) {}
|
| @@ -43,10 +46,9 @@ class BluetoothApiTest : public PlatformAppApiTest {
|
| }
|
|
|
| void expectBooleanResult(bool expected,
|
| - UIThreadExtensionFunction* function,
|
| - const std::string& args) {
|
| + UIThreadExtensionFunction* function) {
|
| scoped_ptr<base::Value> result(
|
| - utils::RunFunctionAndReturnSingleResult(function, args, browser()));
|
| + utils::RunFunctionAndReturnSingleResult(function, "[]", browser()));
|
| ASSERT_TRUE(result.get() != NULL);
|
| ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType());
|
| bool boolean_value;
|
| @@ -54,6 +56,17 @@ class BluetoothApiTest : public PlatformAppApiTest {
|
| EXPECT_EQ(expected, boolean_value);
|
| }
|
|
|
| + void expectStringResult(const std::string& expected,
|
| + UIThreadExtensionFunction* function) {
|
| + scoped_ptr<base::Value> result(
|
| + utils::RunFunctionAndReturnSingleResult(function, "[]", browser()));
|
| + ASSERT_TRUE(result.get() != NULL);
|
| + ASSERT_EQ(base::Value::TYPE_STRING, result->GetType());
|
| + std::string string_value;
|
| + result->GetAsString(&string_value);
|
| + EXPECT_EQ(expected, string_value);
|
| + }
|
| +
|
| template <class T>
|
| T* setupFunction(T* function) {
|
| function->set_extension(empty_extension_.get());
|
| @@ -110,14 +123,14 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, IsAvailable) {
|
| scoped_refptr<api::BluetoothIsAvailableFunction> is_available;
|
|
|
| is_available = setupFunction(new api::BluetoothIsAvailableFunction);
|
| - expectBooleanResult(false, is_available, "[]");
|
| + expectBooleanResult(false, is_available);
|
|
|
| testing::Mock::VerifyAndClearExpectations(mock_adapter_);
|
| EXPECT_CALL(*mock_adapter_, IsPresent())
|
| .WillOnce(testing::Return(true));
|
|
|
| is_available = setupFunction(new api::BluetoothIsAvailableFunction);
|
| - expectBooleanResult(true, is_available, "[]");
|
| + expectBooleanResult(true, is_available);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(BluetoothApiTest, IsPowered) {
|
| @@ -127,14 +140,32 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, IsPowered) {
|
| scoped_refptr<api::BluetoothIsPoweredFunction> is_powered;
|
|
|
| is_powered = setupFunction(new api::BluetoothIsPoweredFunction);
|
| - expectBooleanResult(false, is_powered, "[]");
|
| + expectBooleanResult(false, is_powered);
|
|
|
| testing::Mock::VerifyAndClearExpectations(mock_adapter_);
|
| EXPECT_CALL(*mock_adapter_, IsPowered())
|
| .WillOnce(testing::Return(true));
|
|
|
| is_powered = setupFunction(new api::BluetoothIsPoweredFunction);
|
| - expectBooleanResult(true, is_powered, "[]");
|
| + expectBooleanResult(true, is_powered);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetAddress) {
|
| + std::string address(kAddress);
|
| + EXPECT_CALL(*mock_adapter_, address()).WillOnce(testing::ReturnRef(address));
|
| +
|
| + scoped_refptr<api::BluetoothGetAddressFunction> get_address;
|
| + get_address = setupFunction(new api::BluetoothGetAddressFunction);
|
| + expectStringResult(address, get_address);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetName) {
|
| + std::string name(kName);
|
| + EXPECT_CALL(*mock_adapter_, name()).WillOnce(testing::ReturnRef(name));
|
| +
|
| + scoped_refptr<api::BluetoothGetNameFunction> get_name;
|
| + get_name = setupFunction(new api::BluetoothGetNameFunction);
|
| + expectStringResult(name, get_name);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
|
|
|