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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS Full build. Created 6 years, 8 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: chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
index f1113b8c9d1ef53f132d875e7dc17a7212cfcab9..4c1e85ff45dfdd4dda961faf8525db58a10622c9 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
@@ -74,7 +74,6 @@ class BluetoothApiTest : public ExtensionApiTest {
device3_.reset(new testing::NiceMock<MockBluetoothDevice>(
mock_adapter_, 0, "d3", "31:32:33:34:35:36",
false /* paired */, false /* connected */));
-
}
void DiscoverySessionCallback(
@@ -105,8 +104,11 @@ class BluetoothApiTest : public ExtensionApiTest {
scoped_ptr<testing::NiceMock<MockBluetoothProfile> > profile2_;
extensions::BluetoothEventRouter* event_router() {
- return extensions::BluetoothAPI::Get(browser()->profile())
- ->bluetooth_event_router();
+ return bluetooth_api()->event_router();
+ }
+
+ extensions::BluetoothAPI* bluetooth_api() {
+ return extensions::BluetoothAPI::Get(browser()->profile());
}
private:
@@ -154,6 +156,11 @@ static bool CallClosure(const base::Closure& callback) {
return true;
}
+static bool CallErrorClosure(const BluetoothDevice::ErrorCallback& callback) {
+ callback.Run();
+ return true;
+}
+
static void StopDiscoverySessionCallback(const base::Closure& callback,
const base::Closure& error_callback) {
callback.Run();
@@ -318,9 +325,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) {
testing::Mock::VerifyAndClearExpectations(device1_.get());
EXPECT_CALL(*mock_adapter_, GetDevice(device1_->GetAddress()))
.WillOnce(testing::Return(device1_.get()));
- EXPECT_CALL(*device1_,
- ClearOutOfBandPairingData(testing::_,
- testing::Truly(CallClosure)));
+ EXPECT_CALL(
+ *device1_,
+ ClearOutOfBandPairingData(testing::_, testing::Truly(CallErrorClosure)));
set_oob_function = setupFunction(
new api::BluetoothSetOutOfBandPairingDataFunction);
@@ -562,11 +569,17 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, OnConnection) {
scoped_refptr<device::MockBluetoothSocket> socket =
new device::MockBluetoothSocket();
+ EXPECT_CALL(*mock_adapter_, GetDevice(device1_->GetAddress()))
+ .WillOnce(testing::Return(device1_.get()));
+
event_router()->AddProfile(
- BluetoothUUID("1234"),
- extension->id(), profile1_.get());
- event_router()->DispatchConnectionEvent(
+ BluetoothUUID("1234"), extension->id(), profile1_.get());
+ bluetooth_api()->DispatchConnectionEvent(
extension->id(), BluetoothUUID("1234"), device1_.get(), socket);
+ // Connection events are dispatched using a couple of PostTask to the UI
+ // thread. Waiting until idle ensures the event is dispatched to the
+ // receiver(s).
+ base::RunLoop().RunUntilIdle();
listener.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();

Powered by Google App Engine
This is Rietveld 408576698