Validate snapshot face payloads
This commit is contained in:
@@ -311,6 +311,88 @@ void rejects_invalid_snapshot_metadata(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_layer_frame.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void rejects_invalid_snapshot_face_pixels(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame frames[] { { .duration_ms = 100, .face_pixels = {} } };
|
||||
const AnimationFrame bad_byte_count_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame outside_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 63,
|
||||
.y = 0,
|
||||
.width = 2,
|
||||
.height = 1,
|
||||
.rgba8 = { 1, 2, 3, 4, 5, 6, 7, 8 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig bad_byte_count_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.frames = bad_byte_count_frames,
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig outside_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.frames = outside_frames,
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.frames = {},
|
||||
},
|
||||
};
|
||||
|
||||
const auto bad_layer_payload = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layers = bad_byte_count_layers,
|
||||
.frames = frames,
|
||||
.selection_masks = {},
|
||||
});
|
||||
const auto outside_layer_payload = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layers = outside_layers,
|
||||
.frames = frames,
|
||||
.selection_masks = {},
|
||||
});
|
||||
const auto bad_root_payload = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layers = layers,
|
||||
.frames = bad_byte_count_frames,
|
||||
.selection_masks = {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !bad_layer_payload.ok());
|
||||
PP_EXPECT(h, bad_layer_payload.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !outside_layer_payload.ok());
|
||||
PP_EXPECT(h, outside_layer_payload.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_root_payload.ok());
|
||||
PP_EXPECT(h, bad_root_payload.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void manages_animation_frames_and_duration(pp::tests::Harness& h)
|
||||
{
|
||||
auto document_result = CanvasDocument::create(
|
||||
@@ -744,6 +826,7 @@ int main()
|
||||
harness.run("creates_document_from_snapshot_metadata", creates_document_from_snapshot_metadata);
|
||||
harness.run("preserves_per_layer_snapshot_timelines", preserves_per_layer_snapshot_timelines);
|
||||
harness.run("rejects_invalid_snapshot_metadata", rejects_invalid_snapshot_metadata);
|
||||
harness.run("rejects_invalid_snapshot_face_pixels", rejects_invalid_snapshot_face_pixels);
|
||||
harness.run("manages_animation_frames_and_duration", manages_animation_frames_and_duration);
|
||||
harness.run("moves_frames_and_preserves_active_frame_identity", moves_frames_and_preserves_active_frame_identity);
|
||||
harness.run("rejects_invalid_animation_frame_operations", rejects_invalid_animation_frame_operations);
|
||||
|
||||
Reference in New Issue
Block a user