sc_client_integration_support/
lib.rs1use diagnostics_assertions::assert_data_tree;
6use diagnostics_reader::ArchiveReader;
7use fidl_test_structuredconfig_receiver::{ConfigReceiverPuppetMarker, ReceiverConfig};
8
9pub async fn run_test_case(inspect_selector: &str) {
10 let puppet =
11 fuchsia_component::client::connect_to_protocol::<ConfigReceiverPuppetMarker>().unwrap();
12
13 let observed = puppet.get_config().await.unwrap();
14 let expected = ReceiverConfig {
15 my_flag: true,
16 my_uint8: 255,
17 my_uint16: 65535,
18 my_uint32: 4_000_000_000,
19 my_uint64: 8_000_000_000,
20 my_int8: -127,
21 my_int16: -32766,
22 my_int32: -2_000_000_000,
23 my_int64: -4_000_000_000,
24 my_string: "hello, world!".into(),
25 my_vector_of_flag: vec![true, false],
26 my_vector_of_uint8: vec![1, 2, 3],
27 my_vector_of_uint16: vec![2, 3, 4],
28 my_vector_of_uint32: vec![3, 4, 5],
29 my_vector_of_uint64: vec![4, 5, 6],
30 my_vector_of_int8: vec![-1, -2, 3],
31 my_vector_of_int16: vec![-2, -3, 4],
32 my_vector_of_int32: vec![-3, -4, 5],
33 my_vector_of_int64: vec![-4, -5, 6],
34 my_vector_of_string: vec!["hello, world!".into(), "hello, again!".into()],
35 };
36
37 assert_eq!(observed, expected, "child must receive expected configuration");
38
39 let inspector = ArchiveReader::inspect()
40 .add_selector(inspect_selector)
41 .snapshot()
42 .await
43 .unwrap()
44 .into_iter()
45 .next()
46 .and_then(|result| result.payload)
47 .unwrap();
48
49 assert_eq!(inspector.children.len(), 1, "selector must return exactly one child");
50
51 assert_data_tree!(inspector, root: {
52 config: {
53 my_flag: true,
54 my_uint8: 255u64,
55 my_uint16: 65535u64,
56 my_uint32: 4000000000u64,
57 my_uint64: 8000000000u64,
58 my_int8: -127i64,
59 my_int16: -32766i64,
60 my_int32: -2000000000i64,
61 my_int64: -4000000000i64,
62 my_string: "hello, world!",
63 my_vector_of_flag: vec![
64 1i64,
65 0i64
66 ],
67 my_vector_of_uint8: vec![
68 1i64,
69 2i64,
70 3i64,
71 ],
72 my_vector_of_uint16: vec![
73 2i64,
74 3i64,
75 4i64,
76 ],
77 my_vector_of_uint32: vec![
78 3i64,
79 4i64,
80 5i64,
81 ],
82 my_vector_of_uint64: vec![
83 4i64,
84 5i64,
85 6i64,
86 ],
87 my_vector_of_int8: vec![
88 -1i64,
89 -2i64,
90 3i64,
91 ],
92 my_vector_of_int16: vec![
93 -2i64,
94 -3i64,
95 4i64,
96 ],
97 my_vector_of_int32: vec![
98 -3i64,
99 -4i64,
100 5i64,
101 ],
102 my_vector_of_int64: vec![
103 -4i64,
104 -5i64,
105 6i64,
106 ],
107 my_vector_of_string: vec![
108 "hello, world!",
109 "hello, again!"
110 ]
111 }
112 });
113}