Added a little test of the JSON writer.

I'm also using this test to do the conversions I need, since I just need our
two test scenes in JSON format.
This commit is contained in:
Michael Bayne
2013-01-23 15:38:39 -08:00
parent fd34ffda09
commit ebc91c015f
3 changed files with 47 additions and 0 deletions
@@ -0,0 +1,19 @@
<?xml version="1.0" standalone="yes"?>
<miso>
<width>22</width>
<height>22</height>
<viewwidth>10</viewwidth>
<viewheight>12</viewheight>
<base>131072, 131072, 131072, 131072, 131073, 131073, 131073, 131073, 131074, 65537, 65537, 131072, 131074, 131074, 131074, 131074, 131072, 131073, 131074, 131074, 131072, 131074, 131074, 131072, 131072, 131072, 131073, 131073, 131073, 131074, 131072, 65536, 65538, 131072, 131072, 131074, 131072, 131072, 131073, 131074, 131072, 131072, 131072, 131072, 131072, 131074, 131072, 131074, 131072, 131073, 131074, 131073, 131074, 65537, 65536, 131072, 131073, 131072, 131073, 131072, 131074, 131073, 131073, 131073, 131072, 131074, 131073, 131072, 131073, 131074, 131074, 131072, 131074, 131072, 131073, 65536, 65538, 131074, 131074, 131074, 131073, 131073, 131072, 131072, 131073, 131072, 131072, 131072, 131074, 131072, 131074, 131072, 131074, 131074, 131073, 131074, 131074, 65536, 65536, 131073, 131072, 131072, 131074, 131074, 131074, 131073, 131072, 131072, 131074, 131073, 131074, 131073, 131074, 131072, 131073, 131072, 131073, 131073, 131074, 65537, 65538, 131072, 131072, 131072, 131072, 131073, 131072, 131072, 131073, 131074, 131074, 131074, 131073, 131074, 131072, 131073, 131074, 131073, 131072, 131072, 131072, 65536, 65537, 131074, 131073, 131074, 131072, 131074, 131073, 131074, 131073, 131072, 131073, 131072, 131073, 131074, 131074, 131074, 131072, 131074, 131074, 131074, 131072, 65538, 65538, 131074, 131074, 131073, 131073, 131074, 131073, 131073, 131074, 131074, 131072, 131072, 131072, 131073, 131073, 131072, 131072, 131073, 131073, 131074, 131073, 65536, 65537, 65538, 65536, 65537, 65536, 65537, 65537, 65538, 65538, 65536, 131074, 131073, 131073, 131072, 131073, 131074, 131074, 131074, 131073, 131074, 131072, 65536, 65537, 65538, 65536, 65537, 65536, 65538, 65536, 65538, 65537, 65536, 131073, 131073, 131074, 131072, 131074, 131073, 131072, 131074, 131072, 131073, 131072, 65536, 65538, 65536, 65538, 65537, 65538, 65537, 65538, 65536, 65536, 65538, 65538, 131074, 131072, 131074, 131073, 131074, 131074, 131074, 131073, 131074, 131072, 65538, 131073, 131074, 131074, 131072, 131074, 131072, 131074, 131074, 131074, 131072, 131074, 131073, 131073, 131072, 131073, 131072, 131072, 131073, 131073, 131074, 131072, 65537, 131074, 131073, 131073, 131072, 131073, 131072, 131074, 131074, 131073, 131072, 131073, 131072, 131072, 131073, 131074, 131073, 131073, 131074, 65536, 65538, 65538, 65538, 131074, 131073, 131073, 131074, 131073, 131073, 131072, 131073, 131074, 131074, 131072, 131074, 131074, 131073, 131072, 131072, 131074, 131072, 65536, 65538, 65538, 65538, 131073, 131074, 131073, 131074, 131073, 131072, 131073, 131074, 131074, 131073, 131073, 131074, 131072, 131074, 131072, 131073, 131073, 131074, 65536, 65536, 65537, 65537, 131073, 131074, 131073, 131074, 131073, 131072, 131074, 131074, 131073, 131073, 131074, 131074, 131072, 131073, 131073, 131074, 131073, 131074, 65536, 65536, 65537, 65538, 131072, 131073, 131074, 131073, 131073, 131074, 131072, 131074, 131073, 131072, 131074, 131072, 131073, 131073, 131072, 131073, 131073, 131072, 131072, 131072, 65537, 65538, 131074, 131072, 131072, 131072, 131073, 131072, 131072, 131074, 131073, 131074, 131073, 131072, 131073, 131072, 131072, 131072, 131072, 131072, 131073, 131072, 65537, 65536, 131073, 131073, 131074, 131073, 131074, 131074, 131073, 131073, 131072, 131074, 131073, 131074, 131072, 131073, 131073, 131073, 131073, 131072, 131072, 131072, 65537, 65537, 131074, 131074, 131074, 131072, 131073, 131074, 131072, 131074, 131072, 131072, 131074, 131072, 131074, 131074, 131073, 131073, 131073, 131072, 131072, 131074, 131074, 131073, 131073, 131073, 131072, 131072, 131072, 131074, 131074, 131072, 131072, 131074, 131074, 131072, 131074, 131072, 131073, 131074, 131073, 131073, 131072, 131074, 131072, 131073, 131072, 131073, 131073, 131073, 131074, 131074, 131073, 131074, 131073, 131074, 131072, 131074</base>
<objects>
<object tileId="40173568" x="17" y="11"/>
<object tileId="851968" x="17" y="11"/>
<object tileId="589825" x="16" y="14"/>
<object tileId="917505" x="14" y="7"/>
<object tileId="917505" x="13" y="7"/>
<object tileId="1179649" x="8" y="15"/>
<object tileId="917505" x="8" y="13"/>
<object tileId="655361" x="7" y="10"/>
</objects>
</miso>
@@ -0,0 +1,31 @@
<?xml version="1.0" standalone="yes"?>
<miso>
<width>22</width>
<height>22</height>
<viewwidth>10</viewwidth>
<viewheight>12</viewheight>
<base>131072, 131073, 131073, 131073, 131074, 131072, 131072, 131072, 131073, 131074, 131074, 131072, 131074, 131074, 131072, 131072, 131073, 131073, 131072, 131073, 131073, 131072, 131074, 131072, 131074, 131074, 131072, 131073, 131074, 131072, 131074, 131074, 131074, 131072, 131074, 131074, 131072, 131074, 131072, 131072, 131073, 131074, 131074, 131072, 131074, 131072, 131072, 131072, 131072, 131074, 131073, 131073, 131074, 131073, 131074, 131073, 131074, 131073, 131074, 131074, 131072, 131072, 131073, 131074, 131074, 131073, 131073, 131073, 131073, 131073, 131072, 131073, 131072, 131072, 131072, 131072, 131072, 131074, 131074, 131073, 131074, 131072, 131074, 131074, 131073, 131074, 131073, 131073, 131072, 131073, 131073, 131072, 131074, 131073, 131073, 131074, 131072, 131072, 131073, 131072, 131072, 131073, 131072, 131072, 131074, 131072, 131072, 131074, 131073, 131072, 131072, 131072, 131074, 131074, 131073, 131073, 131073, 131073, 131074, 131073, 131074, 131072, 131074, 131073, 131073, 131072, 131074, 131073, 131072, 131074, 131073, 131072, 131074, 131074, 131074, 131072, 131074, 131073, 131074, 131072, 131073, 131072, 131072, 131072, 131073, 131074, 131073, 131073, 131072, 131072, 131073, 131072, 131072, 131074, 131074, 131074, 131072, 131074, 131074, 131074, 131074, 131074, 131074, 131072, 131072, 131073, 131074, 131073, 131073, 131073, 131072, 131073, 131073, 131073, 131073, 131074, 131073, 131074, 131072, 131072, 131073, 131073, 131072, 131073, 131074, 131074, 131074, 131074, 131072, 131073, 131074, 131072, 131072, 131072, 131074, 131072, 131073, 131073, 131074, 131072, 131072, 131073, 131073, 131072, 131074, 131072, 131073, 131073, 131073, 131073, 131074, 131073, 131072, 131073, 131072, 131073, 131072, 131073, 131072, 131072, 131074, 131074, 131072, 131073, 131074, 131074, 131073, 131074, 131074, 131072, 131073, 131072, 131072, 131072, 131073, 131073, 131072, 131073, 131072, 131074, 131074, 131074, 131073, 131073, 131073, 131073, 131073, 131073, 131073, 131073, 131074, 131073, 131072, 131072, 131074, 131072, 131074, 131073, 131073, 131074, 131074, 131074, 131074, 131072, 131073, 131073, 131074, 131072, 131072, 131073, 131072, 131074, 131073, 131074, 131072, 131072, 131073, 131073, 131074, 131072, 131073, 131074, 131072, 131073, 131074, 131073, 131072, 131072, 131074, 131072, 131073, 131073, 131072, 131074, 131073, 131072, 131074, 131072, 131074, 131072, 131072, 131074, 131073, 131074, 131074, 131073, 131072, 131074, 131072, 131074, 131073, 131073, 131073, 131073, 131072, 131074, 131073, 131073, 131074, 131073, 131073, 131074, 131074, 131074, 131072, 131073, 131072, 131074, 131072, 131074, 131072, 131072, 131073, 131074, 131073, 131072, 131074, 131073, 131073, 131073, 131074, 131073, 131073, 131072, 131074, 131072, 131072, 131072, 131073, 131074, 131074, 131073, 131072, 131074, 131073, 131074, 131074, 131073, 131074, 131073, 131073, 131072, 131072, 131074, 131073, 131072, 131073, 131074, 131073, 131074, 131073, 131072, 131073, 131073, 131072, 131074, 131072, 131074, 131074, 131072, 131074, 131074, 131072, 131072, 131072, 131073, 131072, 131073, 131072, 131073, 131073, 131074, 131074, 131073, 131074, 131074, 131073, 131074, 131072, 131073, 131072, 131074, 131073, 131073, 131073, 131073, 131073, 131073, 131072, 131073, 131073, 131074, 131073, 131072, 131072, 131074, 131072, 131073, 131072, 131074, 131073, 131073, 131073, 131073, 131073, 131072, 131072, 131072, 131072, 131074, 131072, 131073, 131073, 131073, 131074, 131074, 131072, 131072, 131074, 131073, 131073, 131073, 131072, 131072, 131074, 131073, 131074, 131073, 131074, 131073, 131073, 131073, 131074, 131073, 131074, 131072, 131073, 131072, 131073, 131073, 131074, 131072, 131073, 131072, 131072, 131072, 131074, 131073, 131072, 131072, 131074, 131073, 131072, 131072, 131073, 131073, 131074, 131072, 131074, 131072, 131072, 131074, 131074, 131074</base>
<objects>
<object tileId="1048577" x="18" y="10"/>
<object tileId="655362" x="18" y="13"/>
<object tileId="655363" x="17" y="19"/>
<object tileId="851968" x="17" y="11"/>
<object tileId="1048577" x="16" y="14"/>
<object tileId="1048576" x="14" y="11"/>
<object tileId="1048577" x="13" y="5"/>
<object tileId="851968" x="13" y="17"/>
<object tileId="1048576" x="12" y="18"/>
<object tileId="655361" x="12" y="22"/>
<object tileId="1179648" x="12" y="8"/>
<object tileId="786432" x="11" y="13"/>
<object tileId="655360" x="10" y="12"/>
<object tileId="655362" x="10" y="11"/>
<object tileId="1048576" x="9" y="7"/>
<object tileId="851968" x="7" y="12"/>
<object tileId="655361" x="6" y="15"/>
<object tileId="655361" x="6" y="12"/>
<object tileId="1179649" x="5" y="9"/>
<object tileId="1048576" x="3" y="10"/>
</objects>
</miso>
@@ -0,0 +1,47 @@
//
// Nenya library - tools for developing networked games
// Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved
// https://github.com/threerings/nenya
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.miso.tools
import org.junit.Test
import org.junit.Assert._
import playn.core.json.JsonImpl
import com.threerings.miso.data.SimpleMisoSceneModel
import com.threerings.miso.tools.json.SimpleMisoSceneWriter
import com.threerings.miso.tools.xml.SimpleMisoSceneParser
/**
* Tests the Json scene writing code.
*/
class SceneConverterTest
{
@Test def convertScene () {
val path = "rsrc/scenes/idyll.xml"
val in = getClass.getClassLoader.getResourceAsStream(path)
assertTrue("Missing file " + path, in != null)
val parser = new SimpleMisoSceneParser("")
val model = parser.parseScene(in)
assertTrue("No miso scene found in " + path, model != null)
val out = new JsonImpl().newWriter
SimpleMisoSceneWriter.write(model, out)
// println(out.write)
}
}