1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45//! Helper methods for tests involving `FocusChain`.
67use fidl_fuchsia_ui_focus::FocusChain;
8use fidl_fuchsia_ui_views::ViewRefControl;
9use fuchsia_scenic::ViewRefPair;
1011/// Makes a focus chain of the given length, returning both the `FocusChain` instance and a vector
12/// of all the corresponding `ViewRefControl`s, in the same order.
13///
14/// The `ViewRef`s are real, but of course do not correspond to any actual views.
15pub fn make_focus_chain(length: usize) -> (FocusChain, Vec<ViewRefControl>) {
16let mut view_refs = vec![];
17let mut control_refs = vec![];
18for _ in 0..length {
19let ViewRefPair { control_ref, view_ref } = ViewRefPair::new().expect("making ViewRefPair");
20 view_refs.push(view_ref);
21 control_refs.push(control_ref);
22 }
23let focus_chain = FocusChain { focus_chain: Some(view_refs), ..Default::default() };
24 (focus_chain, control_refs)
25}