blob: d7b5716aa95975c8f23faafbd423c2fa58ebef5f [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
fidl::endpoints, fidl_fidl_test_components as ftest, fidl_fuchsia_component as fcomponent,
fidl_fuchsia_component_decl as fdecl, fidl_fuchsia_io as fio, fuchsia_async as fasync,
fuchsia_component::client,
};
#[fasync::run_singlethreaded(test)]
async fn routing() {
let realm = client::connect_to_protocol::<fcomponent::RealmMarker>()
.expect("could not connect to Realm service");
// Bind to `echo_client`, causing it to execute.
let mut child_ref = fdecl::ChildRef { name: "echo_client".to_string(), collection: None };
let (exposed_dir, server_end) = endpoints::create_proxy::<fio::DirectoryMarker>().unwrap();
realm
.open_exposed_dir(&mut child_ref, server_end)
.await
.expect(&format!("open_exposed_dir failed"))
.expect(&format!("failed to open child exposed dir"));
let trigger = client::connect_to_protocol_at_dir_root::<ftest::TriggerMarker>(&exposed_dir)
.expect("failed to open trigger service");
let out = trigger.run().await.expect(&format!("trigger failed"));
assert_eq!(out, "Triggered");
}