| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" | 8 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
| 9 #include "chrome/browser/extensions/bluetooth_event_router.h" | 9 #include "chrome/browser/extensions/bluetooth_event_router.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetName) { | 181 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetName) { |
| 182 scoped_refptr<api::BluetoothGetNameFunction> get_name; | 182 scoped_refptr<api::BluetoothGetNameFunction> get_name; |
| 183 get_name = setupFunction(new api::BluetoothGetNameFunction); | 183 get_name = setupFunction(new api::BluetoothGetNameFunction); |
| 184 expectStringResult(kName, get_name); | 184 expectStringResult(kName, get_name); |
| 185 } | 185 } |
| 186 | 186 |
| 187 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { | 187 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { |
| 188 EXPECT_CALL(*mock_adapter_, | 188 EXPECT_CALL(*mock_adapter_, |
| 189 ReadLocalOutOfBandPairingData(testing::_, testing::_)) | 189 ReadLocalOutOfBandPairingData(testing::_, testing::_)) |
| 190 .WillOnce(testing::Invoke(CallOutOfBandPairingDataCallback)); | 190 .WillOnce(testing::Invoke(CallOutOfBandPairingDataCallback)); |
| 191 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 192 .WillOnce(testing::Return()); |
| 191 | 193 |
| 192 scoped_refptr<api::BluetoothGetLocalOutOfBandPairingDataFunction> | 194 scoped_refptr<api::BluetoothGetLocalOutOfBandPairingDataFunction> |
| 193 get_oob_function(setupFunction( | 195 get_oob_function(setupFunction( |
| 194 new api::BluetoothGetLocalOutOfBandPairingDataFunction)); | 196 new api::BluetoothGetLocalOutOfBandPairingDataFunction)); |
| 195 | 197 |
| 196 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 198 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
| 197 get_oob_function, "[]", browser())); | 199 get_oob_function, "[]", browser())); |
| 198 | 200 |
| 199 base::DictionaryValue* dict; | 201 base::DictionaryValue* dict; |
| 200 EXPECT_TRUE(result->GetAsDictionary(&dict)); | 202 EXPECT_TRUE(result->GetAsDictionary(&dict)); |
| 201 | 203 |
| 202 base::BinaryValue* binary_value; | 204 base::BinaryValue* binary_value; |
| 203 EXPECT_TRUE(dict->GetBinary("hash", &binary_value)); | 205 EXPECT_TRUE(dict->GetBinary("hash", &binary_value)); |
| 204 EXPECT_STREQ(kOutOfBandPairingDataHash, | 206 EXPECT_STREQ(kOutOfBandPairingDataHash, |
| 205 std::string(binary_value->GetBuffer(), binary_value->GetSize()).c_str()); | 207 std::string(binary_value->GetBuffer(), binary_value->GetSize()).c_str()); |
| 206 EXPECT_TRUE(dict->GetBinary("randomizer", &binary_value)); | 208 EXPECT_TRUE(dict->GetBinary("randomizer", &binary_value)); |
| 207 EXPECT_STREQ(kOutOfBandPairingDataRandomizer, | 209 EXPECT_STREQ(kOutOfBandPairingDataRandomizer, |
| 208 std::string(binary_value->GetBuffer(), binary_value->GetSize()).c_str()); | 210 std::string(binary_value->GetBuffer(), binary_value->GetSize()).c_str()); |
| 209 | 211 |
| 210 // Try again with an error | 212 // Try again with an error |
| 211 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 213 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 212 EXPECT_CALL(*mock_adapter_, | 214 EXPECT_CALL(*mock_adapter_, |
| 213 ReadLocalOutOfBandPairingData( | 215 ReadLocalOutOfBandPairingData( |
| 214 testing::_, | 216 testing::_, |
| 215 testing::Truly(CallClosure))); | 217 testing::Truly(CallClosure))); |
| 218 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 219 .WillOnce(testing::Return()); |
| 216 | 220 |
| 217 get_oob_function = | 221 get_oob_function = |
| 218 setupFunction(new api::BluetoothGetLocalOutOfBandPairingDataFunction); | 222 setupFunction(new api::BluetoothGetLocalOutOfBandPairingDataFunction); |
| 219 | 223 |
| 220 std::string error( | 224 std::string error( |
| 221 utils::RunFunctionAndReturnError(get_oob_function, "[]", browser())); | 225 utils::RunFunctionAndReturnError(get_oob_function, "[]", browser())); |
| 222 EXPECT_FALSE(error.empty()); | 226 EXPECT_FALSE(error.empty()); |
| 223 } | 227 } |
| 224 | 228 |
| 225 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) { | 229 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) { |
| 226 std::string device_address("11:12:13:14:15:16"); | 230 std::string device_address("11:12:13:14:15:16"); |
| 227 EXPECT_CALL(*mock_adapter_, GetDevice(device_address)) | 231 EXPECT_CALL(*mock_adapter_, GetDevice(device_address)) |
| 228 .WillOnce(testing::Return(device1_.get())); | 232 .WillOnce(testing::Return(device1_.get())); |
| 229 EXPECT_CALL(*device1_, | 233 EXPECT_CALL(*device1_, |
| 230 ClearOutOfBandPairingData(testing::Truly(CallClosure), | 234 ClearOutOfBandPairingData(testing::Truly(CallClosure), |
| 231 testing::_)); | 235 testing::_)); |
| 236 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 237 .WillOnce(testing::Return()); |
| 232 | 238 |
| 233 std::string params = base::StringPrintf( | 239 std::string params = base::StringPrintf( |
| 234 "[{\"deviceAddress\":\"%s\"}]", device_address.c_str()); | 240 "[{\"deviceAddress\":\"%s\"}]", device_address.c_str()); |
| 235 | 241 |
| 236 scoped_refptr<api::BluetoothSetOutOfBandPairingDataFunction> set_oob_function; | 242 scoped_refptr<api::BluetoothSetOutOfBandPairingDataFunction> set_oob_function; |
| 237 set_oob_function = setupFunction( | 243 set_oob_function = setupFunction( |
| 238 new api::BluetoothSetOutOfBandPairingDataFunction); | 244 new api::BluetoothSetOutOfBandPairingDataFunction); |
| 239 // There isn't actually a result. | 245 // There isn't actually a result. |
| 240 (void)utils::RunFunctionAndReturnSingleResult( | 246 (void)utils::RunFunctionAndReturnSingleResult( |
| 241 set_oob_function, params, browser()); | 247 set_oob_function, params, browser()); |
| 242 | 248 |
| 243 // Try again with an error | 249 // Try again with an error |
| 244 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 250 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 245 testing::Mock::VerifyAndClearExpectations(device1_.get()); | 251 testing::Mock::VerifyAndClearExpectations(device1_.get()); |
| 246 EXPECT_CALL(*mock_adapter_, GetDevice(device_address)) | 252 EXPECT_CALL(*mock_adapter_, GetDevice(device_address)) |
| 247 .WillOnce(testing::Return(device1_.get())); | 253 .WillOnce(testing::Return(device1_.get())); |
| 248 EXPECT_CALL(*device1_, | 254 EXPECT_CALL(*device1_, |
| 249 ClearOutOfBandPairingData(testing::_, | 255 ClearOutOfBandPairingData(testing::_, |
| 250 testing::Truly(CallClosure))); | 256 testing::Truly(CallClosure))); |
| 257 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 258 .WillOnce(testing::Return()); |
| 251 | 259 |
| 252 set_oob_function = setupFunction( | 260 set_oob_function = setupFunction( |
| 253 new api::BluetoothSetOutOfBandPairingDataFunction); | 261 new api::BluetoothSetOutOfBandPairingDataFunction); |
| 254 std::string error( | 262 std::string error( |
| 255 utils::RunFunctionAndReturnError(set_oob_function, params, browser())); | 263 utils::RunFunctionAndReturnError(set_oob_function, params, browser())); |
| 256 EXPECT_FALSE(error.empty()); | 264 EXPECT_FALSE(error.empty()); |
| 257 | 265 |
| 258 // TODO(bryeung): Also test setting the data when there is support for | 266 // TODO(bryeung): Also test setting the data when there is support for |
| 259 // ArrayBuffers in the arguments to the RunFunctionAnd* methods. | 267 // ArrayBuffers in the arguments to the RunFunctionAnd* methods. |
| 260 // crbug.com/132796 | 268 // crbug.com/132796 |
| 261 } | 269 } |
| 262 | 270 |
| 263 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { | 271 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { |
| 264 // Try with a failure to start | 272 // Try with a failure to start |
| 265 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); | 273 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); |
| 266 EXPECT_CALL(*mock_adapter_, | 274 EXPECT_CALL(*mock_adapter_, |
| 267 SetDiscovering(true, | 275 SetDiscovering(true, |
| 268 testing::_, | 276 testing::_, |
| 269 testing::Truly(CallClosure))); | 277 testing::Truly(CallClosure))); |
| 278 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 279 .WillOnce(testing::Return()); |
| 270 scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function; | 280 scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function; |
| 271 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); | 281 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); |
| 272 std::string error( | 282 std::string error( |
| 273 utils::RunFunctionAndReturnError(start_function, "[]", browser())); | 283 utils::RunFunctionAndReturnError(start_function, "[]", browser())); |
| 274 ASSERT_TRUE(!error.empty()); | 284 ASSERT_TRUE(!error.empty()); |
| 275 | 285 |
| 276 // Reset for a successful start | 286 // Reset for a successful start |
| 277 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 287 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 278 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); | 288 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); |
| 279 EXPECT_CALL(*mock_adapter_, | 289 EXPECT_CALL(*mock_adapter_, |
| 280 SetDiscovering(true, | 290 SetDiscovering(true, |
| 281 testing::Truly(CallClosure), | 291 testing::Truly(CallClosure), |
| 282 testing::_)); | 292 testing::_)); |
| 293 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 294 .WillOnce(testing::Return()); |
| 283 | 295 |
| 284 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); | 296 start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); |
| 285 (void)utils::RunFunctionAndReturnError(start_function, "[]", browser()); | 297 (void)utils::RunFunctionAndReturnError(start_function, "[]", browser()); |
| 286 | 298 |
| 287 // Reset to try stopping | 299 // Reset to try stopping |
| 288 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 300 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 289 EXPECT_CALL(*mock_adapter_, | 301 EXPECT_CALL(*mock_adapter_, |
| 290 SetDiscovering(false, | 302 SetDiscovering(false, |
| 291 testing::Truly(CallClosure), | 303 testing::Truly(CallClosure), |
| 292 testing::_)); | 304 testing::_)); |
| 305 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 306 .WillOnce(testing::Return()); |
| 293 scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; | 307 scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; |
| 294 stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); | 308 stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); |
| 295 (void)utils::RunFunctionAndReturnSingleResult(stop_function, "[]", browser()); | 309 (void)utils::RunFunctionAndReturnSingleResult(stop_function, "[]", browser()); |
| 296 | 310 |
| 297 // Reset to try stopping with an error | 311 // Reset to try stopping with an error |
| 298 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 312 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 299 EXPECT_CALL(*mock_adapter_, | 313 EXPECT_CALL(*mock_adapter_, |
| 300 SetDiscovering(false, | 314 SetDiscovering(false, |
| 301 testing::_, | 315 testing::_, |
| 302 testing::Truly(CallClosure))); | 316 testing::Truly(CallClosure))); |
| 317 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 318 .WillOnce(testing::Return()); |
| 303 stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); | 319 stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); |
| 304 error = utils::RunFunctionAndReturnError(stop_function, "[]", browser()); | 320 error = utils::RunFunctionAndReturnError(stop_function, "[]", browser()); |
| 305 ASSERT_TRUE(!error.empty()); | 321 ASSERT_TRUE(!error.empty()); |
| 306 } | 322 } |
| 307 | 323 |
| 308 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryCallback) { | 324 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryCallback) { |
| 309 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); | 325 EXPECT_CALL(*mock_adapter_, IsDiscovering()).WillOnce(testing::Return(false)); |
| 310 EXPECT_CALL(*mock_adapter_, | 326 EXPECT_CALL(*mock_adapter_, |
| 311 SetDiscovering(true, testing::Truly(CallClosure), testing::_)); | 327 SetDiscovering(true, testing::Truly(CallClosure), testing::_)); |
| 312 EXPECT_CALL(*mock_adapter_, | 328 EXPECT_CALL(*mock_adapter_, |
| 313 SetDiscovering(false, testing::Truly(CallClosure), testing::_)); | 329 SetDiscovering(false, testing::Truly(CallClosure), testing::_)); |
| 330 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 331 .Times(testing::AtLeast(1)) |
| 332 .WillRepeatedly(testing::Return()); |
| 314 | 333 |
| 315 ResultCatcher catcher; | 334 ResultCatcher catcher; |
| 316 catcher.RestrictToProfile(browser()->profile()); | 335 catcher.RestrictToProfile(browser()->profile()); |
| 317 | 336 |
| 318 ExtensionTestMessageListener discovery_started("ready", true); | 337 ExtensionTestMessageListener discovery_started("ready", true); |
| 319 ASSERT_TRUE(LoadExtension( | 338 ASSERT_TRUE(LoadExtension( |
| 320 test_data_dir_.AppendASCII("bluetooth/discovery_callback"))); | 339 test_data_dir_.AppendASCII("bluetooth/discovery_callback"))); |
| 321 EXPECT_TRUE(discovery_started.WaitUntilSatisfied()); | 340 EXPECT_TRUE(discovery_started.WaitUntilSatisfied()); |
| 322 | 341 |
| 323 event_router()->DeviceAdded(mock_adapter_, device1_.get()); | 342 event_router()->DeviceAdded(mock_adapter_, device1_.get()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 382 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 364 CloseShellWindowsAndWaitForAppToExit(); | 383 CloseShellWindowsAndWaitForAppToExit(); |
| 365 } | 384 } |
| 366 | 385 |
| 367 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Events) { | 386 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Events) { |
| 368 ResultCatcher catcher; | 387 ResultCatcher catcher; |
| 369 catcher.RestrictToProfile(browser()->profile()); | 388 catcher.RestrictToProfile(browser()->profile()); |
| 370 | 389 |
| 371 // Load and wait for setup | 390 // Load and wait for setup |
| 372 ExtensionTestMessageListener listener("ready", true); | 391 ExtensionTestMessageListener listener("ready", true); |
| 392 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 393 .Times(testing::AtLeast(1)) |
| 394 .WillRepeatedly(testing::Return()); |
| 373 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("bluetooth/events"))); | 395 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("bluetooth/events"))); |
| 374 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 396 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 375 | 397 |
| 376 event_router()->AdapterPoweredChanged(mock_adapter_, true); | 398 event_router()->AdapterPoweredChanged(mock_adapter_, true); |
| 377 event_router()->AdapterPoweredChanged(mock_adapter_, false); | 399 event_router()->AdapterPoweredChanged(mock_adapter_, false); |
| 378 event_router()->AdapterPresentChanged(mock_adapter_, true); | 400 event_router()->AdapterPresentChanged(mock_adapter_, true); |
| 379 event_router()->AdapterPresentChanged(mock_adapter_, false); | 401 event_router()->AdapterPresentChanged(mock_adapter_, false); |
| 380 event_router()->AdapterDiscoveringChanged(mock_adapter_, true); | 402 event_router()->AdapterDiscoveringChanged(mock_adapter_, true); |
| 381 event_router()->AdapterDiscoveringChanged(mock_adapter_, false); | 403 event_router()->AdapterDiscoveringChanged(mock_adapter_, false); |
| 382 | 404 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 400 .WillOnce(testing::Invoke(CallProvidesServiceCallback<true>)); | 422 .WillOnce(testing::Invoke(CallProvidesServiceCallback<true>)); |
| 401 | 423 |
| 402 EXPECT_CALL(*device2_, ProvidesServiceWithUUID(testing::_)) | 424 EXPECT_CALL(*device2_, ProvidesServiceWithUUID(testing::_)) |
| 403 .WillOnce(testing::Return(true)); | 425 .WillOnce(testing::Return(true)); |
| 404 EXPECT_CALL(*device2_, ProvidesServiceWithName(testing::_, testing::_)) | 426 EXPECT_CALL(*device2_, ProvidesServiceWithName(testing::_, testing::_)) |
| 405 .WillOnce(testing::Invoke(CallProvidesServiceCallback<false>)); | 427 .WillOnce(testing::Invoke(CallProvidesServiceCallback<false>)); |
| 406 | 428 |
| 407 EXPECT_CALL(*mock_adapter_, GetDevices()) | 429 EXPECT_CALL(*mock_adapter_, GetDevices()) |
| 408 .Times(3) | 430 .Times(3) |
| 409 .WillRepeatedly(testing::Return(devices)); | 431 .WillRepeatedly(testing::Return(devices)); |
| 432 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 433 .Times(testing::AtLeast(1)) |
| 434 .WillRepeatedly(testing::Return()); |
| 410 | 435 |
| 411 // Load and wait for setup | 436 // Load and wait for setup |
| 412 ExtensionTestMessageListener listener("ready", true); | 437 ExtensionTestMessageListener listener("ready", true); |
| 413 ASSERT_TRUE( | 438 ASSERT_TRUE( |
| 414 LoadExtension(test_data_dir_.AppendASCII("bluetooth/get_devices"))); | 439 LoadExtension(test_data_dir_.AppendASCII("bluetooth/get_devices"))); |
| 415 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 440 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 416 | 441 |
| 417 listener.Reply("go"); | 442 listener.Reply("go"); |
| 418 | 443 |
| 419 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 444 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 420 CloseShellWindowsAndWaitForAppToExit(); | 445 CloseShellWindowsAndWaitForAppToExit(); |
| 421 } | 446 } |
| 422 | 447 |
| 423 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) { | 448 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) { |
| 424 ResultCatcher catcher; | 449 ResultCatcher catcher; |
| 425 catcher.RestrictToProfile(browser()->profile()); | 450 catcher.RestrictToProfile(browser()->profile()); |
| 426 | 451 |
| 427 BluetoothAdapter::ConstDeviceList devices; | 452 BluetoothAdapter::ConstDeviceList devices; |
| 428 devices.push_back(device1_.get()); | 453 devices.push_back(device1_.get()); |
| 429 | 454 |
| 430 // Save the callback to delay execution so that we can force the calls to | 455 // Save the callback to delay execution so that we can force the calls to |
| 431 // happen concurrently. This will be called after the listener is satisfied. | 456 // happen concurrently. This will be called after the listener is satisfied. |
| 432 BluetoothDevice::ProvidesServiceCallback* callback = | 457 BluetoothDevice::ProvidesServiceCallback* callback = |
| 433 new BluetoothDevice::ProvidesServiceCallback; | 458 new BluetoothDevice::ProvidesServiceCallback; |
| 434 EXPECT_CALL(*device1_, ProvidesServiceWithName(testing::_, testing::_)) | 459 EXPECT_CALL(*device1_, ProvidesServiceWithName(testing::_, testing::_)) |
| 435 .WillOnce(testing::SaveArg<1>(callback)); | 460 .WillOnce(testing::SaveArg<1>(callback)); |
| 436 | 461 |
| 437 EXPECT_CALL(*mock_adapter_, GetDevices()) | 462 EXPECT_CALL(*mock_adapter_, GetDevices()) |
| 438 .WillOnce(testing::Return(devices)); | 463 .WillOnce(testing::Return(devices)); |
| 464 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) |
| 465 .Times(testing::AtLeast(1)) |
| 466 .WillRepeatedly(testing::Return()); |
| 439 | 467 |
| 440 // Load and wait for setup | 468 // Load and wait for setup |
| 441 ExtensionTestMessageListener listener("ready", true); | 469 ExtensionTestMessageListener listener("ready", true); |
| 442 ASSERT_TRUE(LoadExtension( | 470 ASSERT_TRUE(LoadExtension( |
| 443 test_data_dir_.AppendASCII("bluetooth/get_devices_concurrently"))); | 471 test_data_dir_.AppendASCII("bluetooth/get_devices_concurrently"))); |
| 444 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 472 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 445 | 473 |
| 446 callback->Run(false); | 474 callback->Run(false); |
| 447 delete callback; | 475 delete callback; |
| 448 listener.Reply("go"); | 476 listener.Reply("go"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 459 ExtensionTestMessageListener listener("ready", true); | 487 ExtensionTestMessageListener listener("ready", true); |
| 460 ASSERT_TRUE(LoadExtension( | 488 ASSERT_TRUE(LoadExtension( |
| 461 test_data_dir_.AppendASCII("bluetooth/get_devices_error"))); | 489 test_data_dir_.AppendASCII("bluetooth/get_devices_error"))); |
| 462 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 490 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 463 | 491 |
| 464 listener.Reply("go"); | 492 listener.Reply("go"); |
| 465 | 493 |
| 466 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 494 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 467 CloseShellWindowsAndWaitForAppToExit(); | 495 CloseShellWindowsAndWaitForAppToExit(); |
| 468 } | 496 } |
| OLD | NEW |