Skip to content

Commit

Permalink
Fix test print json
Browse files Browse the repository at this point in the history
This changes so it is the tests that prints the json not the export function.
  • Loading branch information
nwessman committed Mar 8, 2021
1 parent 3415a7a commit 5867e48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public ExportAnimationException(String message) {
}

/**
* Creates the json representation of an animation object and prints it.
* Creates the json representation of an animation object and returns it.
* This is the public accesible function and can/should be changed to fit into the UI.
*
* @param animation the animation object to export
*/
public void exportAnimation(Animation animation){
public String exportAnimation(Animation animation){

String json = createJson(animation);
System.out.println("JSON: " + json);
return json;
}

/**
Expand All @@ -49,8 +49,6 @@ private String createJson(Animation animation){
Frames[] frames = new Frames[keyframes.size()];

if(frames.length != spritesheet.getTotalNumberOfSprites()){
//ERROR
System.out.println("ERROR");
throw new ExportAnimationException("Different dimensions of keyframes and sprites in spritesheet");
}

Expand Down Expand Up @@ -208,12 +206,7 @@ public Layer(String name, int opacity, String blendMode){
this.blendMode = blendMode;
}

}





}
}


Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
public class AsepriteHandlerTests {


/**
* Test that just create a json and prints in to standard output.
*/
@Test
public void exportAnimationTest() {
String spritesheetPath = "C:/Users/Nikla/Documents/Programmering/SoftwareFundamentals/Assignment-3-EC/litiengine/tests/de/gurkenlabs/litiengine/graphics/animation/aseprite_test_animation/Sprite-0001-sheet.png";
Expand All @@ -22,7 +25,8 @@ public void exportAnimationTest() {
Animation animation = new Animation(spritesheet, false, false, 2,2,2);

AsepriteHandler aseprite = new AsepriteHandler();
aseprite.exportAnimation(animation);
String result = aseprite.exportAnimation(animation);
System.out.println(result);

}
}

0 comments on commit 5867e48

Please sign in to comment.