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

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: remove chromeos/bluetooth code 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 2d91e7e9b554ada62f30c3609bf50defac1680af..73ddd9a5f9a1a53eb7a22c27da466e86cba12c8b 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
#include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_adapter.h"
#include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h"
#include "chrome/browser/chromeos/extensions/bluetooth_event_router.h"
@@ -18,13 +19,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 {
@@ -143,3 +137,33 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) {
ASSERT_TRUE(device->GetString("name", &name));
EXPECT_EQ("d2", name);
}
+
+IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) {
+ testing::NiceMock<chromeos::MockBluetoothDevice> device1(
+ mock_adapter_, "d1", "11:12:13:14:15:16");
+ testing::NiceMock<chromeos::MockBluetoothDevice> device2(
+ mock_adapter_, "d2", "21:22:23:24:25:26");
+ chromeos::BluetoothAdapter::DeviceList devices;
+ devices.push_back(&device1);
+ devices.push_back(&device2);
+
+ scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function;
+ start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
+ std::string error(
+ utils::RunFunctionAndReturnError(start_function, "[]", browser()));
+ ASSERT_TRUE(!error.empty());
+
+ mock_adapter_->SetDiscoveringDevicesForTesting(devices);
+ start_function = setupFunction(new api::BluetoothStartDiscoveryFunction);
+ scoped_ptr<base::Value> result(
+ utils::RunFunctionAndReturnResult(start_function, "[]", browser()));
+
+ // TODO(bryeung): test the events as well (crbug.com/132616)
+
+ scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function;
+ stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction);
+ result.reset(
+ utils::RunFunctionAndReturnResult(stop_function, "[]", browser()));
+
+ // TODO(bryeung): test that no events are sent now (crbug.com/132616)
+}

Powered by Google App Engine
This is Rietveld 408576698