blob: 740f6f8c88c7b8feedd78190790b4987c6ccbd29 [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;
use fuchsia_component::client;
use {
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,
};
#[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 child_ref = fdecl::ChildRef { name: "echo_client".to_string(), collection: None };
let (exposed_dir, server_end) = endpoints::create_proxy::<fio::DirectoryMarker>();
realm
.open_exposed_dir(&child_ref, server_end)
.await
.unwrap_or_else(|e| panic!("open_exposed_dir failed: {:?}", e))
.unwrap_or_else(|e| panic!("failed to open child exposed dir: {:?}", e));
let trigger = client::connect_to_protocol_at_dir_root::<ftest::TriggerMarker>(&exposed_dir)
.expect("failed to open trigger service");
let out = trigger.run().await.unwrap_or_else(|e| panic!("trigger failed: {:?}", e));
assert_eq!(out, "Triggered");
}