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

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

Issue 11369055: Delayed adding BluetoothEventRouter as BluetoothAdapter observer until when the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed BluetoothApiTest Created 8 years, 1 month 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 f51440aefb3d2bf27c85be1a2085320fa28f9773..391d129610938fc6197d23784ce2d3d9140210e3 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
@@ -188,6 +188,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) {
EXPECT_CALL(*mock_adapter_,
ReadLocalOutOfBandPairingData(testing::_, testing::_))
.WillOnce(testing::Invoke(CallOutOfBandPairingDataCallback));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
scoped_refptr<api::BluetoothGetLocalOutOfBandPairingDataFunction>
get_oob_function(setupFunction(
@@ -213,6 +215,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) {
ReadLocalOutOfBandPairingData(
testing::_,
testing::Truly(CallClosure)));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
get_oob_function =
setupFunction(new api::BluetoothGetLocalOutOfBandPairingDataFunction);
@@ -229,6 +233,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) {
EXPECT_CALL(*device1_,
ClearOutOfBandPairingData(testing::Truly(CallClosure),
testing::_));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
std::string params = base::StringPrintf(
"[{\"deviceAddress\":\"%s\"}]", device_address.c_str());
@@ -248,6 +254,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) {
EXPECT_CALL(*device1_,
ClearOutOfBandPairingData(testing::_,
testing::Truly(CallClosure)));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
set_oob_function = setupFunction(
new api::BluetoothSetOutOfBandPairingDataFunction);
@@ -267,6 +275,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
SetDiscovering(true,
testing::_,
testing::Truly(CallClosure)));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function;
start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
std::string error(
@@ -280,6 +290,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
SetDiscovering(true,
testing::Truly(CallClosure),
testing::_));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
(void)utils::RunFunctionAndReturnError(start_function, "[]", browser());
@@ -290,6 +302,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
SetDiscovering(false,
testing::Truly(CallClosure),
testing::_));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function;
stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction);
(void)utils::RunFunctionAndReturnSingleResult(stop_function, "[]", browser());
@@ -300,6 +314,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
SetDiscovering(false,
testing::_,
testing::Truly(CallClosure)));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .WillOnce(testing::Return());
stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction);
error = utils::RunFunctionAndReturnError(stop_function, "[]", browser());
ASSERT_TRUE(!error.empty());
@@ -311,6 +327,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryCallback) {
SetDiscovering(true, testing::Truly(CallClosure), testing::_));
EXPECT_CALL(*mock_adapter_,
SetDiscovering(false, testing::Truly(CallClosure), testing::_));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .Times(testing::AtLeast(1))
+ .WillRepeatedly(testing::Return());
ResultCatcher catcher;
catcher.RestrictToProfile(browser()->profile());
@@ -370,6 +389,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Events) {
// Load and wait for setup
ExtensionTestMessageListener listener("ready", true);
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .Times(testing::AtLeast(1))
+ .WillRepeatedly(testing::Return());
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("bluetooth/events")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -407,6 +429,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
EXPECT_CALL(*mock_adapter_, GetDevices())
.Times(3)
.WillRepeatedly(testing::Return(devices));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .Times(testing::AtLeast(1))
+ .WillRepeatedly(testing::Return());
// Load and wait for setup
ExtensionTestMessageListener listener("ready", true);
@@ -436,6 +461,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) {
EXPECT_CALL(*mock_adapter_, GetDevices())
.WillOnce(testing::Return(devices));
+ EXPECT_CALL(*mock_adapter_, AddObserver(testing::_))
+ .Times(testing::AtLeast(1))
+ .WillRepeatedly(testing::Return());
// Load and wait for setup
ExtensionTestMessageListener listener("ready", true);

Powered by Google App Engine
This is Rietveld 408576698