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

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

Issue 10536159: Bluetooth Extension API: Add a discovery API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 6 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_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 f24a80ffbf5e92ce1ecd31917be3eebfa361ad14..6a96664ba06f182339363483459d6445776009cf 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
@@ -22,13 +22,6 @@ using extensions::Extension;
namespace utils = extension_function_test_utils;
namespace api = extensions::api;
-namespace chromeos {
-
-class BluetoothAdapater;
-
-} // namespace chromeos
-
-
namespace {
class BluetoothApiTest : public PlatformAppApiTest {
@@ -282,3 +275,52 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) {
// ArrayBuffers in the arguments to the RunFunctionAnd* methods.
// crbug.com/132796
}
+
+IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
+ // TODO(bryeung): test that no events are sent now (crbug.com/132616)
+
+ // Try with a failure to start
+ EXPECT_CALL(*mock_adapter_,
+ SetDiscovering(true,
+ testing::_,
+ testing::Truly(CallClosure)));
+ scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function;
+ start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
+ std::string error(
+ utils::RunFunctionAndReturnError(start_function, "[]", browser()));
+ ASSERT_TRUE(!error.empty());
+
+ // Reset for a successful start
+ testing::Mock::VerifyAndClearExpectations(mock_adapter_);
+ EXPECT_CALL(*mock_adapter_,
+ SetDiscovering(true,
+ testing::Truly(CallClosure),
+ testing::_));
+
+ start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
+ (void)utils::RunFunctionAndReturnError(start_function, "[]", browser());
+
+ // TODO(bryeung): test that events are sent now (crbug.com/132616)
+
+ // Reset to try stopping
+ testing::Mock::VerifyAndClearExpectations(mock_adapter_);
+ EXPECT_CALL(*mock_adapter_,
+ SetDiscovering(false,
+ testing::Truly(CallClosure),
+ testing::_));
+ scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function;
+ stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction);
+ (void)utils::RunFunctionAndReturnResult(stop_function, "[]", browser());
+
+ // TODO(bryeung): test that no events are sent now (crbug.com/132616)
+
+ // Reset to try stopping with an error
+ testing::Mock::VerifyAndClearExpectations(mock_adapter_);
+ EXPECT_CALL(*mock_adapter_,
+ SetDiscovering(false,
+ testing::_,
+ testing::Truly(CallClosure)));
+ stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction);
+ error = utils::RunFunctionAndReturnError(stop_function, "[]", browser());
+ ASSERT_TRUE(!error.empty());
+}

Powered by Google App Engine
This is Rietveld 408576698