use of com.helospark.tactview.core.it.util.ui.FakeUi in project tactview by helospark.
the class CommonEffectTest method testThatEffectCanBeSavedAndRestored.
@Test
public void testThatEffectCanBeSavedAndRestored() throws IOException {
LightDiContext lightDi = IntegrationTestUtil.startContext();
List<EffectFactory> effectFactories = lightDi.getListOfBeans(EffectFactory.class);
FakeUi fakeUi = lightDi.getBean(FakeUi.class);
VisualTimelineClip clip = (VisualTimelineClip) fakeUi.dragProceduralClipToFirstChannel("singlecolor", TimelinePosition.ofZero());
for (var effectFactory : effectFactories) {
StatelessEffect effect = effectFactory.createEffect(new CreateEffectRequest(TimelinePosition.ofZero(), effectFactory.getEffectId(), TimelineClipType.VIDEO, clip.getInterval()));
if (!(effect instanceof StatelessVideoEffect)) {
continue;
}
if (!(effect instanceof StatelessVideoEffect) || effectFactory.getEffectId().equals("lensdistort")) /**
* trello.201, check why this occasionally fails
*/
{
continue;
}
ReadOnlyClipImage originalFrame = getFrame((StatelessVideoEffect) effect, clip);
SaveMetadata saveMetadata = new SaveMetadata(false);
Object savedEffect = effect.generateSavedContent(saveMetadata);
String saveData = createObjectMapper(saveMetadata).writeValueAsString(savedEffect);
JsonNode readData = StaticObjectMapper.objectMapper.readTree(saveData);
StatelessEffect restoredEffect = effectFactory.restoreEffect(readData, new LoadMetadata("filepath", StaticObjectMapper.objectMapper, lightDi));
ReadOnlyClipImage clonedFrame = getFrame((StatelessVideoEffect) restoredEffect, clip);
IntegrationTestUtil.assertFrameEquals(originalFrame, clonedFrame, effectFactory.getEffectId() + " is generating different image after save and restore");
freeFrame(originalFrame);
freeFrame(clonedFrame);
}
lightDi.close();
}
use of com.helospark.tactview.core.it.util.ui.FakeUi in project tactview by helospark.
the class CommonEffectTest method testThatEffectIsGeneratingSameImageAfterCloning.
@Test
public void testThatEffectIsGeneratingSameImageAfterCloning() {
LightDiContext lightDi = IntegrationTestUtil.startContext();
List<EffectFactory> effectFactories = lightDi.getListOfBeans(EffectFactory.class);
FakeUi fakeUi = lightDi.getBean(FakeUi.class);
VisualTimelineClip clip = (VisualTimelineClip) fakeUi.dragProceduralClipToFirstChannel("singlecolor", TimelinePosition.ofZero());
for (var effectFactory : effectFactories) {
StatelessEffect effect = effectFactory.createEffect(new CreateEffectRequest(TimelinePosition.ofZero(), effectFactory.getEffectId(), TimelineClipType.VIDEO, clip.getInterval()));
if (!(effect instanceof StatelessVideoEffect) || effectFactory.getEffectId().equals("lensdistort")) {
/**
* trello.201, check why this occasionally fails
*/
continue;
}
ReadOnlyClipImage originalFrame = getFrame((StatelessVideoEffect) effect, clip);
StatelessVideoEffect clonedEffect = (StatelessVideoEffect) effect.cloneEffect(CloneRequestMetadata.ofDefault());
ReadOnlyClipImage clonedFrame = getFrame(clonedEffect, clip);
IntegrationTestUtil.assertFrameEquals(originalFrame, clonedFrame, effectFactory.getEffectId() + " is generating different image after clone");
freeFrame(originalFrame);
freeFrame(clonedFrame);
}
lightDi.close();
}
Aggregations