Reject duplicate document snapshot payloads
This commit is contained in:
@@ -344,6 +344,29 @@ void rejects_invalid_snapshot_face_pixels(pp::tests::Harness& h)
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame duplicate_face_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 1, 2, 3, 4 },
|
||||
},
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 1,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 5, 6, 7, 8 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig bad_byte_count_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
@@ -356,6 +379,12 @@ void rejects_invalid_snapshot_face_pixels(pp::tests::Harness& h)
|
||||
.frames = outside_frames,
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig duplicate_face_layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
.frames = duplicate_face_frames,
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Ink",
|
||||
@@ -384,6 +413,13 @@ void rejects_invalid_snapshot_face_pixels(pp::tests::Harness& h)
|
||||
.frames = bad_byte_count_frames,
|
||||
.selection_masks = {},
|
||||
});
|
||||
const auto duplicate_face_payload = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layers = duplicate_face_layers,
|
||||
.frames = frames,
|
||||
.selection_masks = {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !bad_layer_payload.ok());
|
||||
PP_EXPECT(h, bad_layer_payload.status().code == StatusCode::invalid_argument);
|
||||
@@ -391,6 +427,8 @@ void rejects_invalid_snapshot_face_pixels(pp::tests::Harness& h)
|
||||
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);
|
||||
PP_EXPECT(h, !duplicate_face_payload.ok());
|
||||
PP_EXPECT(h, duplicate_face_payload.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void manages_animation_frames_and_duration(pp::tests::Harness& h)
|
||||
@@ -649,6 +687,19 @@ void rejects_invalid_selection_masks(pp::tests::Harness& h)
|
||||
SelectionMask { .face_index = 0, .x = 0, .y = 0, .width = 2, .height = 1, .alpha8 = { 1 } });
|
||||
const auto missing_clear = document.clear_selection_mask(2);
|
||||
const auto bad_clear_face = document.clear_selection_mask(6);
|
||||
const DocumentLayerConfig layers[] { { .name = "Ink", .frames = {} } };
|
||||
const AnimationFrame frames[] { { .duration_ms = 100, .face_pixels = {} } };
|
||||
const SelectionMask duplicate_masks[] {
|
||||
{ .face_index = 2, .x = 0, .y = 0, .width = 1, .height = 1, .alpha8 = { 1 } },
|
||||
{ .face_index = 2, .x = 1, .y = 0, .width = 1, .height = 1, .alpha8 = { 2 } },
|
||||
};
|
||||
const auto duplicate_snapshot_masks = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 64,
|
||||
.height = 32,
|
||||
.layers = layers,
|
||||
.frames = frames,
|
||||
.selection_masks = duplicate_masks,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !bad_face.ok());
|
||||
PP_EXPECT(h, bad_face.code == StatusCode::out_of_range);
|
||||
@@ -662,6 +713,8 @@ void rejects_invalid_selection_masks(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, missing_clear.code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_clear_face.ok());
|
||||
PP_EXPECT(h, bad_clear_face.code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !duplicate_snapshot_masks.ok());
|
||||
PP_EXPECT(h, duplicate_snapshot_masks.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, document.selection_mask_payload_count() == 0U);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user