aboutsummaryrefslogtreecommitdiff
path: root/cast/standalone_receiver/main.cc
diff options
context:
space:
mode:
authorJordan Bayles <jophba@chromium.org>2020-04-27 12:02:29 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-21 17:23:31 +0000
commit3275593b9d8b99d653ead174d749aa8fcb332b95 (patch)
tree6ce01f2cf9096b2f60d77ae43b128561ee9d588a /cast/standalone_receiver/main.cc
parent9b28b9695df98d310c2271eaa65d20cc6d224203 (diff)
downloadopenscreen-3275593b9d8b99d653ead174d749aa8fcb332b95.tar.gz
Add basic functional tests for the CastAgent
This patch adds some rudimentary test coverage to ensure that the CastAgent in the standalone receiver implementation is not entirely broken. Bug: b/153079471 Change-Id: Iff26badce61fbded172ff27c490440651909b0c3 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2169345 Reviewed-by: Brandon Tolsch <btolsch@chromium.org> Commit-Queue: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast/standalone_receiver/main.cc')
-rw-r--r--cast/standalone_receiver/main.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/cast/standalone_receiver/main.cc b/cast/standalone_receiver/main.cc
index 9109d501..027edd81 100644
--- a/cast/standalone_receiver/main.cc
+++ b/cast/standalone_receiver/main.cc
@@ -8,8 +8,10 @@
#include <chrono> // NOLINT
#include <iostream>
+#include "absl/strings/str_cat.h"
#include "cast/common/public/service_info.h"
#include "cast/standalone_receiver/cast_agent.h"
+#include "cast/standalone_receiver/static_credentials.h"
#include "cast/streaming/ssrc.h"
#include "discovery/common/config.h"
#include "discovery/common/reporting_client.h"
@@ -93,8 +95,11 @@ ErrorOr<std::unique_ptr<DiscoveryState>> StartDiscovery(
return state;
}
-void StartCastAgent(TaskRunnerImpl* task_runner, InterfaceInfo interface) {
- CastAgent agent(task_runner, interface);
+void StartCastAgent(TaskRunnerImpl* task_runner,
+ InterfaceInfo interface,
+ GeneratedCredentials* creds) {
+ CastAgent agent(task_runner, interface, creds->provider.get(),
+ creds->tls_credentials);
const auto error = agent.Start();
if (!error.ok()) {
OSP_LOG_ERROR << "Error occurred while starting agent: " << error;
@@ -179,9 +184,13 @@ int RunStandaloneReceiver(int argc, char* argv[]) {
auto discovery_state = StartDiscovery(task_runner, interface_info);
OSP_CHECK(discovery_state.is_value()) << "Failed to start discovery.";
+ auto creds = GenerateCredentials(
+ absl::StrCat("Standalone Receiver on ", argv[optind]));
+ OSP_CHECK(creds.is_value());
+
// Runs until the process is interrupted. Safe to pass |task_runner| as it
// will not be destroyed by ShutDown() until this exits.
- StartCastAgent(task_runner, interface_info);
+ StartCastAgent(task_runner, interface_info, &(creds.value()));
// The task runner must be deleted after all serial delete pointers, such
// as the one stored in the discovery state.