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
impl TestView
Sourcepub fn new(width: f64, height: f64) -> TestView
pub fn new(width: f64, height: f64) -> TestView
View IMPLICIT_VIEW_ID at pixel ratio 1, width by height physical pixels.
Sourcepub fn with_pixel_ratio(
width: f64,
height: f64,
device_pixel_ratio: f64,
) -> TestView
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.
Sourcepub fn with_metrics(metrics: ViewMetrics) -> TestView
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.
Sourcepub fn with_id(self, id: ViewId) -> TestView
pub fn with_id(self, id: ViewId) -> TestView
The same view under another id, for a platform with several.
Sourcepub fn with_request(
self,
id: RequestId,
initial_data: Option<String>,
) -> TestView
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.
Sourcepub fn with_host(self, host: Rc<dyn ViewHost>) -> TestView
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.
Sourcepub fn on_screen(self, screen: ScreenId) -> TestView
pub fn on_screen(self, screen: ScreenId) -> TestView
The same view on screen, as its metrics say.
Sourcepub fn with_initial_data(self, initial_data: impl Into<String>) -> TestView
pub fn with_initial_data(self, initial_data: impl Into<String>) -> TestView
The same view as one an embedder gave with initial_data.
Sourcepub fn set_metrics_listener(&self, listener: MetricsListener)
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.
Sourcepub fn set_physical_size(&self, size: Size)
pub fn set_physical_size(&self, size: Size)
Dart’s tester.view.physicalSize = size, which also makes the physical constraints tight
to it.
Sourcepub fn reset_physical_size(&self)
pub fn reset_physical_size(&self)
Dart’s tester.view.resetPhysicalSize(), which resets the physical constraints too.
Sourcepub fn set_physical_constraints(&self, constraints: ViewConstraints)
pub fn set_physical_constraints(&self, constraints: ViewConstraints)
Dart’s tester.view.physicalConstraints = constraints.
Sourcepub fn reset_physical_constraints(&self)
pub fn reset_physical_constraints(&self)
Dart’s tester.view.resetPhysicalConstraints().
Sourcepub fn set_device_pixel_ratio(&self, ratio: f64)
pub fn set_device_pixel_ratio(&self, ratio: f64)
Dart’s tester.view.devicePixelRatio = ratio.
Sourcepub fn reset_device_pixel_ratio(&self)
pub fn reset_device_pixel_ratio(&self)
Dart’s tester.view.resetDevicePixelRatio().
Sourcepub fn set_padding(&self, padding: ViewPadding)
pub fn set_padding(&self, padding: ViewPadding)
Dart’s tester.view.padding = padding, in physical pixels.
Sourcepub fn reset_padding(&self)
pub fn reset_padding(&self)
Dart’s tester.view.resetPadding().
Sourcepub fn set_view_padding(&self, padding: ViewPadding)
pub fn set_view_padding(&self, padding: ViewPadding)
Dart’s tester.view.viewPadding = padding, in physical pixels.
Sourcepub fn reset_view_padding(&self)
pub fn reset_view_padding(&self)
Dart’s tester.view.resetViewPadding().
Sourcepub fn set_view_insets(&self, insets: ViewPadding)
pub fn set_view_insets(&self, insets: ViewPadding)
Dart’s tester.view.viewInsets = insets, in physical pixels.
Sourcepub fn reset_view_insets(&self)
pub fn reset_view_insets(&self)
Dart’s tester.view.resetViewInsets().
Sourcepub fn set_system_gesture_insets(&self, insets: ViewPadding)
pub fn set_system_gesture_insets(&self, insets: ViewPadding)
Dart’s tester.view.systemGestureInsets = insets, in physical pixels.
Sourcepub fn reset_system_gesture_insets(&self)
pub fn reset_system_gesture_insets(&self)
Dart’s tester.view.resetSystemGestureInsets().
Sourcepub fn set_title_bar_area(&self, area: Option<TitleBarArea>)
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.
Sourcepub fn set_gesture_settings(&self, settings: GestureSettings)
pub fn set_gesture_settings(&self, settings: GestureSettings)
Dart’s tester.view.gestureSettings = settings.
Sourcepub fn reset_gesture_settings(&self)
pub fn reset_gesture_settings(&self)
Dart’s tester.view.resetGestureSettings().
Sourcepub fn reset(&self)
pub fn reset(&self)
Dart’s tester.view.reset(): every metric back to what the view was made with, told as
one change.
Sourcepub fn last_scene(&self) -> Option<Arc<Scene>>
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.
Sourcepub fn last_frame_size(&self) -> Option<Size>
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.
Sourcepub fn test_host(&self) -> &TestViewHost
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.
Sourcepub fn test_window(&self) -> Option<Rc<TestWindow>>
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
impl View for TestView
fn id(&self) -> ViewId
fn metrics(&self) -> ViewMetrics
Source§fn gesture_settings(&self) -> GestureSettings
fn gesture_settings(&self) -> GestureSettings
FlutterView.gestureSettings.Source§fn present(&self, scene: Arc<Scene>, size: Size)
fn present(&self, scene: Arc<Scene>, size: Size)
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 moreSource§fn host(&self) -> &dyn ViewHost
fn host(&self) -> &dyn ViewHost
Source§fn initial_data(&self) -> Option<String>
fn initial_data(&self) -> Option<String>
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>
fn request_id(&self) -> Option<RequestId>
crate::Platform::request_view,
ViewEmbedder::add_view); None for a view the platform gave the app unasked.Source§fn window(&self) -> Option<WindowRef>
fn window(&self) -> Option<WindowRef>
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.