Learn R Programming

rgl (version 1.2.8)

expect_known_scene: Helper for testthat testing.

Description

Gets the current scene using scene3d, and compares the result to a saved value, optionally closing the window afterwards.

Usage

expect_known_scene(name, 
                   close = TRUE, 
                   file = paste0("testdata/", name, ".rds"),
                   ...)

Value

A value describing the changes to the saved object, suitable for use in test_that().

Arguments

name

By default, the base name of the file to save results in. Not used if file is specified.

close

Whether to close the rgl window after the comparison.

file

The file in which to save the result.

...

Other arguments which will be passed to expect_known_value.

Details

This function uses expect_known_value to save a representation of the scene. During the comparison, the scene is modified so that non-reproducible aspects are standardized or omitted:

  • object ids are changed to start at 1.

  • system-specific font names and texture names are deleted.

  • the window is shifted to the top left of the screen.

Calls to expect_known_scene() enable testthat::local_edition(2) for the duration of the call, so it will work in testthat “3rd edition”.

Examples

Run this code
if (FALSE) {
# These lines can be included in testthat::test_that() code.
plot3d(1:10, 1:10, 1:10)
expect_known_scene("plot")
}

Run the code above in your browser using DataLab