Skip to main content

TestView

Struct TestView 

Source
pub struct TestView { /* private fields */ }
Expand description

A view that counts the scenes presented to it, keeps the last and the size it came at, shows none, and records what it asks of the system in its host: flutter_test’s TestFlutterView. A frame of a size other than the view had is heard by its host (ViewHost::view_size_changed), as a host that shows views sized to their content tells it.

Its metrics are what it was made with until a test sets one; each setter, and each reset_* that puts a metric back to what the view was made with, tells the MetricsListener, as TestFlutterView’s setters call onMetricsChanged.

Implementations§

Source§

impl TestView

Source

pub fn new(width: f64, height: f64) -> TestView

View IMPLICIT_VIEW_ID at pixel ratio 1, width by height physical pixels.

Source

pub fn with_pixel_ratio( width: f64, height: f64, device_pixel_ratio: f64, ) -> TestView

View IMPLICIT_VIEW_ID at device_pixel_ratio, width by height physical pixels.

Source

pub fn with_metrics(metrics: ViewMetrics) -> TestView

View IMPLICIT_VIEW_ID at metrics, as a host gives a view the metrics it was asked for.

Source

pub fn with_id(self, id: ViewId) -> TestView

The same view under another id, for a platform with several.

Source

pub fn with_request( self, id: RequestId, initial_data: Option<String>, ) -> TestView

The same view as one that arrived for request id, carrying initial_data.

Source

pub fn with_host(self, host: Rc<dyn ViewHost>) -> TestView

The same view asking what it asks of the system of host, as a view the app adds on a layer does; its own test_host hears nothing then.

Source

pub fn on_screen(self, screen: ScreenId) -> TestView

The same view on screen, as its metrics say.

Source

pub fn with_initial_data(self, initial_data: impl Into<String>) -> TestView

The same view as one an embedder gave with initial_data.

Source

pub fn set_metrics_listener(&self, listener: MetricsListener)

Makes listener the one that hears of each change to the view’s metrics, in place of the one before: what runs the app installs it, as a host hands a view’s changes to its client.

Source

pub fn set_physical_size(&self, size: Size)

Dart’s tester.view.physicalSize = size, which also makes the physical constraints tight to it.

Source

pub fn reset_physical_size(&self)

Dart’s tester.view.resetPhysicalSize(), which resets the physical constraints too.

Source

pub fn set_physical_constraints(&self, constraints: ViewConstraints)

Dart’s tester.view.physicalConstraints = constraints.

Source

pub fn reset_physical_constraints(&self)

Dart’s tester.view.resetPhysicalConstraints().

Source

pub fn set_device_pixel_ratio(&self, ratio: f64)

Dart’s tester.view.devicePixelRatio = ratio.

Source

pub fn reset_device_pixel_ratio(&self)

Dart’s tester.view.resetDevicePixelRatio().

Source

pub fn set_padding(&self, padding: ViewPadding)

Dart’s tester.view.padding = padding, in physical pixels.

Source

pub fn reset_padding(&self)

Dart’s tester.view.resetPadding().

Source

pub fn set_view_padding(&self, padding: ViewPadding)

Dart’s tester.view.viewPadding = padding, in physical pixels.

Source

pub fn reset_view_padding(&self)

Dart’s tester.view.resetViewPadding().

Source

pub fn set_view_insets(&self, insets: ViewPadding)

Dart’s tester.view.viewInsets = insets, in physical pixels.

Source

pub fn reset_view_insets(&self)

Dart’s tester.view.resetViewInsets().

Source

pub fn set_system_gesture_insets(&self, insets: ViewPadding)

Dart’s tester.view.systemGestureInsets = insets, in physical pixels.

Source

pub fn reset_system_gesture_insets(&self)

Dart’s tester.view.resetSystemGestureInsets().

Source

pub fn set_title_bar_area(&self, area: Option<TitleBarArea>)

The strip the window buttons sit in, in physical pixels, as a windowed iPad reports it; Dart’s TestFlutterView has no counterpart.

Source

pub fn set_gesture_settings(&self, settings: GestureSettings)

Dart’s tester.view.gestureSettings = settings.

Source

pub fn reset_gesture_settings(&self)

Dart’s tester.view.resetGestureSettings().

Source

pub fn reset(&self)

Dart’s tester.view.reset(): every metric back to what the view was made with, told as one change.

Source

pub fn presented(&self) -> u32

How many pictures have been presented.

Source

pub fn last_scene(&self) -> Option<Arc<Scene>>

The scene presented last, the frame’s layer tree, which waft_embedder::slices turns into what it draws and the composition layers it places.

Source

pub fn last_frame_size(&self) -> Option<Size>

The size the frame presented last came at, in physical pixels: the size the view laid itself out at within its physical constraints.

Source

pub fn test_host(&self) -> &TestViewHost

The view’s host, which records the cursors shown over the view, the focus requested for it, what its text input was asked, what the framework said of handling Back in it and the bars’ styles set over it.

Source

pub fn test_window(&self) -> Option<Rc<TestWindow>>

The window the view is in, until it closes, with what it records: what View::window answers, as the test’s own window.

Trait Implementations§

Source§

impl View for TestView

Source§

fn id(&self) -> ViewId

Source§

fn metrics(&self) -> ViewMetrics

Source§

fn gesture_settings(&self) -> GestureSettings

Flutter FlutterView.gestureSettings.
Source§

fn present(&self, scene: Arc<Scene>, size: Size)

Renders and presents one scene, the frame’s layer tree, shared so the host may keep it: to present it again when the window is seen again, and to tell a scene equal to the last from one worth drawing. Physical pixels; the presenter applies no extra scaling. slices makes of it the picture a host draws and the composition layers a host with a compositor places in the same native transaction; a host without one draws the picture alone. Read more
Source§

fn host(&self) -> &dyn ViewHost

What the view asks of the system: its input methods, its cursor and its focus.
Source§

fn initial_data(&self) -> Option<String>

What whoever gave or asked for this view attached to it, such as which screen to show: what the app asked for it with (crate::Platform::request_view), or what an embedder said, as Flutter web’s initialData does. None for a view with none.
Source§

fn request_id(&self) -> Option<RequestId>

The request this view arrived for (crate::Platform::request_view, ViewEmbedder::add_view); None for a view the platform gave the app unasked.
Source§

fn window(&self) -> Option<WindowRef>

The window this view is in, where the platform lets the app manage it, as NSView.window answers: every window on a desktop, whether the app asked for it or the platform gave it, such as WaOS’s window around a program’s view, every activity’s task on Android, and every window scene on an iPad that has more than one. None for a view in nothing the app may manage: an iPhone’s screen, a web page’s element, a host app’s view. Closing a view is its window’s: a view with none is not the app’s to close, and its way out is to quit.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>