Expand description
Test scaffolding: a TestPlatform to run an App on, a TestView for it to draw
into, whose TestViewHost records what it asks of the system, a MockClipboard for it to copy to and paste from, the system’s menus
(MockMenuBar, MockPopupMenus, MockDockMenu, MockTrayIcons) for it to set and
choose in, file dialogs (MockFileDialogs, with MemoryFile and MemoryFolder)
for it to open and save through, a hardware buffer allocator (MockHardwareBufferAllocator) for it to allocate buffers with,
and a compositor, frame readers, players, media assets and
cameras (MockCompositor, MockVideoFrameReaders, MockPlayers, MockMediaAssets,
MockCameras) for it to show and read media through, image codecs (MockImageCodecs)
for it to decode and encode images with, with the user’s caption settings (MockCaptionSettings) to draw subtitles
in, so a test supplies only the piece it is about. The shape of flutter_test’s TestPlatformDispatcher and
TestFlutterView: real implementations of the host traits that answer what a test
configures and record what the framework asks of them. Its fonts are flutter_test’s: every
family is FlutterTest (TestFontSource) unless the test gives the platform other fonts.
A test that looks at what the app paints gives the platform the system’s fonts and a GPU
with no window (TestPlatform::with_system_fonts, TestPlatform::with_gpu), reads
a widget’s image back through it, and can encode the pixels as a PNG (encode_png).
In a debug build, object_snapshot and assert_no_new_objects check that a piece of a
test leaves no object behind in the App’s arena.
A dev-dependency of a crate with tests:
[dev-dependencies]
waft-test = "0.1"Structs§
- Asked
Allocation - An allocation the app asked for.
- Asset
Answers - What every asset answers: its length,
Nonefor a live stream, its tracks, its tags, and the size of its pictures, each or a failure. - Frame
Asked - A picture the app asked an asset for.
- Image
Answers - What every image and every encoding answers.
- Image
Facts - What an image says of itself.
- Memory
File - A file in memory, given as a handle. When writable, a writer’s writes land only once it finishes, and a writer dropped before abandons them, as the web’s do. Every clone is the same file.
- Memory
Files - A file system in memory, rooted at
/. - Memory
Folder - A folder in memory, given as a handle: its files and folders by name. When writable, what it opens is writable, and files and folders are made in it. Every clone is the same folder.
- Mock
Cameras - Cameras that list what the test gave, telling the app each time the test changes the list, each running in the formats the test gave, and keep each session started, which reports the state the test gives it. A session started on a camera another session still runs joins that one’s format, as a system that runs a camera in one format at a time does. Every clone is the same cameras.
- Mock
Caption Settings - Caption settings that answer the style the test gives, telling the app each time the test changes it. Every clone is the same settings.
- Mock
Capture Session - A camera session the app started, as the test sees it. Its photos answer what the test gave, or that the session does not run; its recordings answer when they are stopped, writing nothing. Every clone is the same session.
- Mock
Clipboard - A clipboard held in memory, which answers every call at once but a promise’s, which answers once its producer does. Every clone is the same clipboard.
- Mock
Compositor - A compositor whose layers show nowhere and keep what they show now (
MockLayer), kept in the order made. It accepts the buffers the test gives it, none unless told. Every clone is the same compositor. - Mock
Dock Menu - A Dock menu that keeps the menu last set. Every clone is the same menu.
- Mock
File Dialogs - File dialogs that answer what the test gave, and keep each dialog asked for. Until the test gives an answer, every dialog is cancelled. Every clone is the same dialogs.
- Mock
Hardware Buffer - A hardware buffer of a size, in the format the test gives, with no pixels on any GPU: it is imported as no texture, as a buffer a device cannot take, which a drawing skips, and its pixels read back opaque black where it is in BGRA.
- Mock
Hardware Buffer Allocator - The system’s hardware buffer allocator, which allocates
MockHardwareBuffers in BGRA, as Apple’s systems do, and keeps each allocation asked for. Every clone is the same allocator. - Mock
Http Client - A client that answers what the test configured. A request for a URL with no answer fails as a connection that found nothing.
- Mock
Image Codecs - Image codecs that answer what the test set, at once, and keep what the app asked of them, with hardware codecs where the test gives them. Every clone is the same codecs.
- Mock
Layer - A layer that shows nothing, and keeps what it shows now: the buffer presented last, as its
current_picture, and the layers placed under it then; and how many pictures it was handed. Presents release their buffers at once. - Mock
Media Asset - An asset the app opened, as the test sees it. Every clone is the same asset.
- Mock
Media Assets - Media assets that each answer what the test set, at once, and keep each asset opened with the pictures asked of it. Every clone is the same assets.
- Mock
Menu Bar - A menu bar that keeps the menus last set. Every clone is the same menu bar.
- Mock
Notifications - Notifications that keep what the app posted, scheduled and removed. By default any app may notify, as on a system with no permission question, and replies and scheduling are there. Every clone is the same notifications.
- Mock
Opener - An opener that keeps what it was asked and answers what the test gave: every link and file opens, until the test says otherwise. Every clone is the same opener.
- Mock
Player - A player the app opened, as the test sees it. Every clone is the same player.
- Mock
Players - Players that keep each player opened, which reports the state, position, metadata and cues the test gives it. Every clone is the same players.
- Mock
Popup Menus - Menus opened at a point, each answered at once with the choice the test gave, and kept. Every clone is the same.
- Mock
Response - One response a
MockHttpClientanswers. - Mock
Tray Icons - Tray icons kept while they are there, each with what the framework set, its menus opened at it answered with the choice the test gave. An icon is answered at once, and offers both kinds of menu, as macOS’s status items do, unless the test leaves one out, as Windows and Linux do, or has the tray refuse icons. Every clone is the same tray.
- Mock
Video Frame - A picture of a size, with no pixels on any GPU: its buffer is imported as no texture, as a frame a device cannot take, which a drawing skips, and its pixels read back opaque black, in BGRA as Apple’s frames are.
- Mock
Video Frame Readers - Frame readers that never have a frame, and which keep each reader made. Every clone is the same readers.
- Object
Snapshot - The objects an
Appheld at one moment, counted by type and creation site; seeobject_snapshot. - Sent
Request - A request the app sent, as the client kept it.
- Shown
Menu - One menu the framework opened at a point in a view.
- Shown
Tray Icon - A tray icon as the test reads it back.
- Test
Dispatcher - A host that records what it was asked for and never wakes the app. The test pumps the app
instead, where a host would call
EmbedderClient::wake, and work runs at once on the calling thread, so a test needs only a checkpoint to see its result. - Test
Font Source - Flutter’s engine
TestFontManagerasFontCollection::RegisterTestFontsinstalls it: every family answers with FlutterTest, and font fallback is off. - Test
Platform - A platform a test builds: which host it claims to be, the views it offers, and each capability as the test’s own implementation or absent. It keeps the frames the framework asks for, what it says of whether it handles back, and the deadlines it asks to be woken at, so a test can assert on them; the test itself pumps the app, since there is no loop to run it.
- Test
Time Zone - A local time zone for a test: UTC, a fixed offset and name, or any rule of the instant, such as a zone with summer time.
- Test
View - 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’sTestFlutterView. 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. - Test
View Host - A view’s host that records what the view asks of the system, as
flutter_test’sTestTextInputlogs the text input channel and its tests logSystemChannels.mouseCursor,SystemChannels.navigation’ssetFrameworkHandlesBackandSystemChannels.platform’s overlay style. - Test
Window - A window that shows nothing, keeps the frame, the title and the icon it was last given, whether
it was last shown or hidden, whether it is maximized or full screen and the size limits it was
last given, and
counts how often it
was closed and dragged: one of
TestWindows, or one a test gives the app a view in. A closed window’s view is in no window any more, and is no longer among the views ofTestWindows. It is neither minimized nor occluded until a test says so, and the test then reports the change itself, as a host would throughEmbedderClient::window_changed. - Test
Windows - A desktop’s answer to requests for views: each request makes a window at once, over a view
that carries the request’s id and initial data. A test hands it to a platform
(
TestPlatform::with_windows), which lists the views of the windows still open; the test tells the framework of each new view itself, as a host would throughEmbedderClient::view_added.
Enums§
- Asked
Dialog - A dialog the app asked for.
- Bars
Shown - Whether the bars over a
TestViewHost’s view were hidden, and how, or shown. - Codec
Call - What the app asked of the codecs, in order.
- Opened
- What the app asked the opener.
- Player
Call - What a player was asked to do.
- Text
Input Call - What a
TestViewHost’s text input was asked. - Video
Output Kind - The kind of a
VideoOutput, which aPlayerCallrecords.
Constants§
- IMPLICIT_
VIEW_ ID - The id of a
TestViewgiven none: the view of a test with one, as the engine numbers Flutter’s implicit view.
Functions§
- assert_
no_ new_ objects - Fails if
appholds more objects of some type, made at some site, than it did atsnapshot, listing each such type and creation site with how many more. Run it after a checkpoint, so that what was let go is freed. - encode_
png pixels, asPlatform::read_image_pixelsreads them back, encoded as a PNG’s bytes, for a test to write to a file.- object_
snapshot - Counts the objects
appholds now, kept or waiting for the next checkpoint.
Type Aliases§
- Metrics
Listener - What hears that a
TestView’s metrics changed: the host’s client, whichEmbedderClient::view_metrics_changedreaches in an app a host runs.