Skip to main content

Crate waft_test

Crate waft_test 

Source
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§

AskedAllocation
An allocation the app asked for.
AssetAnswers
What every asset answers: its length, None for a live stream, its tracks, its tags, and the size of its pictures, each or a failure.
FrameAsked
A picture the app asked an asset for.
ImageAnswers
What every image and every encoding answers.
ImageFacts
What an image says of itself.
MemoryFile
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.
MemoryFiles
A file system in memory, rooted at /.
MemoryFolder
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.
MockCameras
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.
MockCaptionSettings
Caption settings that answer the style the test gives, telling the app each time the test changes it. Every clone is the same settings.
MockCaptureSession
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.
MockClipboard
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.
MockCompositor
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.
MockDockMenu
A Dock menu that keeps the menu last set. Every clone is the same menu.
MockFileDialogs
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.
MockHardwareBuffer
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.
MockHardwareBufferAllocator
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.
MockHttpClient
A client that answers what the test configured. A request for a URL with no answer fails as a connection that found nothing.
MockImageCodecs
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.
MockLayer
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.
MockMediaAsset
An asset the app opened, as the test sees it. Every clone is the same asset.
MockMediaAssets
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.
MockMenuBar
A menu bar that keeps the menus last set. Every clone is the same menu bar.
MockNotifications
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.
MockOpener
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.
MockPlayer
A player the app opened, as the test sees it. Every clone is the same player.
MockPlayers
Players that keep each player opened, which reports the state, position, metadata and cues the test gives it. Every clone is the same players.
MockPopupMenus
Menus opened at a point, each answered at once with the choice the test gave, and kept. Every clone is the same.
MockResponse
One response a MockHttpClient answers.
MockTrayIcons
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.
MockVideoFrame
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.
MockVideoFrameReaders
Frame readers that never have a frame, and which keep each reader made. Every clone is the same readers.
ObjectSnapshot
The objects an App held at one moment, counted by type and creation site; see object_snapshot.
SentRequest
A request the app sent, as the client kept it.
ShownMenu
One menu the framework opened at a point in a view.
ShownTrayIcon
A tray icon as the test reads it back.
TestDispatcher
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.
TestFontSource
Flutter’s engine TestFontManager as FontCollection::RegisterTestFonts installs it: every family answers with FlutterTest, and font fallback is off.
TestPlatform
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.
TestTimeZone
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.
TestView
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.
TestViewHost
A view’s host that records what the view asks of the system, as flutter_test’s TestTextInput logs the text input channel and its tests log SystemChannels.mouseCursor, SystemChannels.navigation’s setFrameworkHandlesBack and SystemChannels.platform’s overlay style.
TestWindow
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 of TestWindows. It is neither minimized nor occluded until a test says so, and the test then reports the change itself, as a host would through EmbedderClient::window_changed.
TestWindows
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 through EmbedderClient::view_added.

Enums§

AskedDialog
A dialog the app asked for.
BarsShown
Whether the bars over a TestViewHost’s view were hidden, and how, or shown.
CodecCall
What the app asked of the codecs, in order.
Opened
What the app asked the opener.
PlayerCall
What a player was asked to do.
TextInputCall
What a TestViewHost’s text input was asked.
VideoOutputKind
The kind of a VideoOutput, which a PlayerCall records.

Constants§

IMPLICIT_VIEW_ID
The id of a TestView given none: the view of a test with one, as the engine numbers Flutter’s implicit view.

Functions§

assert_no_new_objects
Fails if app holds more objects of some type, made at some site, than it did at snapshot, 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, as Platform::read_image_pixels reads them back, encoded as a PNG’s bytes, for a test to write to a file.
object_snapshot
Counts the objects app holds now, kept or waiting for the next checkpoint.

Type Aliases§

MetricsListener
What hears that a TestView’s metrics changed: the host’s client, which EmbedderClient::view_metrics_changed reaches in an app a host runs.