Commit 38f791a8 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

Instant Tethering: Rewrite the ConnectTetheringOperation unittest.

Such that the tests no longer depend on BleConnectionManager.

* Remove as much simulation using dependent objects as possible.
* Directly call methods under test.
* Remove irrelevant tests.

R=khorimoto@chromium.org

Bug: none
Test: ConnectTetheringOperationTest.*
Change-Id: I7f6c69e90dfe2f4d3006067de92db0973486c4d4
Reviewed-on: https://chromium-review.googlesource.com/c/1351478
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612368}
parent 96eb4c26
......@@ -5,6 +5,8 @@
#ifndef CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_
#define CHROMEOS_COMPONENTS_TETHER_CONNECT_TETHERING_OPERATION_H_
#include <stdint.h>
#include <map>
#include <vector>
......@@ -12,6 +14,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "chromeos/components/tether/message_transfer_operation.h"
#include "components/cryptauth/remote_device_ref.h"
......@@ -115,7 +118,17 @@ class ConnectTetheringOperation : public MessageTransferOperation {
private:
friend class ConnectTetheringOperationTest;
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
TestOperation_SetupRequired);
SuccessWithValidResponse);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
SuccessButInvalidResponse);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest, UnknownError);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest, ProvisioningFailed);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
NotifyConnectTetheringRequest);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
GetMessageTimeoutSeconds);
FRIEND_TEST_ALL_PREFIXES(ConnectTetheringOperationTest,
MessageSentOnceAuthenticated);
HostResponseErrorCode ConnectTetheringResponseCodeToHostResponseErrorCode(
ConnectTetheringResponse_ResponseCode error_code);
......@@ -128,8 +141,6 @@ class ConnectTetheringOperation : public MessageTransferOperation {
static const uint32_t kSetupRequiredResponseTimeoutSeconds;
cryptauth::RemoteDeviceRef remote_device_;
device_sync::DeviceSyncClient* device_sync_client_;
secure_channel::SecureChannelClient* secure_channel_client_;
TetherHostResponseRecorder* tether_host_response_recorder_;
base::Clock* clock_;
int connect_message_sequence_number_ = -1;
......
......@@ -13,13 +13,18 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
#include "base/timer/mock_timer.h"
#include "chromeos/components/tether/fake_ble_connection_manager.h"
#include "chromeos/components/tether/message_wrapper.h"
#include "chromeos/components/tether/mock_tether_host_response_recorder.h"
#include "chromeos/components/tether/proto/tether.pb.h"
#include "chromeos/components/tether/proto_test_util.h"
#include "chromeos/components/tether/timer_factory.h"
#include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h"
#include "chromeos/services/secure_channel/ble_constants.h"
#include "chromeos/services/secure_channel/public/cpp/client/fake_client_channel.h"
#include "chromeos/services/secure_channel/public/cpp/client/fake_connection_attempt.h"
#include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h"
#include "components/cryptauth/remote_device_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -34,287 +39,294 @@ namespace tether {
namespace {
const char kTestSsid[] = "testSsid";
const char kTestPassword[] = "testPassword";
constexpr base::TimeDelta kConnectTetheringResponseTime =
constexpr base::TimeDelta kConnectTetheringResponseTimeSeconds =
base::TimeDelta::FromSeconds(15);
class TestObserver final : public ConnectTetheringOperation::Observer {
// Used to verify the ConnectTetheringOperation notifies the observer
// when appropriate.
class MockOperationObserver : public ConnectTetheringOperation::Observer {
public:
TestObserver() = default;
~TestObserver() = default;
MockOperationObserver() = default;
~MockOperationObserver() = default;
MOCK_METHOD1(OnConnectTetheringRequestSent, void(cryptauth::RemoteDeviceRef));
MOCK_METHOD3(OnSuccessfulConnectTetheringResponse,
void(cryptauth::RemoteDeviceRef,
const std::string&,
const std::string&));
MOCK_METHOD2(OnConnectTetheringFailure,
void(cryptauth::RemoteDeviceRef,
ConnectTetheringOperation::HostResponseErrorCode));
base::Optional<cryptauth::RemoteDeviceRef> remote_device() {
return remote_device_;
}
const std::string& ssid() { return ssid_; }
const std::string& password() { return password_; }
bool has_received_failure() { return has_received_failure_; }
bool has_sent_request() { return has_sent_request_; }
ConnectTetheringOperation::HostResponseErrorCode error_code() {
return error_code_;
}
private:
DISALLOW_COPY_AND_ASSIGN(MockOperationObserver);
};
// ConnectTetheringOperation::Observer:
void OnConnectTetheringRequestSent(
cryptauth::RemoteDeviceRef remote_device) override {
has_sent_request_ = true;
}
} // namespace
void OnSuccessfulConnectTetheringResponse(
cryptauth::RemoteDeviceRef remote_device,
const std::string& ssid,
const std::string& password) override {
remote_device_ = remote_device;
ssid_ = ssid;
password_ = password;
class TestTimerFactory : public TimerFactory {
public:
~TestTimerFactory() override = default;
// TimerFactory:
std::unique_ptr<base::OneShotTimer> CreateOneShotTimer() override {
EXPECT_FALSE(device_id_for_next_timer_.empty());
base::MockOneShotTimer* mock_timer = new base::MockOneShotTimer();
device_id_to_timer_map_[device_id_for_next_timer_] = mock_timer;
return base::WrapUnique(mock_timer);
}
void OnConnectTetheringFailure(
cryptauth::RemoteDeviceRef remote_device,
ConnectTetheringOperation::HostResponseErrorCode error_code) override {
has_received_failure_ = true;
remote_device_ = remote_device;
error_code_ = error_code;
void set_device_id_for_next_timer(
const std::string& device_id_for_next_timer) {
device_id_for_next_timer_ = device_id_for_next_timer;
}
private:
base::Optional<cryptauth::RemoteDeviceRef> remote_device_;
std::string ssid_;
std::string password_;
bool has_received_failure_ = false;
bool has_sent_request_ = false;
ConnectTetheringOperation::HostResponseErrorCode error_code_;
std::string device_id_for_next_timer_;
base::flat_map<std::string, base::MockOneShotTimer*> device_id_to_timer_map_;
};
std::string CreateConnectTetheringRequestString() {
ConnectTetheringRequest request;
return MessageWrapper(request).ToRawMessage();
}
std::string CreateConnectTetheringResponseString(
ConnectTetheringResponse_ResponseCode response_code,
bool use_proto_without_ssid_and_password) {
ConnectTetheringResponse response;
response.set_response_code(response_code);
// Only set SSID/password if |response_code| is SUCCESS.
if (!use_proto_without_ssid_and_password &&
response_code == ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS) {
response.set_ssid(std::string(kTestSsid));
response.set_password(std::string(kTestPassword));
}
response.mutable_device_status()->CopyFrom(
CreateDeviceStatusWithFakeFields());
return MessageWrapper(response).ToRawMessage();
}
} // namespace
class ConnectTetheringOperationTest : public testing::Test {
protected:
ConnectTetheringOperationTest()
: connect_tethering_request_string_(
CreateConnectTetheringRequestString()),
test_device_(cryptauth::CreateRemoteDeviceRefListForTest(1)[0]) {}
: test_local_device_(cryptauth::RemoteDeviceRefBuilder()
.SetPublicKey("local device")
.Build()),
remote_device_(cryptauth::CreateRemoteDeviceRefForTest()) {}
void SetUp() override {
mock_tether_host_response_recorder_ =
std::make_unique<StrictMock<MockTetherHostResponseRecorder>>();
fake_device_sync_client_ =
std::make_unique<device_sync::FakeDeviceSyncClient>();
fake_device_sync_client_->set_local_device_metadata(test_local_device_);
fake_secure_channel_client_ =
std::make_unique<secure_channel::FakeSecureChannelClient>();
fake_ble_connection_manager_ = std::make_unique<FakeBleConnectionManager>();
mock_tether_host_response_recorder_ =
std::make_unique<StrictMock<MockTetherHostResponseRecorder>>();
test_observer_ = base::WrapUnique(new TestObserver());
operation_ = base::WrapUnique(new ConnectTetheringOperation(
test_device_, fake_device_sync_client_.get(),
fake_secure_channel_client_.get(),
mock_tether_host_response_recorder_.get(), false /* setup_required */));
operation_->AddObserver(test_observer_.get());
test_clock_.SetNow(base::Time::UnixEpoch());
operation_->SetClockForTest(&test_clock_);
operation_ = ConstructOperation();
operation_->Initialize();
}
void SimulateDeviceAuthenticationAndVerifyMessageSent() {
VerifyResponseTimeoutSeconds(false /* setup_required */);
operation_->OnDeviceAuthenticated(test_device_);
// Verify that the message was sent successfully.
std::vector<FakeBleConnectionManager::SentMessage>& sent_messages =
fake_ble_connection_manager_->sent_messages();
ASSERT_EQ(1u, sent_messages.size());
EXPECT_EQ(test_device_.GetDeviceId(), sent_messages[0].device_id);
EXPECT_EQ(connect_tethering_request_string_, sent_messages[0].message);
// Simulate BleConnectionManager notifying ConnectTetheringOperation that
// the message was delivered.
int last_sequence_number =
fake_ble_connection_manager_->last_sequence_number();
EXPECT_NE(last_sequence_number, -1);
fake_ble_connection_manager_->SetMessageSent(last_sequence_number);
EXPECT_TRUE(test_observer_->has_sent_request());
ConnectAuthenticatedChannelForDevice(remote_device_);
}
void SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode response_code,
ConnectTetheringOperation::HostResponseErrorCode expected_error_code,
bool use_proto_without_ssid_and_password) {
test_clock_.Advance(kConnectTetheringResponseTime);
fake_ble_connection_manager_->ReceiveMessage(
test_device_.GetDeviceId(),
CreateConnectTetheringResponseString(
response_code, use_proto_without_ssid_and_password));
bool is_success_response =
response_code == ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS;
ConnectTetheringResponse_ResponseCode expected_response_code;
if (is_success_response && use_proto_without_ssid_and_password) {
expected_response_code = ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR;
} else if (is_success_response && !use_proto_without_ssid_and_password) {
expected_response_code = ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS;
} else {
expected_response_code = response_code;
}
std::unique_ptr<ConnectTetheringOperation> ConstructOperation() {
std::unique_ptr<ConnectTetheringOperation> operation;
test_timer_factory_ = new TestTimerFactory();
if (expected_response_code ==
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS) {
EXPECT_EQ(test_device_, test_observer_->remote_device());
EXPECT_EQ(std::string(kTestSsid), test_observer_->ssid());
EXPECT_EQ(std::string(kTestPassword), test_observer_->password());
} else {
EXPECT_TRUE(test_observer_->has_received_failure());
EXPECT_EQ(expected_error_code, test_observer_->error_code());
}
// Prepare the connection timeout timer to be made for the remote device.
test_timer_factory_->set_device_id_for_next_timer(
remote_device_.GetDeviceId());
histogram_tester_.ExpectTimeBucketCount(
"InstantTethering.Performance.ConnectTetheringResponseDuration",
kConnectTetheringResponseTime, 1);
}
auto fake_connection_attempt =
std::make_unique<secure_channel::FakeConnectionAttempt>();
remote_device_to_fake_connection_attempt_map_[remote_device_] =
fake_connection_attempt.get();
fake_secure_channel_client_->set_next_listen_connection_attempt(
remote_device_, test_local_device_, std::move(fake_connection_attempt));
void VerifyResponseTimeoutSeconds(bool setup_required) {
uint32_t expected_response_timeout_seconds =
setup_required
? ConnectTetheringOperation::kSetupRequiredResponseTimeoutSeconds
: ConnectTetheringOperation::
kSetupNotRequiredResponseTimeoutSeconds;
operation = base::WrapUnique(new ConnectTetheringOperation(
remote_device_, fake_device_sync_client_.get(),
fake_secure_channel_client_.get(),
mock_tether_host_response_recorder_.get(), false /* setup_required */));
operation->SetTimerFactoryForTest(base::WrapUnique(test_timer_factory_));
operation->AddObserver(&mock_observer_);
test_clock_.SetNow(base::Time::UnixEpoch());
operation->SetClockForTest(&test_clock_);
EXPECT_EQ(expected_response_timeout_seconds,
operation_->GetMessageTimeoutSeconds());
return operation;
}
const std::string connect_tethering_request_string_;
const cryptauth::RemoteDeviceRef test_device_;
void ConnectAuthenticatedChannelForDevice(
cryptauth::RemoteDeviceRef remote_device) {
auto fake_client_channel =
std::make_unique<secure_channel::FakeClientChannel>();
remote_device_to_fake_client_channel_map_[remote_device] =
fake_client_channel.get();
remote_device_to_fake_connection_attempt_map_[remote_device]
->NotifyConnection(std::move(fake_client_channel));
}
const cryptauth::RemoteDeviceRef test_local_device_;
const cryptauth::RemoteDeviceRef remote_device_;
base::flat_map<cryptauth::RemoteDeviceRef,
secure_channel::FakeConnectionAttempt*>
remote_device_to_fake_connection_attempt_map_;
base::flat_map<cryptauth::RemoteDeviceRef, secure_channel::FakeClientChannel*>
remote_device_to_fake_client_channel_map_;
std::unique_ptr<device_sync::FakeDeviceSyncClient> fake_device_sync_client_;
std::unique_ptr<secure_channel::SecureChannelClient>
std::unique_ptr<secure_channel::FakeSecureChannelClient>
fake_secure_channel_client_;
std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_;
std::unique_ptr<StrictMock<MockTetherHostResponseRecorder>>
mock_tether_host_response_recorder_;
std::unique_ptr<TestObserver> test_observer_;
base::SimpleTestClock test_clock_;
std::unique_ptr<ConnectTetheringOperation> operation_;
TestTimerFactory* test_timer_factory_;
MockOperationObserver mock_observer_;
base::HistogramTester histogram_tester_;
private:
DISALLOW_COPY_AND_ASSIGN(ConnectTetheringOperationTest);
std::unique_ptr<ConnectTetheringOperation> operation_;
};
TEST_F(ConnectTetheringOperationTest,
DISABLED_TestOperation_SuccessButInvalidResponse) {
TEST_F(ConnectTetheringOperationTest, SuccessWithValidResponse) {
static const std::string kTestSsid = "testSsid";
static const std::string kTestPassword = "testPassword";
EXPECT_CALL(*mock_tether_host_response_recorder_,
RecordSuccessfulConnectTetheringResponse(_))
.Times(0);
RecordSuccessfulConnectTetheringResponse(remote_device_));
SimulateDeviceAuthenticationAndVerifyMessageSent();
SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS,
ConnectTetheringOperation::HostResponseErrorCode::
INVALID_HOTSPOT_CREDENTIALS,
true /* use_proto_without_ssid_and_password */);
}
// Verify that the Observer is called with success and the correct parameters.
EXPECT_CALL(mock_observer_, OnSuccessfulConnectTetheringResponse(
remote_device_, kTestSsid, kTestPassword));
TEST_F(ConnectTetheringOperationTest,
DISABLED_TestOperation_SuccessWithValidResponse) {
EXPECT_CALL(*mock_tether_host_response_recorder_,
RecordSuccessfulConnectTetheringResponse(test_device_));
// Advance the clock in order to verify a non-zero response duration is
// recorded and verified (below).
test_clock_.Advance(kConnectTetheringResponseTimeSeconds);
SimulateDeviceAuthenticationAndVerifyMessageSent();
SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS,
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
false /* use_proto_without_ssid_and_password */);
// The ConnectTetheringResponse message contains the success response code and
// the required SSID and password parameters.
ConnectTetheringResponse response;
response.set_response_code(ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS);
response.set_ssid(kTestSsid);
response.set_password(kTestPassword);
std::unique_ptr<MessageWrapper> message(new MessageWrapper(response));
operation_->OnMessageReceived(std::move(message), remote_device_);
// Verify the response duration metric is recorded.
histogram_tester_.ExpectTimeBucketCount(
"InstantTethering.Performance.ConnectTetheringResponseDuration",
kConnectTetheringResponseTimeSeconds, 1);
}
TEST_F(ConnectTetheringOperationTest, DISABLED_TestOperation_UnknownError) {
// Tests that the SSID and password parameters are a required parameters of the
// success response code; failure to provide these parameters results in a
// failed tethering connection.
TEST_F(ConnectTetheringOperationTest, SuccessButInvalidResponse) {
EXPECT_CALL(*mock_tether_host_response_recorder_,
RecordSuccessfulConnectTetheringResponse(_))
.Times(0);
SimulateDeviceAuthenticationAndVerifyMessageSent();
SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR,
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR,
false /* use_proto_without_ssid_and_password */);
// Verify that the observer is called with failure and the appropriate error
// code.
EXPECT_CALL(
mock_observer_,
OnConnectTetheringFailure(
remote_device_, ConnectTetheringOperation::HostResponseErrorCode::
INVALID_HOTSPOT_CREDENTIALS));
// The ConnectTetheringResponse message does not contain the required SSID and
// password fields.
ConnectTetheringResponse response;
response.set_response_code(ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_SUCCESS);
std::unique_ptr<MessageWrapper> message(new MessageWrapper(response));
operation_->OnMessageReceived(std::move(message), remote_device_);
}
TEST_F(ConnectTetheringOperationTest,
DISABLED_TestOperation_ProvisioningFailed) {
TEST_F(ConnectTetheringOperationTest, UnknownError) {
EXPECT_CALL(*mock_tether_host_response_recorder_,
RecordSuccessfulConnectTetheringResponse(_))
.Times(0);
SimulateDeviceAuthenticationAndVerifyMessageSent();
SimulateResponseReceivedAndVerifyObserverCallbackInvoked(
// Verify that the observer is called with failure and the appropriate error
// code.
EXPECT_CALL(
mock_observer_,
OnConnectTetheringFailure(
remote_device_,
ConnectTetheringOperation::HostResponseErrorCode::UNKNOWN_ERROR));
ConnectTetheringResponse response;
response.set_response_code(
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED,
ConnectTetheringOperation::HostResponseErrorCode::PROVISIONING_FAILED,
false /* use_proto_without_ssid_and_password */);
ConnectTetheringResponse_ResponseCode_UNKNOWN_ERROR);
std::unique_ptr<MessageWrapper> message(new MessageWrapper(response));
operation_->OnMessageReceived(std::move(message), remote_device_);
}
TEST_F(ConnectTetheringOperationTest, DISABLED_TestCannotConnect) {
TEST_F(ConnectTetheringOperationTest, ProvisioningFailed) {
EXPECT_CALL(*mock_tether_host_response_recorder_,
RecordSuccessfulConnectTetheringResponse(_))
.Times(0);
// Simulate the device failing to connect.
fake_ble_connection_manager_->SimulateUnansweredConnectionAttempts(
test_device_.GetDeviceId(), 0 /* num_attempts */);
// Verify that the observer is called with failure and the appropriate error
// code.
EXPECT_CALL(
mock_observer_,
OnConnectTetheringFailure(
remote_device_, ConnectTetheringOperation::HostResponseErrorCode::
PROVISIONING_FAILED));
// The maximum number of connection failures has occurred.
EXPECT_TRUE(test_observer_->has_received_failure());
EXPECT_EQ(ConnectTetheringOperation::HostResponseErrorCode::NO_RESPONSE,
test_observer_->error_code());
ConnectTetheringResponse response;
response.set_response_code(
ConnectTetheringResponse_ResponseCode::
ConnectTetheringResponse_ResponseCode_PROVISIONING_FAILED);
std::unique_ptr<MessageWrapper> message(new MessageWrapper(response));
histogram_tester_.ExpectTotalCount(
"InstantTethering.Performance.ConnectTetheringResponseDuration", 0);
operation_->OnMessageReceived(std::move(message), remote_device_);
}
TEST_F(ConnectTetheringOperationTest, DISABLED_TestOperation_SetupRequired) {
operation_ = base::WrapUnique(new ConnectTetheringOperation(
test_device_, fake_device_sync_client_.get(),
// Tests that observers are notified when the connection request is sent.
TEST_F(ConnectTetheringOperationTest, NotifyConnectTetheringRequest) {
EXPECT_CALL(mock_observer_, OnConnectTetheringRequestSent(remote_device_));
operation_->OnMessageSent(0 /* sequence_number */);
}
// Tests that the message timeout value varies based on whether setup is
// required or not.
TEST_F(ConnectTetheringOperationTest, GetMessageTimeoutSeconds) {
// Setup required case.
std::unique_ptr<ConnectTetheringOperation> operation(
new ConnectTetheringOperation(remote_device_,
fake_device_sync_client_.get(),
fake_secure_channel_client_.get(),
mock_tether_host_response_recorder_.get(),
true /* setup_required */));
EXPECT_EQ(ConnectTetheringOperation::kSetupRequiredResponseTimeoutSeconds,
operation->GetMessageTimeoutSeconds());
// Setup not required case.
operation.reset(new ConnectTetheringOperation(
remote_device_, fake_device_sync_client_.get(),
fake_secure_channel_client_.get(),
mock_tether_host_response_recorder_.get(), true /* setup_required */));
VerifyResponseTimeoutSeconds(true /* setup_required */);
mock_tether_host_response_recorder_.get(), false /* setup_required */));
EXPECT_EQ(ConnectTetheringOperation::kSetupNotRequiredResponseTimeoutSeconds,
operation->GetMessageTimeoutSeconds());
}
// Tests that the ConnectTetheringRequest message is sent to the remote device
// once the communication channel is connected and authenticated.
TEST_F(ConnectTetheringOperationTest, ConnectRequestSentOnceAuthenticated) {
std::unique_ptr<ConnectTetheringOperation> operation = ConstructOperation();
operation->Initialize();
// Create the client channel to the remote device.
auto fake_client_channel =
std::make_unique<secure_channel::FakeClientChannel>();
remote_device_to_fake_client_channel_map_[remote_device_] =
fake_client_channel.get();
// No requests as a result of creating the client channel.
auto& sent_messages = fake_client_channel->sent_messages();
EXPECT_EQ(0u, sent_messages.size());
// Connect and authenticate the client channel.
remote_device_to_fake_connection_attempt_map_[remote_device_]
->NotifyConnection(std::move(fake_client_channel));
// Verify the ConnectTetheringRequest message is sent.
auto message_wrapper =
std::make_unique<MessageWrapper>(ConnectTetheringRequest());
std::string expected_payload = message_wrapper->ToRawMessage();
EXPECT_EQ(1u, sent_messages.size());
EXPECT_EQ(expected_payload, sent_messages[0].first);
}
} // namespace tether
......
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