pub struct VisualTestContext {
pub cx: TestAppContext,
/* private fields */
}Expand description
A TestAppContext bound to one window, the test equivalent of a Window and App.
Use it to run window-specific test code. It implements VisualContext and
dereferences to the TestAppContext it wraps. Clones refer to the same window.
Fields§
§cx: TestAppContextThe underlying TestAppContext. Methods on it are also available through deref.
Implementations§
Source§impl VisualTestContext
impl VisualTestContext
Sourcepub fn virtual_keyboard_requests(&self) -> usize
pub fn virtual_keyboard_requests(&self) -> usize
Returns the number of virtual keyboard show requests sent to this test window.
Sourcepub fn update<R>(&mut self, f: impl FnOnce(&mut Window, &mut App) -> R) -> R
pub fn update<R>(&mut self, f: impl FnOnce(&mut Window, &mut App) -> R) -> R
Runs f with the window and the app. This doesn’t run pending tasks.
Sourcepub fn from_window(window: AnyWindowHandle, cx: &TestAppContext) -> Self
pub fn from_window(window: AnyWindowHandle, cx: &TestAppContext) -> Self
Creates a context for window that shares cx’s app.
Shadow the TestAppContext with the result, which is usually what you want:
let cx = VisualTestContext::from_window(window, cx);.
Sourcepub fn run_until_parked(&self)
pub fn run_until_parked(&self)
Runs pending tasks until none can make progress.
This runs the same scheduler as TestAppContext::run_until_parked. It doesn’t move the simulated clock.
Sourcepub fn dispatch_action<A>(&mut self, action: A)where
A: Action,
pub fn dispatch_action<A>(&mut self, action: A)where
A: Action,
Dispatches action to the focused element in this window, then runs pending tasks.
Sourcepub fn window_title(&mut self) -> Option<String>
pub fn window_title(&mut self) -> Option<String>
Returns the title set with Window::set_window_title, or None if none was set.
Sourcepub fn document_path(&mut self) -> Option<PathBuf>
pub fn document_path(&mut self) -> Option<PathBuf>
Returns the document path set with Window::set_document_path, or None if none was set.
Sourcepub fn simulate_keystrokes(&mut self, keystrokes: &str)
pub fn simulate_keystrokes(&mut self, keystrokes: &str)
Sends a space-separated list of keystrokes to this window, then runs pending tasks.
This is TestAppContext::simulate_keystrokes for this window. The same rules
apply: a space separates keystrokes, so use the key name "space" only as one
keystroke.
Sourcepub fn simulate_input(&mut self, input: &str)
pub fn simulate_input(&mut self, input: &str)
Types input into this window, one keystroke per character, then runs pending tasks.
See TestAppContext::simulate_input for how characters are sent.
Sourcepub fn simulate_mouse_move(
&mut self,
position: Point<Pixels>,
button: impl Into<Option<MouseButton>>,
modifiers: Modifiers,
)
pub fn simulate_mouse_move( &mut self, position: Point<Pixels>, button: impl Into<Option<MouseButton>>, modifiers: Modifiers, )
Moves the pointer to position, with button held if it’s Some.
Sourcepub fn simulate_mouse_down(
&mut self,
position: Point<Pixels>,
button: MouseButton,
modifiers: Modifiers,
)
pub fn simulate_mouse_down( &mut self, position: Point<Pixels>, button: MouseButton, modifiers: Modifiers, )
Presses button at position with modifiers held. The click count is always 1.
Sourcepub fn simulate_mouse_up(
&mut self,
position: Point<Pixels>,
button: MouseButton,
modifiers: Modifiers,
)
pub fn simulate_mouse_up( &mut self, position: Point<Pixels>, button: MouseButton, modifiers: Modifiers, )
Releases button at position with modifiers held. The click count is always 1.
Sourcepub fn simulate_click(&mut self, position: Point<Pixels>, modifiers: Modifiers)
pub fn simulate_click(&mut self, position: Point<Pixels>, modifiers: Modifiers)
Presses and releases the left button at position, with click count 1 on both events.
Sourcepub fn simulate_modifiers_change(&mut self, modifiers: Modifiers)
pub fn simulate_modifiers_change(&mut self, modifiers: Modifiers)
Sends a modifiers-changed event with modifiers. Caps lock is reported as off.
Sourcepub fn simulate_capslock_change(&mut self, on: bool)
pub fn simulate_capslock_change(&mut self, on: bool)
Sends a modifiers-changed event with no modifiers and caps lock set to on.
Sourcepub fn simulate_resize(&self, size: Size<Pixels>)
pub fn simulate_resize(&self, size: Size<Pixels>)
Resizes the window to size. See TestAppContext::simulate_window_resize.
This doesn’t paint the window. Call VisualTestContext::draw to paint at the new size.
Sourcepub fn simulate_visibility_change(&self, visibility: WindowVisibility)
pub fn simulate_visibility_change(&self, visibility: WindowVisibility)
Simulates a change in whether the platform is presenting this window.
Sourcepub fn simulate_scale_factor_change(&self, scale_factor: f32)
pub fn simulate_scale_factor_change(&self, scale_factor: f32)
Simulates the window moving to a display with a different scale factor.
Sourcepub fn debug_bounds(&mut self, selector: &'static str) -> Option<Bounds<Pixels>>
pub fn debug_bounds(&mut self, selector: &'static str) -> Option<Bounds<Pixels>>
Returns the bounds of the element with debug_selector(selector) in the last painted frame, or None.
Draw the view first, so that the frame contains the element. Use this to click
an element without guessing its position. Builds without debug_assertions don’t
record selectors, so there this always returns None; see
InteractiveElement::debug_selector.
Sourcepub fn draw<E>(
&mut self,
origin: Point<Pixels>,
space: impl Into<Size<AvailableSpace>>,
f: impl FnOnce(&mut Window, &mut App) -> E,
) -> (E::RequestLayoutState, E::PrepaintState)where
E: Element,
pub fn draw<E>(
&mut self,
origin: Point<Pixels>,
space: impl Into<Size<AvailableSpace>>,
f: impl FnOnce(&mut Window, &mut App) -> E,
) -> (E::RequestLayoutState, E::PrepaintState)where
E: Element,
Lays out and paints f’s element as a root at origin, within space.
Use this to paint an element on its own, without a root view. It returns the element’s request-layout and prepaint state. The window is refreshed afterward.
Sourcepub fn simulate_event<E: InputEvent>(&mut self, event: E)
pub fn simulate_event<E: InputEvent>(&mut self, event: E)
Sends event to the window as platform input, then runs pending tasks.
Call VisualTestContext::draw first, so that hit tests see the current layout.
Sourcepub fn deactivate_window(&mut self)
pub fn deactivate_window(&mut self)
Makes this window inactive, as if the user had switched to another window.
Does nothing if the window isn’t active. Runs pending tasks.
Sourcepub fn simulate_close(&mut self) -> bool
pub fn simulate_close(&mut self) -> bool
Runs the window’s should-close callback and returns its result.
Returns false if the window has no callback. This doesn’t remove the window
from the app, even when the callback returns true.
Sourcepub fn into_mut(self) -> &'static mut Self
pub fn into_mut(self) -> &'static mut Self
Leaks this context and returns a mutable reference that stays valid until the test ends.
TestAppContext::add_window_view and TestAppContext::add_empty_window use
this to return a context that borrows from the test. The memory is freed when
the test quits.
Methods from Deref<Target = TestAppContext>§
Sourcepub fn disable_accessibility(&mut self)
pub fn disable_accessibility(&mut self)
Disables accessibility for subsequently created test windows.
Sourcepub fn skip_drawing(&mut self)
pub fn skip_drawing(&mut self)
Turns off drawing for this app for the rest of the test.
Sourcepub fn test_function_name(&self) -> Option<&'static str>
pub fn test_function_name(&self) -> Option<&'static str>
Returns the name of the test function that created this context, if known.
Sourcepub fn did_prompt_for_new_path(&self) -> bool
pub fn did_prompt_for_new_path(&self) -> bool
Returns whether a new-path prompt is waiting for TestAppContext::simulate_new_path_selection.
Sourcepub fn active_idle_sleep_preventions(&self) -> usize
pub fn active_idle_sleep_preventions(&self) -> usize
Returns the number of active idle sleep prevention tokens.
Sourcepub fn set_idle_sleep_prevention_delay(&self, delay: Duration)
pub fn set_idle_sleep_prevention_delay(&self, delay: Duration)
Sets the delay for subsequent idle sleep prevention acquisitions.
Sourcepub fn set_idle_sleep_prevention_fails(&self, fails: bool)
pub fn set_idle_sleep_prevention_fails(&self, fails: bool)
Makes subsequent idle sleep prevention acquisitions fail or succeed.
Sourcepub fn new_app(&self) -> TestAppContext
pub fn new_app(&self) -> TestAppContext
Creates another app that shares this context’s scheduler, so tasks from both apps interleave deterministically.
The new app has its own state, windows and globals.
Sourcepub fn quit(&self)
pub fn quit(&self)
Runs the cleanup registered with TestAppContext::on_quit, then shuts the app down.
#[gpui::test] calls this when the test ends.
Sourcepub fn on_quit(&mut self, f: impl FnOnce() + 'static)
pub fn on_quit(&mut self, f: impl FnOnce() + 'static)
Registers f to run when the test ends, before the app shuts down.
Sourcepub fn refresh(&mut self) -> Result<()>
pub fn refresh(&mut self) -> Result<()>
Marks every window for redraw on the next effect cycle. Always returns Ok(()).
Sourcepub fn executor(&self) -> BackgroundExecutor
pub fn executor(&self) -> BackgroundExecutor
Returns a clone of the background executor.
Sourcepub fn foreground_executor(&self) -> &ForegroundExecutor
pub fn foreground_executor(&self) -> &ForegroundExecutor
Returns the foreground executor.
Sourcepub fn update<R>(&self, f: impl FnOnce(&mut App) -> R) -> R
pub fn update<R>(&self, f: impl FnOnce(&mut App) -> R) -> R
Runs f with mutable access to the App.
Unlike TestApp::update, this doesn’t run pending
tasks. Call TestAppContext::run_until_parked afterward if you need them.
§Example
let cx = TestAppContext::single();
let finished = Rc::new(Cell::new(false));
let flag = finished.clone();
cx.foreground_executor().spawn(async move { flag.set(true) }).detach();
cx.update(|_| ());
assert!(!finished.get(), "update doesn't run pending tasks");
cx.run_until_parked();
assert!(finished.get());Sourcepub fn add_window<F, V>(&mut self, build_window: F) -> WindowHandle<V>
pub fn add_window<F, V>(&mut self, build_window: F) -> WindowHandle<V>
Opens a window with maximized bounds and returns its handle.
The window is backed by a test platform window, so input and resize helpers work on it. This doesn’t run pending tasks.
§Panics
Panics if the window can’t be opened.
Sourcepub fn open_window<F, V>(
&mut self,
window_size: Size<Pixels>,
build_window: F,
) -> WindowHandle<V>
pub fn open_window<F, V>( &mut self, window_size: Size<Pixels>, build_window: F, ) -> WindowHandle<V>
Opens a window of window_size at the origin and returns its handle.
Use this when a layout test needs a known size. TestAppContext::add_window
uses the size of the test display instead. This doesn’t run pending tasks.
§Panics
Panics if the window can’t be opened.
Sourcepub fn add_empty_window(&mut self) -> &mut VisualTestContext
pub fn add_empty_window(&mut self) -> &mut VisualTestContext
Opens a window with an empty root view and returns a VisualTestContext for it.
Runs pending tasks before it returns.
Sourcepub fn add_window_view<F, V>(
&mut self,
build_root_view: F,
) -> (Entity<V>, &mut VisualTestContext)
pub fn add_window_view<F, V>( &mut self, build_root_view: F, ) -> (Entity<V>, &mut VisualTestContext)
Opens a window whose root view build_root_view builds.
Returns the root view’s entity and a VisualTestContext for the window. Use
the returned context from then on, which is the usual pattern:
let (view, cx) = cx.add_window_view(...);. Runs pending tasks before it returns.
See testing a window for an example.
Sourcepub fn text_system(&self) -> &Arc<TextSystem> ⓘ
pub fn text_system(&self) -> &Arc<TextSystem> ⓘ
Returns the text system.
Sourcepub fn cursor_style(&self) -> CursorStyle
pub fn cursor_style(&self) -> CursorStyle
Returns the cursor most recently applied to the test platform.
Sourcepub fn write_to_clipboard(&self, item: ClipboardItem)
pub fn write_to_clipboard(&self, item: ClipboardItem)
Writes item to the test clipboard.
Sourcepub fn read_from_clipboard(&self) -> Option<ClipboardItem>
pub fn read_from_clipboard(&self) -> Option<ClipboardItem>
Returns the item most recently written to the test clipboard, or None.
Sourcepub fn simulate_new_path_selection(
&self,
select_path: impl FnOnce(&Path) -> Option<PathBuf>,
)
pub fn simulate_new_path_selection( &self, select_path: impl FnOnce(&Path) -> Option<PathBuf>, )
Answers the oldest pending new-path prompt.
select_path receives the directory the app asked about and returns the chosen
path, or None to cancel.
§Panics
Panics if no new-path prompt is pending.
Sourcepub fn simulate_path_prompt_response(
&self,
select_paths: impl FnOnce(&PathPromptOptions) -> Option<Vec<PathBuf>>,
)
pub fn simulate_path_prompt_response( &self, select_paths: impl FnOnce(&PathPromptOptions) -> Option<Vec<PathBuf>>, )
Answers the oldest pending prompt_for_paths request.
select_paths receives the prompt’s options and returns the chosen paths, or
None to cancel.
§Panics
Panics if no paths prompt is pending. Also panics if select_paths returns more
than one path for a prompt that doesn’t allow multiple selection.
Sourcepub fn did_prompt_for_paths(&self) -> bool
pub fn did_prompt_for_paths(&self) -> bool
Returns whether a prompt_for_paths request is waiting for TestAppContext::simulate_path_prompt_response.
Sourcepub fn simulate_prompt_answer(&self, button: &str)
pub fn simulate_prompt_answer(&self, button: &str)
Presses the button labelled button on the oldest pending prompt.
§Panics
Panics if no prompt is pending, or if no button on the prompt has the label button.
Sourcepub fn has_pending_prompt(&self) -> bool
pub fn has_pending_prompt(&self) -> bool
Returns whether a prompt is waiting for an answer.
Sourcepub fn pending_prompt(&self) -> Option<(String, String)>
pub fn pending_prompt(&self) -> Option<(String, String)>
Returns the message and detail of the oldest pending prompt, or None.
The detail is an empty string when the prompt has none.
Sourcepub fn opened_url(&self) -> Option<String>
pub fn opened_url(&self) -> Option<String>
Returns the URL most recently passed to open_url, or None.
Only the last URL is kept.
Sourcepub fn app_identity(&self) -> Option<(SharedString, SharedString)>
pub fn app_identity(&self) -> Option<(SharedString, SharedString)>
Returns the identifier and name set with set_app_identity, or None if none was set.
Sourcepub fn shown_system_notifications(&self) -> Vec<SystemNotification>
pub fn shown_system_notifications(&self) -> Vec<SystemNotification>
Returns every system notification shown during the test, in order.
A notification shown before the app has an identity is dropped and doesn’t appear here.
Sourcepub fn delivered_system_notifications(&self) -> Vec<SystemNotification>
pub fn delivered_system_notifications(&self) -> Vec<SystemNotification>
Returns the notifications that are shown and not yet dismissed.
A notification with the same tag as an earlier one replaces it.
Sourcepub fn dismissed_system_notifications(&self) -> Vec<SharedString>
pub fn dismissed_system_notifications(&self) -> Vec<SharedString>
Returns the tags of the notifications dismissed during the test, in order.
Sourcepub fn simulate_system_notification_response(
&self,
response: SystemNotificationResponse,
)
pub fn simulate_system_notification_response( &self, response: SystemNotificationResponse, )
Delivers response to the response handlers, as if the user had activated the notification.
Sourcepub fn simulate_window_resize(
&self,
window_handle: AnyWindowHandle,
size: Size<Pixels>,
)
pub fn simulate_window_resize( &self, window_handle: AnyWindowHandle, size: Size<Pixels>, )
Resizes window_handle to size. See VisualTestContext::simulate_resize.
Sourcepub fn simulate_window_visibility_change(
&self,
window_handle: AnyWindowHandle,
visibility: WindowVisibility,
)
pub fn simulate_window_visibility_change( &self, window_handle: AnyWindowHandle, visibility: WindowVisibility, )
Simulates a change in whether the platform is presenting the window.
Sourcepub fn simulate_display_added(
&self,
display_id: DisplayId,
refresh_interval: Option<Duration>,
)
pub fn simulate_display_added( &self, display_id: DisplayId, refresh_interval: Option<Duration>, )
Simulates connecting a display.
Sourcepub fn simulate_display_removed(&self, display_id: DisplayId)
pub fn simulate_display_removed(&self, display_id: DisplayId)
Simulates disconnecting a display.
Sourcepub fn simulate_display_refresh_interval_change(
&self,
display_id: DisplayId,
refresh_interval: Option<Duration>,
)
pub fn simulate_display_refresh_interval_change( &self, display_id: DisplayId, refresh_interval: Option<Duration>, )
Simulates a connected display changing its refresh interval.
Sourcepub fn simulate_window_visual_viewport_change(
&self,
window_handle: AnyWindowHandle,
bounds: Bounds<Pixels>,
)
pub fn simulate_window_visual_viewport_change( &self, window_handle: AnyWindowHandle, bounds: Bounds<Pixels>, )
Simulates visible viewport changes without resizing the window’s layout area.
Sourcepub fn simulate_window_scale_factor_change(
&self,
window_handle: AnyWindowHandle,
scale_factor: f32,
)
pub fn simulate_window_scale_factor_change( &self, window_handle: AnyWindowHandle, scale_factor: f32, )
Simulates the window moving to a display with a different scale factor.
Sourcepub fn expect_restart(&self) -> Receiver<(Option<PathBuf>, Vec<OsString>)> ⓘ
pub fn expect_restart(&self) -> Receiver<(Option<PathBuf>, Vec<OsString>)> ⓘ
Returns a receiver that gets the path and arguments of the next restart request.
The app doesn’t restart in a test. Calling this again replaces the previous sender, so the previous receiver is cancelled.
Sourcepub fn set_screen_capture_sources(&self, sources: Vec<TestScreenCaptureSource>)
pub fn set_screen_capture_sources(&self, sources: Vec<TestScreenCaptureSource>)
Sets the sources that screen capture queries return.
Sourcepub fn windows(&self) -> Vec<AnyWindowHandle>
pub fn windows(&self) -> Vec<AnyWindowHandle>
Returns the handles of all open windows.
Sourcepub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task<R> ⓘwhere
Fut: Future<Output = R> + 'static,
R: 'static,
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncApp) -> Fut) -> Task<R> ⓘwhere
Fut: Future<Output = R> + 'static,
R: 'static,
Spawns a future on the foreground executor, with an AsyncApp for this app.
The future runs when tasks run, such as during TestAppContext::run_until_parked
or a simulate_* method. A plain update doesn’t run it.
Sourcepub fn has_global<G: Global>(&self) -> bool
pub fn has_global<G: Global>(&self) -> bool
Returns whether a global of type G is set.
Sourcepub fn read_global<G: Global, R>(&self, read: impl FnOnce(&G, &App) -> R) -> R
pub fn read_global<G: Global, R>(&self, read: impl FnOnce(&G, &App) -> R) -> R
Runs read with the global of type G.
§Panics
Panics if no global of type G is set. Use TestAppContext::try_read_global when it might not be.
Sourcepub fn try_read_global<G: Global, R>(
&self,
read: impl FnOnce(&G, &App) -> R,
) -> Option<R>
pub fn try_read_global<G: Global, R>( &self, read: impl FnOnce(&G, &App) -> R, ) -> Option<R>
Runs read with the global of type G if it is set, and returns None otherwise.
Sourcepub fn set_global<G: Global>(&mut self, global: G)
pub fn set_global<G: Global>(&mut self, global: G)
Sets the global of type G, replacing any previous value.
Sourcepub fn update_global<G: Global, R>(
&mut self,
update: impl FnOnce(&mut G, &mut App) -> R,
) -> R
pub fn update_global<G: Global, R>( &mut self, update: impl FnOnce(&mut G, &mut App) -> R, ) -> R
Runs update with mutable access to the global of type G.
§Panics
Panics if no global of type G is set.
Sourcepub fn to_async(&self) -> AsyncApp
pub fn to_async(&self) -> AsyncApp
Returns an AsyncApp for this app.
The handle holds a weak reference, so it can’t keep the app alive.
Sourcepub fn run_until_parked(&self)
pub fn run_until_parked(&self)
Runs pending tasks until none can make progress.
This doesn’t move the simulated clock. Use executor().advance_clock for that.
Timers that haven’t expired stay pending.
Sourcepub fn dispatch_action<A>(&mut self, window: AnyWindowHandle, action: A)where
A: Action,
pub fn dispatch_action<A>(&mut self, window: AnyWindowHandle, action: A)where
A: Action,
Dispatches action to the focused element in window, then runs pending tasks.
§Panics
Panics if window has been closed.
Sourcepub fn simulate_keystrokes(&mut self, window: AnyWindowHandle, keystrokes: &str)
pub fn simulate_keystrokes(&mut self, window: AnyWindowHandle, keystrokes: &str)
Sends each keystroke in a space-separated list to window, then runs pending tasks.
Each part is parsed as in TestAppWindow::simulate_keystroke.
The space bar is the key "space", which can’t appear in this list, because
a space separates keystrokes. Two spaces in a row send an empty keystroke.
§Panics
Panics if any part isn’t a valid keystroke.
Sourcepub fn simulate_input(&mut self, window: AnyWindowHandle, input: &str)
pub fn simulate_input(&mut self, window: AnyWindowHandle, input: &str)
Types input into window by sending one keystroke per character, then runs pending tasks.
Each character is parsed as a keystroke, so the text reaches text inputs. A
space is sent with the key " ", not "space".
Splitting on an empty string also sends an empty keystroke before the first character and after the last. Don’t rely on those.
Sourcepub fn dispatch_keystroke(
&mut self,
window: AnyWindowHandle,
keystroke: Keystroke,
)
pub fn dispatch_keystroke( &mut self, window: AnyWindowHandle, keystroke: Keystroke, )
Dispatches one keystroke to the focused element in window.
This doesn’t run pending tasks. TestAppContext::simulate_keystrokes does.
Sourcepub fn notifications<T: 'static>(
&mut self,
entity: &Entity<T>,
) -> impl Stream<Item = ()> + use<T>
pub fn notifications<T: 'static>( &mut self, entity: &Entity<T>, ) -> impl Stream<Item = ()> + use<T>
Returns a stream that yields () each time entity notifies.
The stream ends when the entity is released.
Sourcepub fn events<Evt, T: 'static + EventEmitter<Evt>>(
&mut self,
entity: &Entity<T>,
) -> UnboundedReceiver<Evt>where
Evt: 'static + Clone,
pub fn events<Evt, T: 'static + EventEmitter<Evt>>(
&mut self,
entity: &Entity<T>,
) -> UnboundedReceiver<Evt>where
Evt: 'static + Clone,
Returns a stream of the events entity emits, cloned, in order.
Sourcepub async fn condition<T: 'static>(
&mut self,
entity: &Entity<T>,
predicate: impl FnMut(&mut T, &mut Context<'_, T>) -> bool,
)
pub async fn condition<T: 'static>( &mut self, entity: &Entity<T>, predicate: impl FnMut(&mut T, &mut Context<'_, T>) -> bool, )
Waits until predicate returns true for entity, checking after each notification.
§Panics
Panics if the predicate isn’t true within 3 seconds of simulated time, or if the entity is released while waiting.
Trait Implementations§
Source§impl AppContext for VisualTestContext
impl AppContext for VisualTestContext
Source§fn new<T: 'static>(
&mut self,
build_entity: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Entity<T>
fn new<T: 'static>( &mut self, build_entity: impl FnOnce(&mut Context<'_, T>) -> T, ) -> Entity<T>
build_entity, and returns a handle to it. Read moreSource§fn reserve_entity<T: 'static>(&mut self) -> Reservation<T>
fn reserve_entity<T: 'static>(&mut self) -> Reservation<T>
Reservation for it. Read moreSource§fn insert_entity<T: 'static>(
&mut self,
reservation: Reservation<T>,
build_entity: impl FnOnce(&mut Context<'_, T>) -> T,
) -> Entity<T>
fn insert_entity<T: 'static>( &mut self, reservation: Reservation<T>, build_entity: impl FnOnce(&mut Context<'_, T>) -> T, ) -> Entity<T>
Source§fn update_entity<T, R>(
&mut self,
handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Rwhere
T: 'static,
fn update_entity<T, R>(
&mut self,
handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Rwhere
T: 'static,
Source§fn as_mut<'a, T>(&'a mut self, handle: &Entity<T>) -> GpuiBorrow<'a, T>where
T: 'static,
fn as_mut<'a, T>(&'a mut self, handle: &Entity<T>) -> GpuiBorrow<'a, T>where
T: 'static,
Source§fn read_entity<T, R>(
&self,
handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R,
) -> Rwhere
T: 'static,
fn read_entity<T, R>(
&self,
handle: &Entity<T>,
read: impl FnOnce(&T, &App) -> R,
) -> Rwhere
T: 'static,
read. Read moreSource§fn notify(&mut self, entity_id: EntityId)
fn notify(&mut self, entity_id: EntityId)
entity_id changed. Its observers run and windows
that show it redraw. Read moreSource§fn emit<EntityType, EventType>(
&mut self,
entity: &Entity<EntityType>,
event: EventType,
)where
EntityType: EventEmitter<EventType>,
EventType: 'static,
fn emit<EntityType, EventType>(
&mut self,
entity: &Entity<EntityType>,
event: EventType,
)where
EntityType: EventEmitter<EventType>,
EventType: 'static,
Source§fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
f with the window’s root view, the window and the app, and returns the
result. Read moreSource§fn with_window<R>(
&mut self,
entity_id: EntityId,
f: impl FnOnce(&mut Window, &mut App) -> R,
) -> Option<R>
fn with_window<R>( &mut self, entity_id: EntityId, f: impl FnOnce(&mut Window, &mut App) -> R, ) -> Option<R>
f with the window that most recently rendered the entity entity_id, and
returns the result. Read moreSource§fn read_window<T, R>(
&self,
window: &WindowHandle<T>,
read: impl FnOnce(Entity<T>, &App) -> R,
) -> Result<R>where
T: 'static,
fn read_window<T, R>(
&self,
window: &WindowHandle<T>,
read: impl FnOnce(Entity<T>, &App) -> R,
) -> Result<R>where
T: 'static,
window with the app, and returns the result. Read moreSource§fn background_spawn<R>(
&self,
future: impl Future<Output = R> + Send + 'static,
) -> Task<R> ⓘwhere
R: Send + 'static,
fn background_spawn<R>(
&self,
future: impl Future<Output = R> + Send + 'static,
) -> Task<R> ⓘwhere
R: Send + 'static,
future on the background executor and returns a task for its result. Read moreSource§fn insert_global_entity<T: 'static>(&mut self, entity: Entity<T>)
fn insert_global_entity<T: 'static>(&mut self, entity: Entity<T>)
entity alive without a handle to it. Read moreSource§fn remove_global_entity<T: 'static>(&mut self, entity: &Entity<T>)
fn remove_global_entity<T: 'static>(&mut self, entity: &Entity<T>)
entity alive. It’s dropped once no other handle refers to it.Source§fn global_entities<T: 'static>(&self) -> impl Iterator<Item = Entity<T>>
fn global_entities<T: 'static>(&self) -> impl Iterator<Item = Entity<T>>
AppContext::insert_global_entity whose type is
T.Source§impl Clone for VisualTestContext
impl Clone for VisualTestContext
Source§impl Deref for VisualTestContext
impl Deref for VisualTestContext
Source§impl DerefMut for VisualTestContext
impl DerefMut for VisualTestContext
Source§impl VisualContext for VisualTestContext
impl VisualContext for VisualTestContext
Source§fn window_handle(&self) -> AnyWindowHandle
fn window_handle(&self) -> AnyWindowHandle
Get the underlying window handle underlying this context.
Source§fn new_window_entity<T: 'static>(
&mut self,
build_entity: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T,
) -> Entity<T>
fn new_window_entity<T: 'static>( &mut self, build_entity: impl FnOnce(&mut Window, &mut Context<'_, T>) -> T, ) -> Entity<T>
Source§fn update_window_entity<V: 'static, R>(
&mut self,
view: &Entity<V>,
update: impl FnOnce(&mut V, &mut Window, &mut Context<'_, V>) -> R,
) -> R
fn update_window_entity<V: 'static, R>( &mut self, view: &Entity<V>, update: impl FnOnce(&mut V, &mut Window, &mut Context<'_, V>) -> R, ) -> R
update with the entity, its window and a Context for the entity, and
returns the result, wrapped in VisualContext::Result.Auto Trait Implementations§
impl !RefUnwindSafe for VisualTestContext
impl !Send for VisualTestContext
impl !Sync for VisualTestContext
impl !UnwindSafe for VisualTestContext
impl Freeze for VisualTestContext
impl Unpin for VisualTestContext
impl UnsafeUnpin for VisualTestContext
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more