Commit 52680a74 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS PhoneHub] Create NearbyEndpointFinder

This class is responsible for discovering endpoints via the Nearby
Connections library. It uses an out-of-band Bluetooth discovery
mechanism since SecureChannel already has access to a Bluetooth MAC
address for the device we're aiming to connect to.

This CL also adds a nearby_connector.mojom file which contains the
service ID to use for SecureChannel connections over Nearby Connections.
Follow-up CLs will add additional interfaces to this file.

Bug: 1106937
Change-Id: I66b20d960823bf3e8429dbfa863e84b123e29deb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506551
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#824992}
parent 1569b0aa
...@@ -223,6 +223,7 @@ source_set("chromeos") { ...@@ -223,6 +223,7 @@ source_set("chromeos") {
"//chromeos/services/network_health/public/mojom", "//chromeos/services/network_health/public/mojom",
"//chromeos/services/secure_channel", "//chromeos/services/secure_channel",
"//chromeos/services/secure_channel/public/cpp/client", "//chromeos/services/secure_channel/public/cpp/client",
"//chromeos/services/secure_channel/public/mojom",
"//chromeos/settings", "//chromeos/settings",
"//chromeos/system", "//chromeos/system",
"//chromeos/timezone", "//chromeos/timezone",
...@@ -2600,6 +2601,10 @@ source_set("chromeos") { ...@@ -2600,6 +2601,10 @@ source_set("chromeos") {
"scanning/zeroconf_scanner_detector_utils.h", "scanning/zeroconf_scanner_detector_utils.h",
"scheduler_configuration_manager.cc", "scheduler_configuration_manager.cc",
"scheduler_configuration_manager.h", "scheduler_configuration_manager.h",
"secure_channel/nearby_endpoint_finder.cc",
"secure_channel/nearby_endpoint_finder.h",
"secure_channel/nearby_endpoint_finder_impl.cc",
"secure_channel/nearby_endpoint_finder_impl.h",
"secure_channel/secure_channel_client_provider.cc", "secure_channel/secure_channel_client_provider.cc",
"secure_channel/secure_channel_client_provider.h", "secure_channel/secure_channel_client_provider.h",
"service_sandbox_type.h", "service_sandbox_type.h",
...@@ -3170,6 +3175,8 @@ static_library("test_support") { ...@@ -3170,6 +3175,8 @@ static_library("test_support") {
"printing/printing_stubs.h", "printing/printing_stubs.h",
"scoped_set_running_on_chromeos_for_testing.cc", "scoped_set_running_on_chromeos_for_testing.cc",
"scoped_set_running_on_chromeos_for_testing.h", "scoped_set_running_on_chromeos_for_testing.h",
"secure_channel/fake_nearby_endpoint_finder.cc",
"secure_channel/fake_nearby_endpoint_finder.h",
"settings/scoped_testing_cros_settings.cc", "settings/scoped_testing_cros_settings.cc",
"settings/scoped_testing_cros_settings.h", "settings/scoped_testing_cros_settings.h",
] ]
...@@ -3763,6 +3770,7 @@ source_set("unit_tests") { ...@@ -3763,6 +3770,7 @@ source_set("unit_tests") {
"scanning/scanning_type_converters_unittest.cc", "scanning/scanning_type_converters_unittest.cc",
"scanning/zeroconf_scanner_detector_unittest.cc", "scanning/zeroconf_scanner_detector_unittest.cc",
"scheduler_configuration_manager_unittest.cc", "scheduler_configuration_manager_unittest.cc",
"secure_channel/nearby_endpoint_finder_impl_unittest.cc",
"session_length_limiter_unittest.cc", "session_length_limiter_unittest.cc",
"settings/cros_settings_unittest.cc", "settings/cros_settings_unittest.cc",
"settings/device_settings_cache_unittest.cc", "settings/device_settings_cache_unittest.cc",
...@@ -3921,8 +3929,11 @@ source_set("unit_tests") { ...@@ -3921,8 +3929,11 @@ source_set("unit_tests") {
"//chromeos/services/device_sync/public/cpp:test_support", "//chromeos/services/device_sync/public/cpp:test_support",
"//chromeos/services/multidevice_setup/public/cpp:prefs", "//chromeos/services/multidevice_setup/public/cpp:prefs",
"//chromeos/services/multidevice_setup/public/cpp:test_support", "//chromeos/services/multidevice_setup/public/cpp:test_support",
"//chromeos/services/nearby/public/cpp:test_support",
"//chromeos/services/nearby/public/mojom",
"//chromeos/services/secure_channel/public/cpp/client", "//chromeos/services/secure_channel/public/cpp/client",
"//chromeos/services/secure_channel/public/cpp/client:test_support", "//chromeos/services/secure_channel/public/cpp/client:test_support",
"//chromeos/services/secure_channel/public/mojom",
"//chromeos/settings", "//chromeos/settings",
"//chromeos/system", "//chromeos/system",
"//chromeos/tpm", "//chromeos/tpm",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/secure_channel/fake_nearby_endpoint_finder.h"
namespace chromeos {
namespace secure_channel {
FakeNearbyEndpointFinder::FakeNearbyEndpointFinder() = default;
FakeNearbyEndpointFinder::~FakeNearbyEndpointFinder() = default;
} // namespace secure_channel
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_FAKE_NEARBY_ENDPOINT_FINDER_H_
#define CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_FAKE_NEARBY_ENDPOINT_FINDER_H_
#include "chrome/browser/chromeos/secure_channel/nearby_endpoint_finder.h"
namespace chromeos {
namespace secure_channel {
class FakeNearbyEndpointFinder : public NearbyEndpointFinder {
public:
FakeNearbyEndpointFinder();
~FakeNearbyEndpointFinder() override;
// Make functions public for testing.
using NearbyEndpointFinder::NotifyEndpointDiscoveryFailure;
using NearbyEndpointFinder::NotifyEndpointFound;
using NearbyEndpointFinder::remote_device_bluetooth_address;
private:
// NearbyEndpointFinder:
void PerformFindEndpoint() override {}
};
} // namespace secure_channel
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_FAKE_NEARBY_ENDPOINT_FINDER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/secure_channel/nearby_endpoint_finder.h"
namespace chromeos {
namespace secure_channel {
NearbyEndpointFinder::NearbyEndpointFinder() = default;
NearbyEndpointFinder::~NearbyEndpointFinder() = default;
void NearbyEndpointFinder::FindEndpoint(
const std::vector<uint8_t>& remote_device_bluetooth_address,
EndpointCallback success_callback,
base::OnceClosure failure_callback) {
// Only intended to be called once.
DCHECK(remote_device_bluetooth_address_.empty());
remote_device_bluetooth_address_ = remote_device_bluetooth_address;
success_callback_ = std::move(success_callback);
failure_callback_ = std::move(failure_callback);
PerformFindEndpoint();
}
void NearbyEndpointFinder::NotifyEndpointFound(
const std::string& endpoint_id,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr info) {
std::move(success_callback_).Run(endpoint_id, std::move(info));
}
void NearbyEndpointFinder::NotifyEndpointDiscoveryFailure() {
std::move(failure_callback_).Run();
}
} // namespace secure_channel
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_H_
#define CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_H_
#include "base/containers/flat_map.h"
#include "base/unguessable_token.h"
#include "chromeos/services/nearby/public/mojom/nearby_connections.mojom.h"
namespace chromeos {
namespace secure_channel {
// Discovers an endpoint corresponding to a remote device via the Nearby
// Connections library using the service ID corresponding to SecureChannel.
// Only one NearbyEndpointFinder is meant to be active at a given time. Note
// that this class does not implement timeouts for finding a connection.
class NearbyEndpointFinder {
public:
virtual ~NearbyEndpointFinder();
// Callback which receives an endpoint ID and additional metadata about a
// discovered endpoint.
using EndpointCallback = base::OnceCallback<void(
const std::string&,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr)>;
// Attempts to find an endpoint for the device with the provided Bluetooth
// address, which is expected to be a 6-byte MAC address.
void FindEndpoint(const std::vector<uint8_t>& remote_device_bluetooth_address,
EndpointCallback success_callback,
base::OnceClosure failure_callback);
protected:
NearbyEndpointFinder();
const std::vector<uint8_t>& remote_device_bluetooth_address() const {
return remote_device_bluetooth_address_;
}
void NotifyEndpointFound(
const std::string& endpoint_id,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr info);
void NotifyEndpointDiscoveryFailure();
virtual void PerformFindEndpoint() = 0;
private:
std::vector<uint8_t> remote_device_bluetooth_address_;
EndpointCallback success_callback_;
base::OnceClosure failure_callback_;
};
} // namespace secure_channel
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/secure_channel/nearby_endpoint_finder_impl.h"
#include "base/memory/ptr_util.h"
#include "chromeos/components/multidevice/logging/logging.h"
#include "chromeos/services/secure_channel/public/mojom/nearby_connector.mojom.h"
namespace chromeos {
namespace secure_channel {
namespace {
using location::nearby::connections::mojom::DiscoveredEndpointInfoPtr;
using location::nearby::connections::mojom::DiscoveryOptions;
using location::nearby::connections::mojom::MediumSelection;
using location::nearby::connections::mojom::Status;
using location::nearby::connections::mojom::Strategy;
NearbyEndpointFinderImpl::Factory* g_test_factory = nullptr;
void OnStopDiscoveryDestructorResult(Status status) {
if (status != Status::kSuccess)
PA_LOG(WARNING) << "Failed to stop discovery as part of destructor";
}
} // namespace
// static
std::unique_ptr<NearbyEndpointFinder> NearbyEndpointFinderImpl::Factory::Create(
const mojo::SharedRemote<
location::nearby::connections::mojom::NearbyConnections>&
nearby_connections) {
if (g_test_factory)
return g_test_factory->CreateInstance(nearby_connections);
return base::WrapUnique(new NearbyEndpointFinderImpl(nearby_connections));
}
// static
void NearbyEndpointFinderImpl::Factory::SetFactoryForTesting(
Factory* test_factory) {
g_test_factory = test_factory;
}
NearbyEndpointFinderImpl::NearbyEndpointFinderImpl(
const mojo::SharedRemote<
location::nearby::connections::mojom::NearbyConnections>&
nearby_connections)
: nearby_connections_(nearby_connections) {}
NearbyEndpointFinderImpl::~NearbyEndpointFinderImpl() {
if (is_discovery_active_) {
nearby_connections_->StopDiscovery(
mojom::kServiceId, base::BindOnce(&OnStopDiscoveryDestructorResult));
}
}
void NearbyEndpointFinderImpl::PerformFindEndpoint() {
is_discovery_active_ = true;
nearby_connections_->StartDiscovery(
mojom::kServiceId,
DiscoveryOptions::New(Strategy::kP2pPointToPoint,
MediumSelection::New(/*bluetooth=*/true,
/*ble=*/false,
/*webrtc=*/false,
/*wifi_lan=*/false),
/*fast_advertisement_service_uuid=*/base::nullopt,
/*is_out_of_band_connection=*/true),
endpoint_discovery_listener_receiver_.BindNewPipeAndPassRemote(),
base::BindOnce(&NearbyEndpointFinderImpl::OnStartDiscoveryResult,
weak_ptr_factory_.GetWeakPtr()));
}
void NearbyEndpointFinderImpl::OnEndpointFound(const std::string& endpoint_id,
DiscoveredEndpointInfoPtr info) {
nearby_connections_->StopDiscovery(
mojom::kServiceId,
base::BindOnce(&NearbyEndpointFinderImpl::OnStopDiscoveryResult,
weak_ptr_factory_.GetWeakPtr(), endpoint_id,
std::move(info)));
}
void NearbyEndpointFinderImpl::OnStartDiscoveryResult(Status status) {
if (status != Status::kSuccess) {
PA_LOG(WARNING) << "Failed to start Nearby discovery: " << status;
is_discovery_active_ = false;
NotifyEndpointDiscoveryFailure();
return;
}
PA_LOG(VERBOSE) << "Started Nearby discovery";
nearby_connections_->InjectBluetoothEndpoint(
mojom::kServiceId, remote_device_bluetooth_address(),
base::BindOnce(&NearbyEndpointFinderImpl::OnInjectBluetoothEndpointResult,
weak_ptr_factory_.GetWeakPtr()));
}
void NearbyEndpointFinderImpl::OnInjectBluetoothEndpointResult(Status status) {
if (status != Status::kSuccess) {
PA_LOG(WARNING) << "Failed to inject Bluetooth endpoint: " << status;
NotifyEndpointDiscoveryFailure();
return;
}
PA_LOG(VERBOSE) << "Injected Bluetooth endpoint";
}
void NearbyEndpointFinderImpl::OnStopDiscoveryResult(
const std::string& endpoint_id,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr info,
Status status) {
is_discovery_active_ = false;
if (status != Status::kSuccess) {
PA_LOG(WARNING) << "Failed to stop Nearby discovery: " << status;
NotifyEndpointDiscoveryFailure();
return;
}
NotifyEndpointFound(endpoint_id, std::move(info));
}
} // namespace secure_channel
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_IMPL_H_
#define CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_IMPL_H_
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/secure_channel/nearby_endpoint_finder.h"
#include "chromeos/services/nearby/public/mojom/nearby_connections.mojom.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/shared_remote.h"
namespace chromeos {
namespace secure_channel {
// NearbyEndpointFinder implementation which uses a Mojo connection to the
// Nearby utility process to find the endpoint. This process consists of:
// (1) Starting discovery, using an out-of-band Bluetooth mechanism.
// (2) Injecting an endpoint using a Bluetooth address.
// (3) Waiting for an endpoint to be found.
// (4) Stopping discovery.
class NearbyEndpointFinderImpl
: public NearbyEndpointFinder,
public location::nearby::connections::mojom::EndpointDiscoveryListener {
public:
class Factory {
public:
static std::unique_ptr<NearbyEndpointFinder> Create(
const mojo::SharedRemote<
location::nearby::connections::mojom::NearbyConnections>&
nearby_connections);
static void SetFactoryForTesting(Factory* test_factory);
virtual ~Factory() = default;
protected:
virtual std::unique_ptr<NearbyEndpointFinder> CreateInstance(
const mojo::SharedRemote<
location::nearby::connections::mojom::NearbyConnections>&
nearby_connections) = 0;
};
NearbyEndpointFinderImpl(
const mojo::SharedRemote<
location::nearby::connections::mojom::NearbyConnections>&
nearby_connections);
~NearbyEndpointFinderImpl() override;
private:
friend class NearbyEndpointFinderImplTest;
// NearbyEndpointFinder:
void PerformFindEndpoint() override;
// location::nearby::connections::mojom::EndpointDiscoveryListener:
void OnEndpointFound(
const std::string& endpoint_id,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr info)
override;
void OnEndpointLost(const std::string& endpoint_id) override {}
void OnStartDiscoveryResult(
location::nearby::connections::mojom::Status status);
void OnInjectBluetoothEndpointResult(
location::nearby::connections::mojom::Status status);
void OnStopDiscoveryResult(
const std::string& endpoint_id,
location::nearby::connections::mojom::DiscoveredEndpointInfoPtr info,
location::nearby::connections::mojom::Status status);
mojo::SharedRemote<location::nearby::connections::mojom::NearbyConnections>
nearby_connections_;
mojo::Receiver<
location::nearby::connections::mojom::EndpointDiscoveryListener>
endpoint_discovery_listener_receiver_{this};
bool is_discovery_active_ = false;
base::WeakPtrFactory<NearbyEndpointFinderImpl> weak_ptr_factory_{this};
};
} // namespace secure_channel
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SECURE_CHANNEL_NEARBY_ENDPOINT_FINDER_IMPL_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/secure_channel/nearby_endpoint_finder_impl.h"
#include <memory>
#include <vector>
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "chromeos/services/nearby/public/cpp/mock_nearby_connections.h"
#include "chromeos/services/secure_channel/public/mojom/nearby_connector.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/shared_remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace secure_channel {
namespace {
using location::nearby::connections::mojom::DiscoveredEndpointInfo;
using location::nearby::connections::mojom::DiscoveredEndpointInfoPtr;
using location::nearby::connections::mojom::EndpointDiscoveryListener;
using location::nearby::connections::mojom::Status;
using testing::_;
using testing::Invoke;
const char kEndpointId[] = "endpointId";
const std::vector<uint8_t>& GetBluetoothAddress() {
static const std::vector<uint8_t> address{0, 1, 2, 3, 4, 5};
return address;
}
} // namespace
class NearbyEndpointFinderImplTest : public testing::Test {
protected:
NearbyEndpointFinderImplTest() = default;
~NearbyEndpointFinderImplTest() override = default;
// testing::Test:
void SetUp() override {
finder_ = NearbyEndpointFinderImpl::Factory::Create(
mock_nearby_connections_.shared_remote());
}
void FindEndpoint() {
base::RunLoop run_loop;
EXPECT_CALL(mock_nearby_connections_, StartDiscovery(_, _, _, _))
.WillOnce(Invoke(
[&](const std::string& service_id, DiscoveryOptionsPtr options,
mojo::PendingRemote<EndpointDiscoveryListener> listener,
NearbyConnectionsMojom::StartDiscoveryCallback callback) {
start_discovery_callback_ = std::move(callback);
endpoint_discovery_listener_.Bind(std::move(listener));
run_loop.Quit();
}));
finder_->FindEndpoint(
GetBluetoothAddress(),
base::BindOnce(&NearbyEndpointFinderImplTest::OnEndpointFound,
base::Unretained(this)),
base::BindOnce(
&NearbyEndpointFinderImplTest::OnEndpointDiscoveryFailure,
base::Unretained(this)));
run_loop.Run();
}
void InvokeStartDiscoveryCallback(bool success) {
base::RunLoop run_loop;
if (!success) {
result_closure_ = run_loop.QuitClosure();
std::move(start_discovery_callback_).Run(Status::kError);
run_loop.Run();
return;
}
EXPECT_CALL(mock_nearby_connections_, InjectBluetoothEndpoint(_, _, _))
.WillOnce(
Invoke([&](const std::string& service_id,
const std::vector<uint8_t>& remote_bluetooth_mac_address,
NearbyConnectionsMojom::InjectBluetoothEndpointCallback
callback) {
inject_endpoint_callback_ = std::move(callback);
run_loop.Quit();
}));
std::move(start_discovery_callback_).Run(Status::kSuccess);
run_loop.Run();
}
void InvokeInjectEndpointCallback(bool success) {
base::RunLoop run_loop;
if (!success) {
result_closure_ = run_loop.QuitClosure();
std::move(inject_endpoint_callback_).Run(Status::kError);
run_loop.Run();
return;
}
std::move(inject_endpoint_callback_).Run(Status::kSuccess);
}
void InvokeOnEndpointFound() {
base::RunLoop run_loop;
EXPECT_CALL(mock_nearby_connections_, StopDiscovery(_, _))
.WillOnce(
Invoke([&](const std::string& service_id,
NearbyConnectionsMojom::StopDiscoveryCallback callback) {
stop_discovery_callback_ = std::move(callback);
run_loop.Quit();
}));
endpoint_discovery_listener_->OnEndpointFound(
kEndpointId, DiscoveredEndpointInfo::New());
run_loop.Run();
}
void InvokeStopDiscoveryCallback(bool success) {
base::RunLoop run_loop;
result_closure_ = run_loop.QuitClosure();
std::move(stop_discovery_callback_)
.Run(success ? Status::kSuccess : Status::kError);
run_loop.Run();
}
void DeleteFinder(bool expected_to_stop_discovery) {
if (!expected_to_stop_discovery) {
EXPECT_CALL(mock_nearby_connections_, StopDiscovery(_, _)).Times(0);
finder_.reset();
return;
}
base::RunLoop run_loop;
EXPECT_CALL(mock_nearby_connections_, StopDiscovery(_, _))
.WillOnce(
Invoke([&](const std::string& service_id,
NearbyConnectionsMojom::StopDiscoveryCallback callback) {
std::move(callback).Run(Status::kSuccess);
run_loop.Quit();
}));
finder_.reset();
run_loop.Run();
}
bool has_failed_ = false;
// Empty if no endpoint has been discovered.
std::string discovered_endpoint_id_;
private:
void OnEndpointFound(const std::string& endpoint_id,
DiscoveredEndpointInfoPtr endpoint_info) {
discovered_endpoint_id_ = endpoint_id;
std::move(result_closure_).Run();
}
void OnEndpointDiscoveryFailure() {
has_failed_ = true;
std::move(result_closure_).Run();
}
base::test::TaskEnvironment task_environment_;
nearby::MockNearbyConnections mock_nearby_connections_;
std::unique_ptr<NearbyEndpointFinder> finder_;
base::OnceClosure result_closure_;
NearbyConnectionsMojom::StartDiscoveryCallback start_discovery_callback_;
NearbyConnectionsMojom::InjectBluetoothEndpointCallback
inject_endpoint_callback_;
NearbyConnectionsMojom::StopDiscoveryCallback stop_discovery_callback_;
mojo::Remote<EndpointDiscoveryListener> endpoint_discovery_listener_;
};
TEST_F(NearbyEndpointFinderImplTest, Success) {
FindEndpoint();
InvokeStartDiscoveryCallback(/*success=*/true);
InvokeInjectEndpointCallback(/*success=*/true);
InvokeOnEndpointFound();
InvokeStopDiscoveryCallback(/*success=*/true);
DeleteFinder(/*expected_to_stop_discovery=*/false);
EXPECT_EQ(kEndpointId, discovered_endpoint_id_);
EXPECT_FALSE(has_failed_);
}
TEST_F(NearbyEndpointFinderImplTest, FailStartingDiscovery) {
FindEndpoint();
InvokeStartDiscoveryCallback(/*success=*/false);
DeleteFinder(/*expected_to_stop_discovery=*/false);
EXPECT_TRUE(has_failed_);
}
TEST_F(NearbyEndpointFinderImplTest, FailInjectingEndpoint) {
FindEndpoint();
InvokeStartDiscoveryCallback(/*success=*/true);
InvokeInjectEndpointCallback(/*success=*/false);
DeleteFinder(/*expected_to_stop_discovery=*/true);
EXPECT_TRUE(has_failed_);
}
TEST_F(NearbyEndpointFinderImplTest, FailStoppingDiscovery) {
FindEndpoint();
InvokeStartDiscoveryCallback(/*success=*/true);
InvokeInjectEndpointCallback(/*success=*/true);
InvokeOnEndpointFound();
InvokeStopDiscoveryCallback(/*success=*/false);
DeleteFinder(/*expected_to_stop_discovery=*/false);
EXPECT_TRUE(has_failed_);
}
} // namespace secure_channel
} // namespace chromeos
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") { mojom("mojom") {
sources = [ "secure_channel.mojom" ] sources = [
"nearby_connector.mojom",
"secure_channel.mojom",
]
public_deps = [ public_deps = [
"//chromeos/components/multidevice/mojom", "//chromeos/components/multidevice/mojom",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chromeos.secure_channel.mojom;
// Service ID to use. Nearby Connections requires a service ID to be associated
// with each connection request.
const string kServiceId = "secure_channel";
// TODO(khorimoto): Add SecureChannel interfaces for Nearby Connections.
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment