Skip to content

Commit

Permalink
make testing good
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 committed Feb 6, 2024
1 parent e3b795d commit ff4890b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ workspace = true
# Enable running image comparison tests. This is off by default,
# since the images we compare against are generated on CI, and may
# not match your local machine's Vulkan version / image output.
imgtests = ["ruffle_test_framework/ruffle_video_software", "ruffle_render_wgpu"]
imgtests = [
"ruffle_render_wgpu",
"ruffle_test_framework/ruffle_video_software",
"ruffle_test_framework/ruffle_video_external",
]
jpegxr = ["ruffle_test_framework/jpegxr"]
lzma = ["ruffle_test_framework/lzma"]

Expand Down
4 changes: 3 additions & 1 deletion tests/framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ ruffle_core = { path = "../../core", features = ["deterministic", "timeline_debu
ruffle_render = { path = "../../render" }
ruffle_input_format = { path = "../input-format" }
ruffle_socket_format = { path = "../socket-format" }
ruffle_video = { path = "../../video" }
ruffle_video_software = { path = "../../video/software", optional = true }
ruffle_video_external = { path = "../../video/external", optional = true }
image = { version = "0.24.8", default-features = false, features = ["png"] }
regex = "1.10.3"
url = "2.5.0"
Expand All @@ -32,4 +34,4 @@ percent-encoding = "2.3.1"

[features]
jpegxr = ["ruffle_core/jpegxr"]
lzma = ["ruffle_core/lzma"]
lzma = ["ruffle_core/lzma"]
31 changes: 28 additions & 3 deletions tests/framework/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,35 @@ impl PlayerOptions {

player_builder = player_builder.with_player_runtime(self.runtime);

#[cfg(feature = "ruffle_video_software")]
if self.with_video {
use ruffle_video_software::backend::SoftwareVideoBackend;
player_builder = player_builder.with_video(SoftwareVideoBackend::new())
// TODO: Do the same dance everywhere we set up a video backend, or
// make ExternalVideoBackend tolerate failure and fall back completely
// to SoftwareVideoBackend internally?
let video: Option<Box<dyn ruffle_video::backend::VideoBackend>> =
if cfg!(feature = "ruffle_video_external") {
match ruffle_video_external::backend::ExternalVideoBackend::new() {
Ok(video) => Some(Box::new(video)),
Err(_e) => {
if cfg!(feature = "ruffle_software_video") {
Some(Box::new(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
))
} else {
None
}
}
}
} else if cfg!(feature = "ruffle_video_software") {
Some(Box::new(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
))
} else {
None
};

if let Some(video) = video {
player_builder = player_builder.with_boxed_video(video);
}
}

Ok(player_builder)
Expand Down
Binary file modified tests/tests/swfs/visual/video/h264/output.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/tests/swfs/visual/video/h264/test.swf
Binary file not shown.
4 changes: 3 additions & 1 deletion tests/tests/swfs/visual/video/h264/test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
num_frames = 1
num_frames = 5
num_ticks = 10

[image_comparisons.output]
tolerance = 0
max_outliers = 1500

[player_options]
with_renderer = { optional = false, sample_count = 1 }
Expand Down
1 change: 0 additions & 1 deletion video/external/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl ExternalVideoBackend {
let filepath = std::env::current_dir().unwrap().join(filename);

if !filepath.is_file() {

let url = format!("{}{}{}", URL_BASE, filename, URL_SUFFIX);

let mut resp = isahc::get(&url).unwrap();
Expand Down
5 changes: 2 additions & 3 deletions video/external/src/decoder/openh264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl H264Decoder {

assert_eq!(
(version.uMajor, version.uMinor, version.uRevision),
(2, 4, 1),
(2, 4, 0),
"Unexpected OpenH264 version"
);

Expand Down Expand Up @@ -165,8 +165,7 @@ impl VideoDecoder for H264Decoder {
// input: encoded bitstream start position; should include start code prefix
// converting from AVCC (file-like) to Annex B (stream-like) format
// Thankfully the start code emulation prevention is there in both.
let mut buffer: Vec<c_uchar> =
Vec::with_capacity(encoded_frame.data.len());
let mut buffer: Vec<c_uchar> = Vec::with_capacity(encoded_frame.data.len());

let mut i = 0;
while i < encoded_frame.data.len() {
Expand Down

0 comments on commit ff4890b

Please sign in to comment.