Avi Drissman | 8804558b | 2022-09-13 20:34:39 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef FUCHSIA_WEB_COMMON_TEST_TEST_REALM_SUPPORT_H_ |
| 6 | #define FUCHSIA_WEB_COMMON_TEST_TEST_REALM_SUPPORT_H_ |
| 7 | |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 8 | #include "base/strings/string_piece.h" |
| 9 | |
| 10 | namespace base { |
| 11 | class CommandLine; |
| 12 | } |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 13 | |
| 14 | namespace component_testing { |
| 15 | class RealmBuilder; |
| 16 | } |
| 17 | |
| 18 | namespace test { |
| 19 | |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 20 | // Appends the arguments of `command_line` (ignoring the program name at |
| 21 | // position zero) to the command line for the component named `child_name`. |
| 22 | void AppendCommandLineArguments( |
| 23 | ::component_testing::RealmBuilder& realm_builder, |
| 24 | base::StringPiece child_name, |
| 25 | const base::CommandLine& command_line); |
| 26 | |
Greg Thompson | 78920be7 | 2023-02-11 10:12:04 | [diff] [blame] | 27 | // Appends the arguments of `command_line` (ignoring the program name at |
| 28 | // position zero) to the command line for the realm. |
| 29 | void AppendCommandLineArgumentsForRealm( |
| 30 | ::component_testing::RealmBuilder& realm_builder, |
| 31 | const base::CommandLine& command_line); |
| 32 | |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 33 | // In the functions below, the term "parent" is the `#realm_builder` collection |
| 34 | // for the test component that is using these helpers to build a test realm. |
| 35 | // Each test component must use a .cml fragment that routes the required |
| 36 | // capabilities to `#realm_builder`. |
| 37 | |
David Dorwin | 8382ee6f | 2023-09-29 20:45:22 | [diff] [blame] | 38 | void AddRouteFromParent(component_testing::RealmBuilder& realm_builder, |
| 39 | base::StringPiece child_name, |
| 40 | base::StringPiece protocol_name); |
| 41 | |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 42 | // Adds routes to the child component named `child_name` to satisfy that |
| 43 | // child's use of syslog/client.shard.cml. |
| 44 | void AddSyslogRoutesFromParent(::component_testing::RealmBuilder& realm_builder, |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 45 | base::StringPiece child_name); |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 46 | |
| 47 | // Adds routes to the child component named `child_name` to satisfy that |
| 48 | // child's use of vulkan/client.shard.cml. |
| 49 | void AddVulkanRoutesFromParent(::component_testing::RealmBuilder& realm_builder, |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 50 | base::StringPiece child_name); |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 51 | |
| 52 | // Adds fuchsia-pkg://fuchsia.com/fonts#meta/fonts.cm as a child in the realm, |
| 53 | // routes all of its required capabilities from parent, and routes its |
| 54 | // fuchsia.fonts.Provider protocol to the child component named `child_name` |
| 55 | // in the realm. |
| 56 | void AddFontService(::component_testing::RealmBuilder& realm_builder, |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 57 | base::StringPiece child_name); |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 58 | |
| 59 | // Adds fuchsia-pkg://fuchsia.com/test-ui-stack#meta/test-ui-stack.cm as a |
| 60 | // child in the realm, routes all of its required capabilities from parent, |
| 61 | // and routes various of its protocols to the child component named |
| 62 | // `child_name` in the realm. |
| 63 | void AddTestUiStack(::component_testing::RealmBuilder& realm_builder, |
Greg Thompson | 2cd6c487 | 2022-09-16 12:10:19 | [diff] [blame] | 64 | base::StringPiece child_name); |
Greg Thompson | 9bf10b0 | 2022-08-27 07:40:55 | [diff] [blame] | 65 | |
| 66 | } // namespace test |
| 67 | |
| 68 | #endif // FUCHSIA_WEB_COMMON_TEST_TEST_REALM_SUPPORT_H_ |