test_controller.mojom 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // Copyright 2020 The Chromium 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.
  4. module crosapi.mojom;
  5. import "chromeos/crosapi/mojom/app_service_types.mojom";
  6. import "mojo/public/mojom/base/values.mojom";
  7. import "ui/gfx/geometry/mojom/geometry.mojom";
  8. [Stable, Extensible]
  9. enum TouchEventType {
  10. kUnknown = 0,
  11. kPressed = 1,
  12. kMoved = 2,
  13. kReleased = 3,
  14. // Touch events can be cancelled if mouse capture or touch capture changes in
  15. // the middle of a gesture. For example, a long-press might change window or
  16. // focus activation state in a way that cancels the gesture, even though the
  17. // user has not released their finger. See ui::GestureRecognizer.
  18. kCancelled = 4
  19. };
  20. // Augments a bool to include an 'unknown' value.
  21. [Stable, Extensible]
  22. enum OptionalBoolean {
  23. [Default] kUnknown = 0,
  24. kFalse,
  25. kTrue,
  26. };
  27. // Implemented in lacros-chrome.
  28. // Lets the Ash browser tests that require Lacros to send commands to this
  29. // lacros-chrome instance.
  30. // Next version: 2
  31. // Next method id: 2
  32. [Stable, Uuid="20e7f031-f4e1-4ad9-bd91-ad59eb8b1504"]
  33. interface StandaloneBrowserTestController {
  34. // Installs a test web app in lacros-chrome given a start URL and mode (open
  35. // in a tab or window) and returns the ID of the installed app (see
  36. // |web_app::GenerateAppId|).
  37. InstallWebApp@0(string start_url, WindowMode mode) => (string app_id);
  38. // Loads a fake extension in lacros-chrome, assigns it the given name and
  39. // returns the ID of the loaded extension.
  40. [MinVersion=1]
  41. LoadVpnExtension@1(string extension_name) => (string extension_id);
  42. };
  43. // Allows callers running in lacros to trigger test events that are passed to
  44. // the active Vpn configuration.
  45. // See chrome/browser/lacros/vpn_provider_lacros_apitest.cc for details.
  46. // Next version: 1
  47. // Next method id: 2
  48. [Stable, Uuid="e2bca22e-32e9-40b3-a0bc-035b41534496"]
  49. interface TestShillController {
  50. // Simulate |data| being received by the configuration determined by
  51. // |extension_id| and |configuration_name|.
  52. OnPacketReceived@0(string extension_id, string configuration_name,
  53. array<uint8> data);
  54. // Simulate |message| being received by the configuration determined by
  55. // |extension_id| and |configuration_name|.
  56. OnPlatformMessage@1(string extension_id, string configuration_name,
  57. uint32 message);
  58. };
  59. // This interface is implemented by Ash-Chrome.
  60. // It enables tests in Lacros-Chrome to access the TestInterfaces
  61. // of ash::Shill*Client classes.
  62. [Stable, Uuid="12d5dbb4-e974-4f41-820e-6d92c2215452"]
  63. interface ShillClientTestInterface {
  64. // From ash::ShillDeviceClient::TestInterface:
  65. // Adds a fake networking device.
  66. AddDevice@0(string device_path, string type,string name) => ();
  67. // Clear all fake networking devices.
  68. ClearDevices@1() => ();
  69. // Sets a property on the given fake device.
  70. SetDeviceProperty@2(string device_path,
  71. string name,
  72. mojo_base.mojom.Value value,
  73. bool notify_changed) => ();
  74. // Sets whether the SIM in the given fake device should be locked.
  75. SetSimLocked@3(string device_path, bool enabled) => ();
  76. // From ash::ShillServiceClient::TestInterface:
  77. // Adds a Service to the Manager and Service stubs.
  78. AddService@4(string service_path,
  79. string guid,
  80. string name,
  81. string type,
  82. string state,
  83. bool visible) => ();
  84. // Clears all Services from the Manager and Service stubs.
  85. ClearServices@5() => ();
  86. // Sets a property of the specified service.
  87. SetServiceProperty@6(string service_path, string property,
  88. mojo_base.mojom.Value value) => ();
  89. // From ash::ShillProfileClient::TestInterface:
  90. // Adds a profile.
  91. AddProfile@7(string profile_path, string userhash) => ();
  92. // Adds a service to the profile, copying properties from the
  93. // ShillServiceClient entry matching |service_path|.
  94. AddServiceToProfile@8(string profile_path, string service_path) => ();
  95. // From ash::ShillIPConfigClient::TestInterface:
  96. // Adds an IPConfig entry.
  97. AddIPConfig@9(string ip_config_path, mojo_base.mojom.Value properties) => ();
  98. };
  99. // This interface is implemented by Ash-Chrome.
  100. // It enables tests in Lacros-Chrome to send commands as an input method.
  101. // Next version: 2
  102. // Next method id: 3
  103. [Stable, Uuid="c214f4f5-c583-44d1-9547-bb2456d9e70b"]
  104. interface InputMethodTestInterface {
  105. // Calls the callback when the input method has focused on some input field.
  106. WaitForFocus@0() => ();
  107. // Calls ui::InputMethodAsh::CommitText with
  108. // InsertTextCursorBehavior::kMoveCursorAfterText.
  109. CommitText@1(string text) => ();
  110. // Calls ui::InputMethodAsh::UpdateComposition.
  111. [MinVersion=1] SetComposition@2(string text, uint32 index) => ();
  112. };
  113. // This interface is implemented by Ash-Chrome.
  114. // This interface provides tests a mechanism to mutate or query ash.
  115. // In the future, this interface may merge with an automation or a11y interface.
  116. // Next version: 18
  117. // Next method id: 28
  118. [Stable, Uuid="1f93f9d7-e466-466c-a675-c21b48cf30d3"]
  119. interface TestController {
  120. // Clicks the middle of the views element identified by |element_name|.
  121. [MinVersion=11]
  122. ClickElement@20(string element_name) => (bool success);
  123. // Clicks the middle of the window. Assumes that the window exists and is
  124. // visible on screen. |window_id| should be obtained from
  125. // PlatformWindow::GetWindowUniqueId(). A typical format might be:
  126. // "org.chromium.lacros.9A82A161B2A0B9BADF75E9BB958B9FCB"
  127. ClickWindow@1(string window_id);
  128. // Checks whether an item with a given ID exists in the shelf.
  129. [MinVersion=5]
  130. DoesItemExistInShelf@9(string item_id) => (bool exists);
  131. // Checks if ash is currently showing any views UI element with the given
  132. // element_name.
  133. [MinVersion=11]
  134. DoesElementExist@19(string element_name) => (bool exists);
  135. // Queries whether a window with the given |window_id| exists and is either
  136. // visible or minimized. |window_id| should be obtained from
  137. // PlatformWindow::GetWindowUniqueId(). A typical format might be:
  138. // "org.chromium.lacros.9A82A161B2A0B9BADF75E9BB958B9FCB"
  139. DoesWindowExist@0(string window_id) => (bool exist);
  140. // Causes ash to enter or exit overview mode. The callback is invoked after
  141. // overview mode is entered (and the animation is finished).
  142. [MinVersion=1]
  143. EnterOverviewMode@2() => ();
  144. [MinVersion=1]
  145. ExitOverviewMode@3() => ();
  146. // Causes ash to enter tablet mode. The callback is invoked after animations
  147. // are finished. Note that tablet mode cannot be activated if mouse devices
  148. // are connected; the callback will run, but ash will not be in tablet mode.
  149. [MinVersion=2]
  150. EnterTabletMode@4() => ();
  151. // Causes ash to exit tablet mode. The callback is invoked after animations
  152. // are finished.
  153. [MinVersion=2]
  154. ExitTabletMode@5() => ();
  155. // Gets the context menu for a shelf item. This assumes the item is already in
  156. // the shelf.
  157. [MinVersion=7]
  158. GetContextMenuForShelfItem@13(string item_id) => (array<string> items);
  159. // Returns the value of the ash::kMinimizeOnBackKey property for the given
  160. // window.
  161. // This allows the client (eg lacros) to verify assumptions eg whether
  162. // the current active tab should react to a system wide back gesture.
  163. //
  164. // Note: For simplicity, the return callback is called with `true` in case
  165. // the property is not set, of the window is not found.
  166. [MinVersion=4]
  167. GetMinimizeOnBackKeyWindowProperty@10(string window_id)
  168. => (OptionalBoolean value);
  169. // Returns the position of a window's top-left corner in global "screen"
  170. // coordinates in DIPs. By design, Wayland clients do not know the global
  171. // position of their windows on the display. However, for window manager
  172. // integration testing, some tests may need to assert a window is in a certain
  173. // position (e.g. at the top of the display). Returns null if the window does
  174. // not exist.
  175. [MinVersion=3]
  176. GetWindowPositionInScreen@8(string window_id) => (gfx.mojom.Point? position);
  177. // Pins or unpins an item to the shelf. This assumes the item is already in
  178. // the shelf. Returns |false| on any error.
  179. [MinVersion=6]
  180. PinOrUnpinItemInShelf@11(string item_id, bool pin) => (bool success);
  181. // Select the context menu item for the shelf item with |item_id| at |index|.
  182. // Returns false on any error.
  183. [MinVersion=11]
  184. SelectContextMenuForShelfItem@18(string item_id, uint32 index)
  185. => (bool success);
  186. // Simulates a user left-clicking an item in the shelf. This assumes the item
  187. // is already in the shelf. Returns |false| on any error.
  188. [MinVersion=6]
  189. SelectItemInShelf@12(string item_id) => (bool success);
  190. // Creates a touch event and dispatches it to the window with |window_id|.
  191. // Returns immediately if the window does not exist. The |pointer_id|
  192. // specifies which touch-point is involved in a multi-touch gesture.
  193. // |pointer_id| is typically 0, meaning the first touch-point, usually the
  194. // index finger. |location_in_window| is in DIPs, in coordinates relative to
  195. // the window origin with 0,0 representing top-left. Note that the location
  196. // is a float, as some input devices report sub-pixel positions for touch
  197. // events.
  198. [MinVersion=3]
  199. SendTouchEvent@7(string window_id, TouchEventType type, uint8 pointer_id,
  200. gfx.mojom.PointF location_in_window) => ();
  201. // Get the number of open Ash browser windows.
  202. [MinVersion=8]
  203. GetOpenAshBrowserWindows@14() => (uint32 number);
  204. // Close all browser windows.
  205. // Note: Usually there should be no Ash window open unless the test opened
  206. // one.
  207. [MinVersion=8]
  208. CloseAllBrowserWindows@15() => (bool success);
  209. // Register a lacros-chrome test controller with ash-chrome to let ash-chrome
  210. // send commands to lacros-chrome.
  211. [MinVersion=9] RegisterStandaloneBrowserTestController@16(
  212. pending_remote<StandaloneBrowserTestController> controller);
  213. // Provides a mechanism for lacros to tell ash to perform tab scrubbing.
  214. [MinVersion=10]
  215. TriggerTabScrubbing@17(float x_offset) => (bool scrubbing);
  216. // Simulates a user always selecting the specified app from future
  217. // Sharesheets.
  218. [MinVersion=12]
  219. SetSelectedSharesheetApp@21(string app_id) => ();
  220. // Returns the version of ash-chrome, e.g. "103.0.5029.0". The returned string
  221. // is intended to be compatible with the base::Version(StringPiece)
  222. // constructor.
  223. // Consider using the convenience wrapper
  224. // lacros_test_helper.h:IsAshVersionAtLeastForTesting instead.
  225. // Introduced in M-103.
  226. [MinVersion=13]
  227. GetAshVersion@22() => (string ash_version);
  228. // Binds |test_shill_controller| that can be used to simulate packet/message
  229. // events.
  230. [MinVersion=14]
  231. BindTestShillController@23(
  232. pending_receiver<TestShillController> test_shill_controller) => ();
  233. // Creates and then cancels a print job.
  234. [MinVersion=15]
  235. CreateAndCancelPrintJob@24(string job_title) => ();
  236. // Binds a |shill_client| that Lacros-Chrome can use to access the Shill
  237. // test intefaces in Ash-Chrome.
  238. [MinVersion=16]
  239. BindShillClientTestInterface@25(
  240. pending_receiver<ShillClientTestInterface> shill_client) => ();
  241. // Returns the sanitized (aka "hashed") username of the active user.
  242. [MinVersion=16]
  243. GetSanitizedActiveUsername@26() => (string sanitized_active_username);
  244. // Binds a |test_input_method| that Lacros-Chrome can use to receive commands
  245. // from a test input method in Ash-Chrome.
  246. [MinVersion=17]
  247. BindInputMethodTestInterface@27(
  248. pending_receiver<InputMethodTestInterface> test_input_method) => ();
  249. };