changeset 74:78de82cc6bde

Tests: move graphical examples into examples, closes #606
author David Demelier <markand@malikania.fr>
date Thu, 22 Dec 2016 15:17:43 +0100
parents efe1a7fb43f8
children 88d996df3eba
files cmake/MalikaniaOptions.cmake examples/animation/CMakeLists.txt examples/animation/main.cpp examples/animation/resources/animations/margins.json examples/animation/resources/images/margins.png examples/animation/resources/sprites/margins.json examples/font/CMakeLists.txt examples/font/main.cpp examples/font/resources/DejaVuSans.ttf examples/image/CMakeLists.txt examples/image/main.cpp examples/image/resources/images/100x10.png examples/image/resources/images/10x100.png examples/image/resources/images/16x16.png examples/image/resources/images/smiley.png examples/image/resources/images/smiley.xcf examples/js-animation/CMakeLists.txt examples/js-animation/main.cpp examples/js-animation/resources/animations/margins.json examples/js-animation/resources/images/margins.png examples/js-animation/resources/sprites/margins.json examples/js-font/CMakeLists.txt examples/js-font/main.cpp examples/js-font/resources/DejaVuSans.ttf examples/js-image/CMakeLists.txt examples/js-image/main.cpp examples/js-image/resources/images/smiley.png examples/js-sprite/CMakeLists.txt examples/js-sprite/main.cpp examples/js-sprite/resources/images/margins.png examples/js-sprite/resources/sprites/margins.json examples/js-window/CMakeLists.txt examples/js-window/main.cpp examples/sprite/CMakeLists.txt examples/sprite/main.cpp examples/sprite/resources/images/margins.png examples/sprite/resources/images/margins.xcf examples/sprite/resources/images/mokodemo.png examples/sprite/resources/sprites/image-not-found.json examples/sprite/resources/sprites/margins.json examples/sprite/resources/sprites/no-property-cell.json examples/sprite/resources/sprites/no-property-image.json examples/sprite/resources/sprites/not-object.json examples/sprite/resources/sprites/property-cell-not-array.json examples/sprite/resources/sprites/property-cell-not-array2.json examples/sprite/resources/sprites/property-image-not-string.json examples/sprite/resources/sprites/simple.json tests/CMakeLists.txt tests/libclient/CMakeLists.txt tests/libclient/animation/CMakeLists.txt tests/libclient/animation/main.cpp tests/libclient/animation/resources/animations/margins.json tests/libclient/animation/resources/images/margins.png tests/libclient/animation/resources/sprites/margins.json tests/libclient/font/CMakeLists.txt tests/libclient/font/main.cpp tests/libclient/font/resources/DejaVuSans.ttf tests/libclient/image/CMakeLists.txt tests/libclient/image/main.cpp tests/libclient/image/resources/images/100x10.png tests/libclient/image/resources/images/10x100.png tests/libclient/image/resources/images/16x16.png tests/libclient/image/resources/images/smiley.png tests/libclient/image/resources/images/smiley.xcf tests/libclient/js-animation/CMakeLists.txt tests/libclient/js-animation/main.cpp tests/libclient/js-animation/resources/animations/margins.json tests/libclient/js-animation/resources/images/margins.png tests/libclient/js-animation/resources/sprites/margins.json tests/libclient/js-font/CMakeLists.txt tests/libclient/js-font/main.cpp tests/libclient/js-font/resources/DejaVuSans.ttf tests/libclient/js-image/CMakeLists.txt tests/libclient/js-image/main.cpp tests/libclient/js-image/resources/images/smiley.png tests/libclient/js-sprite/CMakeLists.txt tests/libclient/js-sprite/main.cpp tests/libclient/js-sprite/resources/images/margins.png tests/libclient/js-sprite/resources/sprites/margins.json tests/libclient/js-window/CMakeLists.txt tests/libclient/js-window/main.cpp tests/libclient/sprite/CMakeLists.txt tests/libclient/sprite/main.cpp tests/libclient/sprite/resources/images/margins.png tests/libclient/sprite/resources/images/margins.xcf tests/libclient/sprite/resources/images/mokodemo.png tests/libclient/sprite/resources/sprites/image-not-found.json tests/libclient/sprite/resources/sprites/margins.json tests/libclient/sprite/resources/sprites/no-property-cell.json tests/libclient/sprite/resources/sprites/no-property-image.json tests/libclient/sprite/resources/sprites/not-object.json tests/libclient/sprite/resources/sprites/property-cell-not-array.json tests/libclient/sprite/resources/sprites/property-cell-not-array2.json tests/libclient/sprite/resources/sprites/property-image-not-string.json tests/libclient/sprite/resources/sprites/simple.json
diffstat 95 files changed, 1436 insertions(+), 1438 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/MalikaniaOptions.cmake	Thu Dec 22 09:27:09 2016 +0100
+++ b/cmake/MalikaniaOptions.cmake	Thu Dec 22 15:17:43 2016 +0100
@@ -74,6 +74,7 @@
 
 option(WITH_VERA "Enable vera++ analyzer" On)
 option(WITH_TESTS "Enable unit tests" On)
+option(WITH_EXAMPLES "Enable examples" On)
 
 find_program(VERA_EXECUTABLE vera++)
 
@@ -94,6 +95,12 @@
     malikania_setg(WITH_TESTS_MSG "Yes")
 endif ()
 
+if (NOT WITH_EXAMPLES)
+    malikania_setg(WITH_EXAMPLES_MSG "No (disabled by user)")
+else ()
+    malikania_setg(WITH_EXAMPLES_MSG "Yes")
+endif ()
+
 #
 # Options for unit tests
 # -------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/animation/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,27 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME animation
+    LIBRARIES libmlk-client
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/animations/margins.json
+        resources/images/margins.png
+        resources/sprites/margins.json
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/animation/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,98 @@
+/*
+ * main.cpp -- test animation
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+#include <exception>
+
+#define BOOST_TEST_MODULE "Animation"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/animation.hpp>
+#include <malikania/animator.hpp>
+#include <malikania/client_resources_loader.hpp>
+#include <malikania/resources_locator.hpp>
+#include <malikania/window.hpp>
+
+namespace {
+
+mlk::window win(400, 400);
+
+} // !namespace
+
+class test_animation {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+
+public:
+    test_animation()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_animation_suite, test_animation)
+
+BOOST_AUTO_TEST_CASE(standard)
+{
+    try {
+        auto animation = m_loader.load_animation("animations/margins.json");
+
+        BOOST_REQUIRE_EQUAL(12U, animation.frames().size());
+        BOOST_REQUIRE_EQUAL(500U, animation[0].delay());
+        BOOST_REQUIRE_EQUAL(501U, animation[1].delay());
+        BOOST_REQUIRE_EQUAL(502U, animation[2].delay());
+        BOOST_REQUIRE_EQUAL(503U, animation[3].delay());
+        BOOST_REQUIRE_EQUAL(504U, animation[4].delay());
+        BOOST_REQUIRE_EQUAL(505U, animation[5].delay());
+        BOOST_REQUIRE_EQUAL(506U, animation[6].delay());
+        BOOST_REQUIRE_EQUAL(507U, animation[7].delay());
+        BOOST_REQUIRE_EQUAL(508U, animation[8].delay());
+        BOOST_REQUIRE_EQUAL(509U, animation[9].delay());
+        BOOST_REQUIRE_EQUAL(510U, animation[10].delay());
+        BOOST_REQUIRE_EQUAL(511U, animation[11].delay());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(draw)
+{
+    boost::timer::cpu_timer timer;
+
+    try {
+        mlk::animation animation = m_loader.load_animation("animations/margins.json");
+        mlk::animator animator(animation);
+
+        auto x = (400 / 2) - (animation.sprite().cell().width() / 2);
+        auto y = (400 / 2) - (animation.sprite().cell().height() / 2);
+
+        while (timer.elapsed().wall / 1000000LL < 8000) {
+            win.clear();
+            animator.draw(win, mlk::point(x, y));
+            animator.update();
+            win.present();
+        }
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/animation/resources/animations/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,17 @@
+{
+  "sprite": "sprites/margins.json",
+  "frames": [
+    { "delay": 500 },
+    { "delay": 501 },
+    { "delay": 502 },
+    { "delay": 503 },
+    { "delay": 504 },
+    { "delay": 505 },
+    { "delay": 506 },
+    { "delay": 507 },
+    { "delay": 508 },
+    { "delay": 509 },
+    { "delay": 510 },
+    { "delay": 511 }
+  ]
+}
Binary file examples/animation/resources/images/margins.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/animation/resources/sprites/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,6 @@
+{
+  "image": "images/margins.png",
+  "cell": [ 32, 32 ],
+  "margin": [ 4, 6 ],
+  "space": [ 2, 3 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/font/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,25 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME font
+    LIBRARIES libmlk-client
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/DejaVuSans.ttf
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/font/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,123 @@
+/*
+ * main.cpp -- test Font
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Font"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/client_resources_loader.hpp>
+#include <malikania/color.hpp>
+#include <malikania/font.hpp>
+#include <malikania/point.hpp>
+#include <malikania/resources_locator.hpp>
+#include <malikania/window.hpp>
+
+using namespace std::chrono_literals;
+
+namespace {
+
+mlk::window window(400, 400);
+
+} // !namespace
+
+class test_font {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+    mlk::font m_font;
+
+public:
+    test_font()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+        , m_font(m_loader.load_font("DejaVuSans.ttf", 10))
+    {
+        window.set_drawing_color(mlk::color("black"));
+        window.clear();
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_font_suite, test_font)
+
+BOOST_AUTO_TEST_CASE(topleft)
+{
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("top left", m_font, mlk::point(10, 10));
+    window.present();
+
+    std::this_thread::sleep_for(1s);
+}
+
+BOOST_AUTO_TEST_CASE(topright)
+{
+    auto dim = m_font.clip("top right");
+
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("top right", m_font, mlk::point(400 - dim.width() - 10, 10));
+    window.present();
+
+    std::this_thread::sleep_for(1s);
+}
+
+BOOST_AUTO_TEST_CASE(bottomleft)
+{
+    auto dim = m_font.clip("bottom left");
+
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("bottom left", m_font, mlk::point(10, 400 - dim.height() - 10));
+    window.present();
+
+    std::this_thread::sleep_for(1s);
+}
+
+BOOST_AUTO_TEST_CASE(bottomright)
+{
+    auto dim = m_font.clip("bottom right");
+
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("bottom right", m_font, mlk::point(400 - dim.width() - 10, 400 - dim.height() - 10));
+    window.present();
+
+    std::this_thread::sleep_for(1s);
+}
+
+BOOST_AUTO_TEST_CASE(center)
+{
+    auto dim = m_font.clip("center");
+
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("center", m_font, mlk::point(200 - (dim.width() / 2), 200 - (dim.height() -2)));
+    window.present();
+
+    std::this_thread::sleep_for(1s);
+}
+
+BOOST_AUTO_TEST_CASE(center2)
+{
+    auto dim = m_font.clip("The world is Malikania.");
+
+    window.set_drawing_color(mlk::color("white"));
+    window.draw_text("The world is Malikania.", m_font, mlk::point(200 - (dim.width() / 2), 200 - (dim.height() -2)));
+    window.present();
+
+    std::this_thread::sleep_for(3s);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/font/resources/DejaVuSans.ttf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/image/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,28 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME image
+    LIBRARIES libmlk-client
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/images/100x10.png
+        resources/images/10x100.png
+        resources/images/16x16.png
+        resources/images/smiley.png
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/image/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,111 @@
+/*
+ * main.cpp -- test Image
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Image"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/client_resources_loader.hpp>
+#include <malikania/image.hpp>
+#include <malikania/resources_locator.hpp>
+#include <malikania/window.hpp>
+
+using namespace std::chrono_literals;
+
+namespace {
+
+mlk::window window(400, 400);
+
+} // !namespace
+
+class test_image {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+
+public:
+    test_image()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_image_suite, test_image)
+
+BOOST_AUTO_TEST_CASE(image100x10)
+{
+    try {
+        auto image = m_loader.load_image("images/100x10.png");
+
+        BOOST_REQUIRE_EQUAL(100U, image.size().width());
+        BOOST_REQUIRE_EQUAL(10U, image.size().height());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(image16x16)
+{
+    try {
+        auto image = m_loader.load_image("images/16x16.png");
+
+        BOOST_REQUIRE_EQUAL(16U, image.size().width());
+        BOOST_REQUIRE_EQUAL(16U, image.size().height());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(image10x100)
+{
+    try {
+        auto image = m_loader.load_image("images/10x100.png");
+
+        BOOST_REQUIRE_EQUAL(10U, image.size().width());
+        BOOST_REQUIRE_EQUAL(100U, image.size().height());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(notfound)
+{
+    BOOST_REQUIRE_THROW(m_loader.load_image("image-not-found"), std::exception);
+}
+
+BOOST_AUTO_TEST_CASE(draw)
+{
+    try {
+        auto image = m_loader.load_image("images/smiley.png");
+        auto x = (400 / 2) - (image.size().width() / 2);
+        auto y = (400 / 2) - (image.size().height() / 2);
+
+        window.clear();
+        image.draw(window, mlk::point(x, y));
+        window.present();
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/image/resources/images/100x10.png has changed
Binary file examples/image/resources/images/10x100.png has changed
Binary file examples/image/resources/images/16x16.png has changed
Binary file examples/image/resources/images/smiley.png has changed
Binary file examples/image/resources/images/smiley.xcf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-animation/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,27 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME js-animation
+    LIBRARIES libmlk-client-js
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/animations/margins.json
+        resources/images/margins.png
+        resources/sprites/margins.json
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-animation/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,90 @@
+/*
+ * main.cpp -- test Animation (JavaScript binding)
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Javascript Animation"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/js_client_resources_loader.hpp>
+#include <malikania/js_animation.hpp>
+#include <malikania/js_animator.hpp>
+#include <malikania/js_window.hpp>
+#include <malikania/resources_locator.hpp>
+
+using namespace std::chrono_literals;
+
+class test_animation {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+    dukx_context m_ctx;
+
+public:
+    test_animation()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+        duk_push_object(m_ctx);
+        duk_put_global_string(m_ctx, "Malikania");
+        mlk::dukx_load_animation(m_ctx);
+        mlk::dukx_load_animator(m_ctx);
+        mlk::dukx_load_window(m_ctx);
+        dukx_put_client_loader(m_ctx, m_loader);
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_animation_suite, test_animation)
+
+BOOST_AUTO_TEST_CASE(basic)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "a = new Malikania.Animation('animations/margins.json');"
+            "d = new Malikania.Animator(a);"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        boost::timer::cpu_timer timer;
+
+        while (timer.elapsed().wall / 1000000LL < 8000) {
+            auto ret = duk_peval_string(m_ctx,
+                "w.setDrawingColor('lightskyblue');"
+                "w.clear();"
+                "d.draw(w, { x: 320 - 16, y: 240 - 16 });"
+                "d.update();"
+                "w.present();"
+            );
+
+            if (ret != 0) {
+                throw dukx_get_exception(m_ctx, -1);
+            }
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-animation/resources/animations/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,17 @@
+{
+  "sprite": "sprites/margins.json",
+  "frames": [
+    { "delay": 500 },
+    { "delay": 501 },
+    { "delay": 502 },
+    { "delay": 503 },
+    { "delay": 504 },
+    { "delay": 505 },
+    { "delay": 506 },
+    { "delay": 507 },
+    { "delay": 508 },
+    { "delay": 509 },
+    { "delay": 510 },
+    { "delay": 511 }
+  ]
+}
Binary file examples/js-animation/resources/images/margins.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-animation/resources/sprites/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,6 @@
+{
+  "image": "images/margins.png",
+  "cell": [ 32, 32 ],
+  "margin": [ 4, 6 ],
+  "space": [ 2, 3 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-font/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,25 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME js-font
+    LIBRARIES libmlk-client-js
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/DejaVuSans.ttf
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-font/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,78 @@
+/*
+ * main.cpp -- test Font (JavaScript binding)
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Javascript Font"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/js_client_resources_loader.hpp>
+#include <malikania/js_font.hpp>
+#include <malikania/js_window.hpp>
+#include <malikania/resources_locator.hpp>
+
+using namespace std::chrono_literals;
+
+class test_font {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+    dukx_context m_ctx;
+
+public:
+    test_font()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+        duk_push_object(m_ctx);
+        duk_put_global_string(m_ctx, "Malikania");
+        dukx_put_client_loader(m_ctx, m_loader);
+        mlk::dukx_load_font(m_ctx);
+        mlk::dukx_load_window(m_ctx);
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_font_suite, test_font)
+
+BOOST_AUTO_TEST_CASE(basic)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "f = new Malikania.Font('DejaVuSans.ttf', 10);"
+            "w.setDrawingColor('lightskyblue');"
+            "w.clear();"
+            "s = 'The world is Malikania.';"
+            "c = f.clip(s);"
+            "w.setDrawingColor('white');"
+            "w.drawText(s, f, { x: 320 - (c.width / 2), y: 240 - (c.height / 2) });"
+            "w.present();"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/js-font/resources/DejaVuSans.ttf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-image/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,25 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME js-image
+    LIBRARIES libmlk-client-js
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/images/smiley.png
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-image/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,121 @@
+/*
+ * main.cpp -- test Image (JavaScript binding)
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Javacript Image"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/js_client_resources_loader.hpp>
+#include <malikania/js_image.hpp>
+#include <malikania/js_window.hpp>
+#include <malikania/resources_locator.hpp>
+
+using namespace std::chrono_literals;
+
+class test_image {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+    dukx_context m_ctx;
+
+public:
+    test_image()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+        duk_push_object(m_ctx);
+        duk_put_global_string(m_ctx, "Malikania");
+        mlk::dukx_load_image(m_ctx);
+        mlk::dukx_load_window(m_ctx);
+        dukx_put_client_loader(m_ctx, m_loader);
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_image_suite, test_image)
+
+BOOST_AUTO_TEST_CASE(size)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "i = new Malikania.Image('images/smiley.png');"
+            "w = i.size.width;"
+            "h = i.size.height;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "w");
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+        duk_get_global_string(m_ctx, "h");
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(basic)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "i = new Malikania.Image('images/smiley.png');"
+            "w.setDrawingColor('lightskyblue');"
+            "w.clear();"
+            "i.draw(w, { x: 320 - 16, y: 240 - 16 });"
+            "w.present();"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(stretch)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "i = new Malikania.Image('images/smiley.png');"
+            "w.setDrawingColor('lightskyblue');"
+            "w.clear();"
+            "i.draw(w, null, { x: 10, y: 10, width: 620, height: 460 });"
+            "w.present();"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/js-image/resources/images/smiley.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-sprite/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,26 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME js-sprite
+    LIBRARIES libmlk-client-js
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/images/margins.png
+        resources/sprites/margins.json
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-sprite/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,201 @@
+/*
+ * main.cpp -- test Sprite (JavaScript binding)
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Javascript Sprite"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/js_client_resources_loader.hpp>
+#include <malikania/js_image.hpp>
+#include <malikania/js_sprite.hpp>
+#include <malikania/js_window.hpp>
+#include <malikania/resources_locator.hpp>
+
+using namespace mlk;
+
+using namespace std::chrono_literals;
+
+class test_sprite {
+protected:
+    directory_resources_locator m_locator;
+    client_resources_loader m_loader;
+    dukx_context m_ctx;
+
+public:
+    test_sprite()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+        duk_push_object(m_ctx);
+        duk_put_global_string(m_ctx, "Malikania");
+        mlk::dukx_load_image(m_ctx);
+        mlk::dukx_load_sprite(m_ctx);
+        mlk::dukx_load_window(m_ctx);
+        dukx_put_client_loader(m_ctx, m_loader);
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_sprite_suite, test_sprite)
+
+BOOST_AUTO_TEST_CASE(cell)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "w = s.cell.width;"
+            "h = s.cell.height;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "w");
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+        duk_get_global_string(m_ctx, "h");
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(columns)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "n = s.columns;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "n");
+        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(margins)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "w = s.margins.width;"
+            "h = s.margins.height;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "w");
+        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+        duk_get_global_string(m_ctx, "h");
+        BOOST_REQUIRE_EQUAL(6U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(rows)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "n = s.rows;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "n");
+        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(space)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "w = s.space.width;"
+            "h = s.space.height;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        duk_get_global_string(m_ctx, "w");
+        BOOST_REQUIRE_EQUAL(2U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+        duk_get_global_string(m_ctx, "h");
+        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
+        duk_pop(m_ctx);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(basic)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "s = new Malikania.Sprite('sprites/margins.json');"
+            "c = 0;"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        for (unsigned c = 0; c < 12; ++c) {
+            auto ret = duk_peval_string(m_ctx,
+                "w.setDrawingColor('lightskyblue');"
+                "w.clear();"
+                "s.draw(w, c++, { x: 320 - 16, y: 240 - 16 });"
+                "w.present();"
+            );
+
+            if (ret != 0) {
+                throw dukx_get_exception(m_ctx, -1);
+            }
+
+            std::this_thread::sleep_for(1s);
+        }
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/js-sprite/resources/images/margins.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-sprite/resources/sprites/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,6 @@
+{
+  "image": "images/margins.png",
+  "cell": [ 32, 32 ],
+  "margin": [ 4, 6 ],
+  "space": [ 2, 3 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-window/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,23 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME js-window
+    LIBRARIES libmlk-client-js
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/js-window/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,87 @@
+/*
+ * main.cpp -- test Window (JavaScript binding)
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+
+#define BOOST_TEST_MODULE "Javascript Window"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/js_window.hpp>
+
+using namespace mlk;
+using namespace std::chrono_literals;
+
+class test_window {
+protected:
+    dukx_context m_ctx;
+
+public:
+    test_window()
+    {
+        duk_push_object(m_ctx);
+        duk_put_global_string(m_ctx, "Malikania");
+        mlk::dukx_load_window(m_ctx);
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_window_suite, test_window)
+
+BOOST_AUTO_TEST_CASE(basic)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "w.setDrawingColor('lightskyblue');"
+            "w.clear();"
+            "w.present();"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(rect)
+{
+    try {
+        auto ret = duk_peval_string(m_ctx,
+            "w = new Malikania.Window();"
+            "w.setDrawingColor('lightskyblue');"
+            "w.clear();"
+            "w.setDrawingColor('white');"
+            "w.drawRectangle({ x: 10, y: 10, width: 10, height: 10 });"
+            "w.present();"
+        );
+
+        if (ret != 0) {
+            throw dukx_get_exception(m_ctx, -1);
+        }
+
+        std::this_thread::sleep_for(3s);
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,36 @@
+#
+# CMakeLists.txt -- CMake build system for malikania
+#
+# Copyright (c) 2013-2016 Malikania Authors
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+malikania_create_test(
+    NAME sprite
+    LIBRARIES libmlk-client
+    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+    RESOURCES
+        resources/images/mokodemo.png
+        resources/images/margins.png
+        resources/sprites/no-property-cell.json
+        resources/sprites/no-property-image.json
+        resources/sprites/image-not-found.json
+        resources/sprites/not-object.json
+        resources/sprites/property-image-not-string.json
+        resources/sprites/property-cell-not-array.json
+        resources/sprites/property-cell-not-array2.json
+        resources/sprites/simple.json
+        resources/sprites/margins.json
+)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/main.cpp	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,191 @@
+/*
+ * main.cpp -- test Sprite
+ *
+ * Copyright (c) 2013-2016 Malikania Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <chrono>
+#include <thread>
+#include <exception>
+
+#define BOOST_TEST_MODULE "Sprite"
+#include <boost/test/unit_test.hpp>
+
+#include <malikania/client_resources_loader.hpp>
+#include <malikania/resources_locator.hpp>
+#include <malikania/sprite.hpp>
+#include <malikania/window.hpp>
+
+using namespace std::chrono_literals;
+
+namespace {
+
+mlk::window window(400, 400);
+
+} // !namespace
+
+class test_sprite {
+protected:
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
+
+public:
+    test_sprite()
+        : m_locator(SOURCE_DIRECTORY "/resources")
+        , m_loader(m_locator)
+    {
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(test_sprite_suite, test_sprite)
+
+/*
+ * Missing properties.
+ * ------------------------------------------------------------------
+ */
+
+BOOST_AUTO_TEST_SUITE(missing_properties)
+
+BOOST_AUTO_TEST_CASE(image)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/no-property-image.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_CASE(cell)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/no-property-cell.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+/*
+ * Invalid properties.
+ * ------------------------------------------------------------------
+ */
+
+BOOST_AUTO_TEST_SUITE(invalid_properties)
+
+BOOST_AUTO_TEST_CASE(image_not_string)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/property-image-not-string.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_CASE(cell_not_array)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/property-cell-not-array.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_CASE(cell_not_array2)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/property-cell-not-array2.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+/*
+ * Other errors.
+ * ------------------------------------------------------------------
+ */
+
+BOOST_AUTO_TEST_SUITE(miscellaneous_errors)
+
+BOOST_AUTO_TEST_CASE(image_not_found)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/image-not-found.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_CASE(not_object)
+{
+    BOOST_REQUIRE_THROW(
+        m_loader.load_sprite("sprites/not-object.json"),
+        std::exception
+    );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+/*
+ * Valid sprites.
+ * ------------------------------------------------------------------
+ */
+
+BOOST_AUTO_TEST_SUITE(valid)
+
+BOOST_AUTO_TEST_CASE(standard)
+{
+    try {
+        auto sprite = m_loader.load_sprite("sprites/simple.json");
+
+        BOOST_REQUIRE_EQUAL(300U, sprite.cell().width());
+        BOOST_REQUIRE_EQUAL(300U, sprite.cell().height());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(margins)
+{
+    try {
+        auto sprite = m_loader.load_sprite("sprites/margins.json");
+
+        BOOST_REQUIRE_EQUAL(3U, sprite.rows());
+        BOOST_REQUIRE_EQUAL(4U, sprite.columns());
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_CASE(draw)
+{
+    try {
+        auto sprite = m_loader.load_sprite("sprites/margins.json");
+
+        auto total = sprite.rows() * sprite.columns();
+        auto x = (400 / 2) - (sprite.cell().width() / 2);
+        auto y = (400 / 2) - (sprite.cell().height() / 2);
+
+        for (unsigned c = 0; c < total; ++c) {
+            window.clear();
+            sprite.draw(window, c, mlk::point(x, y));
+            window.present();
+
+            std::this_thread::sleep_for(1s);
+        }
+    } catch (const std::exception &ex) {
+        BOOST_FAIL(ex.what());
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+BOOST_AUTO_TEST_SUITE_END()
Binary file examples/sprite/resources/images/margins.png has changed
Binary file examples/sprite/resources/images/margins.xcf has changed
Binary file examples/sprite/resources/images/mokodemo.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/image-not-found.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,4 @@
+{
+  "image": "does-not-exist.png",
+  "cell": [ 0, 0 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/margins.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,6 @@
+{
+  "image": "images/margins.png",
+  "cell": [ 32, 32 ],
+  "margin": [ 4, 6 ],
+  "space": [ 2, 3 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/no-property-cell.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,3 @@
+{
+  "image": "images/mokodemo.png"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/no-property-image.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,3 @@
+{
+  "cell": [ 16, 16 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/not-object.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,2 @@
+[
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/property-cell-not-array.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,4 @@
+{
+  "image": "images/mokodemo.png",
+  "cell": "hello"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/property-cell-not-array2.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,4 @@
+{
+  "image": "images/mokodemo.png",
+  "cell": [ true, false ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/property-image-not-string.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,4 @@
+{
+  "image": 123,
+  "cell": [ 0, 0 ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/sprite/resources/sprites/simple.json	Thu Dec 22 15:17:43 2016 +0100
@@ -0,0 +1,4 @@
+{
+  "image": "images/mokodemo.png",
+  "cell": [ 300, 300 ]
+}
--- a/tests/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ b/tests/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -26,6 +26,6 @@
     COMMENT "Building tests"
 )
 
+add_subdirectory(libcommon)
 add_subdirectory(libclient)
-add_subdirectory(libcommon)
 add_subdirectory(libserver)
--- a/tests/libclient/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ b/tests/libclient/CMakeLists.txt	Thu Dec 22 15:17:43 2016 +0100
@@ -16,24 +16,15 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #
 
-add_subdirectory(animation)
 add_subdirectory(color)
-add_subdirectory(font)
-add_subdirectory(image)
 add_subdirectory(line)
 add_subdirectory(point)
 add_subdirectory(rectangle)
 add_subdirectory(size)
-add_subdirectory(sprite)
 
 # JavaScript bindings
-add_subdirectory(js-animation)
 add_subdirectory(js-color)
-add_subdirectory(js-font)
-add_subdirectory(js-image)
 add_subdirectory(js-line)
 add_subdirectory(js-point)
 add_subdirectory(js-rectangle)
 add_subdirectory(js-size)
-add_subdirectory(js-sprite)
-add_subdirectory(js-window)
--- a/tests/libclient/animation/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME animation
-    LIBRARIES libmlk-client
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/animations/margins.json
-        resources/images/margins.png
-        resources/sprites/margins.json
-)
--- a/tests/libclient/animation/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * main.cpp -- test animation
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-#include <exception>
-
-#define BOOST_TEST_MODULE "Animation"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/animation.hpp>
-#include <malikania/animator.hpp>
-#include <malikania/client_resources_loader.hpp>
-#include <malikania/resources_locator.hpp>
-#include <malikania/window.hpp>
-
-namespace {
-
-mlk::window win(400, 400);
-
-} // !namespace
-
-class test_animation {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-
-public:
-    test_animation()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_animation_suite, test_animation)
-
-BOOST_AUTO_TEST_CASE(standard)
-{
-    try {
-        auto animation = m_loader.load_animation("animations/margins.json");
-
-        BOOST_REQUIRE_EQUAL(12U, animation.frames().size());
-        BOOST_REQUIRE_EQUAL(500U, animation[0].delay());
-        BOOST_REQUIRE_EQUAL(501U, animation[1].delay());
-        BOOST_REQUIRE_EQUAL(502U, animation[2].delay());
-        BOOST_REQUIRE_EQUAL(503U, animation[3].delay());
-        BOOST_REQUIRE_EQUAL(504U, animation[4].delay());
-        BOOST_REQUIRE_EQUAL(505U, animation[5].delay());
-        BOOST_REQUIRE_EQUAL(506U, animation[6].delay());
-        BOOST_REQUIRE_EQUAL(507U, animation[7].delay());
-        BOOST_REQUIRE_EQUAL(508U, animation[8].delay());
-        BOOST_REQUIRE_EQUAL(509U, animation[9].delay());
-        BOOST_REQUIRE_EQUAL(510U, animation[10].delay());
-        BOOST_REQUIRE_EQUAL(511U, animation[11].delay());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(draw)
-{
-    boost::timer::cpu_timer timer;
-
-    try {
-        mlk::animation animation = m_loader.load_animation("animations/margins.json");
-        mlk::animator animator(animation);
-
-        auto x = (400 / 2) - (animation.sprite().cell().width() / 2);
-        auto y = (400 / 2) - (animation.sprite().cell().height() / 2);
-
-        while (timer.elapsed().wall / 1000000LL < 8000) {
-            win.clear();
-            animator.draw(win, mlk::point(x, y));
-            animator.update();
-            win.present();
-        }
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
--- a/tests/libclient/animation/resources/animations/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-{
-  "sprite": "sprites/margins.json",
-  "frames": [
-    { "delay": 500 },
-    { "delay": 501 },
-    { "delay": 502 },
-    { "delay": 503 },
-    { "delay": 504 },
-    { "delay": 505 },
-    { "delay": 506 },
-    { "delay": 507 },
-    { "delay": 508 },
-    { "delay": 509 },
-    { "delay": 510 },
-    { "delay": 511 }
-  ]
-}
Binary file tests/libclient/animation/resources/images/margins.png has changed
--- a/tests/libclient/animation/resources/sprites/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{
-  "image": "images/margins.png",
-  "cell": [ 32, 32 ],
-  "margin": [ 4, 6 ],
-  "space": [ 2, 3 ]
-}
--- a/tests/libclient/font/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME font
-    LIBRARIES libmlk-client
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/DejaVuSans.ttf
-)
--- a/tests/libclient/font/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * main.cpp -- test Font
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Font"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/client_resources_loader.hpp>
-#include <malikania/color.hpp>
-#include <malikania/font.hpp>
-#include <malikania/point.hpp>
-#include <malikania/resources_locator.hpp>
-#include <malikania/window.hpp>
-
-using namespace std::chrono_literals;
-
-namespace {
-
-mlk::window window(400, 400);
-
-} // !namespace
-
-class test_font {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-    mlk::font m_font;
-
-public:
-    test_font()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-        , m_font(m_loader.load_font("DejaVuSans.ttf", 10))
-    {
-        window.set_drawing_color(mlk::color("black"));
-        window.clear();
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_font_suite, test_font)
-
-BOOST_AUTO_TEST_CASE(topleft)
-{
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("top left", m_font, mlk::point(10, 10));
-    window.present();
-
-    std::this_thread::sleep_for(1s);
-}
-
-BOOST_AUTO_TEST_CASE(topright)
-{
-    auto dim = m_font.clip("top right");
-
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("top right", m_font, mlk::point(400 - dim.width() - 10, 10));
-    window.present();
-
-    std::this_thread::sleep_for(1s);
-}
-
-BOOST_AUTO_TEST_CASE(bottomleft)
-{
-    auto dim = m_font.clip("bottom left");
-
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("bottom left", m_font, mlk::point(10, 400 - dim.height() - 10));
-    window.present();
-
-    std::this_thread::sleep_for(1s);
-}
-
-BOOST_AUTO_TEST_CASE(bottomright)
-{
-    auto dim = m_font.clip("bottom right");
-
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("bottom right", m_font, mlk::point(400 - dim.width() - 10, 400 - dim.height() - 10));
-    window.present();
-
-    std::this_thread::sleep_for(1s);
-}
-
-BOOST_AUTO_TEST_CASE(center)
-{
-    auto dim = m_font.clip("center");
-
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("center", m_font, mlk::point(200 - (dim.width() / 2), 200 - (dim.height() -2)));
-    window.present();
-
-    std::this_thread::sleep_for(1s);
-}
-
-BOOST_AUTO_TEST_CASE(center2)
-{
-    auto dim = m_font.clip("The world is Malikania.");
-
-    window.set_drawing_color(mlk::color("white"));
-    window.draw_text("The world is Malikania.", m_font, mlk::point(200 - (dim.width() / 2), 200 - (dim.height() -2)));
-    window.present();
-
-    std::this_thread::sleep_for(3s);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/font/resources/DejaVuSans.ttf has changed
--- a/tests/libclient/image/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME image
-    LIBRARIES libmlk-client
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/images/100x10.png
-        resources/images/10x100.png
-        resources/images/16x16.png
-        resources/images/smiley.png
-)
--- a/tests/libclient/image/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * main.cpp -- test Image
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Image"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/client_resources_loader.hpp>
-#include <malikania/image.hpp>
-#include <malikania/resources_locator.hpp>
-#include <malikania/window.hpp>
-
-using namespace std::chrono_literals;
-
-namespace {
-
-mlk::window window(400, 400);
-
-} // !namespace
-
-class test_image {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-
-public:
-    test_image()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_image_suite, test_image)
-
-BOOST_AUTO_TEST_CASE(image100x10)
-{
-    try {
-        auto image = m_loader.load_image("images/100x10.png");
-
-        BOOST_REQUIRE_EQUAL(100U, image.size().width());
-        BOOST_REQUIRE_EQUAL(10U, image.size().height());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(image16x16)
-{
-    try {
-        auto image = m_loader.load_image("images/16x16.png");
-
-        BOOST_REQUIRE_EQUAL(16U, image.size().width());
-        BOOST_REQUIRE_EQUAL(16U, image.size().height());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(image10x100)
-{
-    try {
-        auto image = m_loader.load_image("images/10x100.png");
-
-        BOOST_REQUIRE_EQUAL(10U, image.size().width());
-        BOOST_REQUIRE_EQUAL(100U, image.size().height());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(notfound)
-{
-    BOOST_REQUIRE_THROW(m_loader.load_image("image-not-found"), std::exception);
-}
-
-BOOST_AUTO_TEST_CASE(draw)
-{
-    try {
-        auto image = m_loader.load_image("images/smiley.png");
-        auto x = (400 / 2) - (image.size().width() / 2);
-        auto y = (400 / 2) - (image.size().height() / 2);
-
-        window.clear();
-        image.draw(window, mlk::point(x, y));
-        window.present();
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/image/resources/images/100x10.png has changed
Binary file tests/libclient/image/resources/images/10x100.png has changed
Binary file tests/libclient/image/resources/images/16x16.png has changed
Binary file tests/libclient/image/resources/images/smiley.png has changed
Binary file tests/libclient/image/resources/images/smiley.xcf has changed
--- a/tests/libclient/js-animation/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME js-animation
-    LIBRARIES libmlk-client-js
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/animations/margins.json
-        resources/images/margins.png
-        resources/sprites/margins.json
-)
--- a/tests/libclient/js-animation/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * main.cpp -- test Animation (JavaScript binding)
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Javascript Animation"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/js_client_resources_loader.hpp>
-#include <malikania/js_animation.hpp>
-#include <malikania/js_animator.hpp>
-#include <malikania/js_window.hpp>
-#include <malikania/resources_locator.hpp>
-
-using namespace std::chrono_literals;
-
-class test_animation {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-    dukx_context m_ctx;
-
-public:
-    test_animation()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-        duk_push_object(m_ctx);
-        duk_put_global_string(m_ctx, "Malikania");
-        mlk::dukx_load_animation(m_ctx);
-        mlk::dukx_load_animator(m_ctx);
-        mlk::dukx_load_window(m_ctx);
-        dukx_put_client_loader(m_ctx, m_loader);
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_animation_suite, test_animation)
-
-BOOST_AUTO_TEST_CASE(basic)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "a = new Malikania.Animation('animations/margins.json');"
-            "d = new Malikania.Animator(a);"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        boost::timer::cpu_timer timer;
-
-        while (timer.elapsed().wall / 1000000LL < 8000) {
-            auto ret = duk_peval_string(m_ctx,
-                "w.setDrawingColor('lightskyblue');"
-                "w.clear();"
-                "d.draw(w, { x: 320 - 16, y: 240 - 16 });"
-                "d.update();"
-                "w.present();"
-            );
-
-            if (ret != 0) {
-                throw dukx_get_exception(m_ctx, -1);
-            }
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
--- a/tests/libclient/js-animation/resources/animations/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-{
-  "sprite": "sprites/margins.json",
-  "frames": [
-    { "delay": 500 },
-    { "delay": 501 },
-    { "delay": 502 },
-    { "delay": 503 },
-    { "delay": 504 },
-    { "delay": 505 },
-    { "delay": 506 },
-    { "delay": 507 },
-    { "delay": 508 },
-    { "delay": 509 },
-    { "delay": 510 },
-    { "delay": 511 }
-  ]
-}
Binary file tests/libclient/js-animation/resources/images/margins.png has changed
--- a/tests/libclient/js-animation/resources/sprites/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{
-  "image": "images/margins.png",
-  "cell": [ 32, 32 ],
-  "margin": [ 4, 6 ],
-  "space": [ 2, 3 ]
-}
--- a/tests/libclient/js-font/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME js-font
-    LIBRARIES libmlk-client-js
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/DejaVuSans.ttf
-)
--- a/tests/libclient/js-font/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * main.cpp -- test Font (JavaScript binding)
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Javascript Font"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/js_client_resources_loader.hpp>
-#include <malikania/js_font.hpp>
-#include <malikania/js_window.hpp>
-#include <malikania/resources_locator.hpp>
-
-using namespace std::chrono_literals;
-
-class test_font {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-    dukx_context m_ctx;
-
-public:
-    test_font()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-        duk_push_object(m_ctx);
-        duk_put_global_string(m_ctx, "Malikania");
-        dukx_put_client_loader(m_ctx, m_loader);
-        mlk::dukx_load_font(m_ctx);
-        mlk::dukx_load_window(m_ctx);
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_font_suite, test_font)
-
-BOOST_AUTO_TEST_CASE(basic)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "f = new Malikania.Font('DejaVuSans.ttf', 10);"
-            "w.setDrawingColor('lightskyblue');"
-            "w.clear();"
-            "s = 'The world is Malikania.';"
-            "c = f.clip(s);"
-            "w.setDrawingColor('white');"
-            "w.drawText(s, f, { x: 320 - (c.width / 2), y: 240 - (c.height / 2) });"
-            "w.present();"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/js-font/resources/DejaVuSans.ttf has changed
--- a/tests/libclient/js-image/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME js-image
-    LIBRARIES libmlk-client-js
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/images/smiley.png
-)
--- a/tests/libclient/js-image/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * main.cpp -- test Image (JavaScript binding)
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Javacript Image"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/js_client_resources_loader.hpp>
-#include <malikania/js_image.hpp>
-#include <malikania/js_window.hpp>
-#include <malikania/resources_locator.hpp>
-
-using namespace std::chrono_literals;
-
-class test_image {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-    dukx_context m_ctx;
-
-public:
-    test_image()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-        duk_push_object(m_ctx);
-        duk_put_global_string(m_ctx, "Malikania");
-        mlk::dukx_load_image(m_ctx);
-        mlk::dukx_load_window(m_ctx);
-        dukx_put_client_loader(m_ctx, m_loader);
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_image_suite, test_image)
-
-BOOST_AUTO_TEST_CASE(size)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "i = new Malikania.Image('images/smiley.png');"
-            "w = i.size.width;"
-            "h = i.size.height;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "w");
-        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-        duk_get_global_string(m_ctx, "h");
-        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(basic)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "i = new Malikania.Image('images/smiley.png');"
-            "w.setDrawingColor('lightskyblue');"
-            "w.clear();"
-            "i.draw(w, { x: 320 - 16, y: 240 - 16 });"
-            "w.present();"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(stretch)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "i = new Malikania.Image('images/smiley.png');"
-            "w.setDrawingColor('lightskyblue');"
-            "w.clear();"
-            "i.draw(w, null, { x: 10, y: 10, width: 620, height: 460 });"
-            "w.present();"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/js-image/resources/images/smiley.png has changed
--- a/tests/libclient/js-sprite/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME js-sprite
-    LIBRARIES libmlk-client-js
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/images/margins.png
-        resources/sprites/margins.json
-)
--- a/tests/libclient/js-sprite/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/*
- * main.cpp -- test Sprite (JavaScript binding)
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Javascript Sprite"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/js_client_resources_loader.hpp>
-#include <malikania/js_image.hpp>
-#include <malikania/js_sprite.hpp>
-#include <malikania/js_window.hpp>
-#include <malikania/resources_locator.hpp>
-
-using namespace mlk;
-
-using namespace std::chrono_literals;
-
-class test_sprite {
-protected:
-    directory_resources_locator m_locator;
-    client_resources_loader m_loader;
-    dukx_context m_ctx;
-
-public:
-    test_sprite()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-        duk_push_object(m_ctx);
-        duk_put_global_string(m_ctx, "Malikania");
-        mlk::dukx_load_image(m_ctx);
-        mlk::dukx_load_sprite(m_ctx);
-        mlk::dukx_load_window(m_ctx);
-        dukx_put_client_loader(m_ctx, m_loader);
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_sprite_suite, test_sprite)
-
-BOOST_AUTO_TEST_CASE(cell)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "w = s.cell.width;"
-            "h = s.cell.height;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "w");
-        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-        duk_get_global_string(m_ctx, "h");
-        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(columns)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "n = s.columns;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "n");
-        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(margins)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "w = s.margins.width;"
-            "h = s.margins.height;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "w");
-        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-        duk_get_global_string(m_ctx, "h");
-        BOOST_REQUIRE_EQUAL(6U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(rows)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "n = s.rows;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "n");
-        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(space)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "w = s.space.width;"
-            "h = s.space.height;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        duk_get_global_string(m_ctx, "w");
-        BOOST_REQUIRE_EQUAL(2U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-        duk_get_global_string(m_ctx, "h");
-        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
-        duk_pop(m_ctx);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(basic)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "s = new Malikania.Sprite('sprites/margins.json');"
-            "c = 0;"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        for (unsigned c = 0; c < 12; ++c) {
-            auto ret = duk_peval_string(m_ctx,
-                "w.setDrawingColor('lightskyblue');"
-                "w.clear();"
-                "s.draw(w, c++, { x: 320 - 16, y: 240 - 16 });"
-                "w.present();"
-            );
-
-            if (ret != 0) {
-                throw dukx_get_exception(m_ctx, -1);
-            }
-
-            std::this_thread::sleep_for(1s);
-        }
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/js-sprite/resources/images/margins.png has changed
--- a/tests/libclient/js-sprite/resources/sprites/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{
-  "image": "images/margins.png",
-  "cell": [ 32, 32 ],
-  "margin": [ 4, 6 ],
-  "space": [ 2, 3 ]
-}
--- a/tests/libclient/js-window/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME js-window
-    LIBRARIES libmlk-client-js
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-)
--- a/tests/libclient/js-window/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * main.cpp -- test Window (JavaScript binding)
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-
-#define BOOST_TEST_MODULE "Javascript Window"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/js_window.hpp>
-
-using namespace mlk;
-using namespace std::chrono_literals;
-
-class test_window {
-protected:
-    dukx_context m_ctx;
-
-public:
-    test_window()
-    {
-        duk_push_object(m_ctx);
-        duk_put_global_string(m_ctx, "Malikania");
-        mlk::dukx_load_window(m_ctx);
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_window_suite, test_window)
-
-BOOST_AUTO_TEST_CASE(basic)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "w.setDrawingColor('lightskyblue');"
-            "w.clear();"
-            "w.present();"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(rect)
-{
-    try {
-        auto ret = duk_peval_string(m_ctx,
-            "w = new Malikania.Window();"
-            "w.setDrawingColor('lightskyblue');"
-            "w.clear();"
-            "w.setDrawingColor('white');"
-            "w.drawRectangle({ x: 10, y: 10, width: 10, height: 10 });"
-            "w.present();"
-        );
-
-        if (ret != 0) {
-            throw dukx_get_exception(m_ctx, -1);
-        }
-
-        std::this_thread::sleep_for(3s);
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
--- a/tests/libclient/sprite/CMakeLists.txt	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#
-# CMakeLists.txt -- CMake build system for malikania
-#
-# Copyright (c) 2013-2016 Malikania Authors
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-malikania_create_test(
-    NAME sprite
-    LIBRARIES libmlk-client
-    SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
-    RESOURCES
-        resources/images/mokodemo.png
-        resources/images/margins.png
-        resources/sprites/no-property-cell.json
-        resources/sprites/no-property-image.json
-        resources/sprites/image-not-found.json
-        resources/sprites/not-object.json
-        resources/sprites/property-image-not-string.json
-        resources/sprites/property-cell-not-array.json
-        resources/sprites/property-cell-not-array2.json
-        resources/sprites/simple.json
-        resources/sprites/margins.json
-)
-
--- a/tests/libclient/sprite/main.cpp	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-/*
- * main.cpp -- test Sprite
- *
- * Copyright (c) 2013-2016 Malikania Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <chrono>
-#include <thread>
-#include <exception>
-
-#define BOOST_TEST_MODULE "Sprite"
-#include <boost/test/unit_test.hpp>
-
-#include <malikania/client_resources_loader.hpp>
-#include <malikania/resources_locator.hpp>
-#include <malikania/sprite.hpp>
-#include <malikania/window.hpp>
-
-using namespace std::chrono_literals;
-
-namespace {
-
-mlk::window window(400, 400);
-
-} // !namespace
-
-class test_sprite {
-protected:
-    mlk::directory_resources_locator m_locator;
-    mlk::client_resources_loader m_loader;
-
-public:
-    test_sprite()
-        : m_locator(SOURCE_DIRECTORY "/resources")
-        , m_loader(m_locator)
-    {
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_sprite_suite, test_sprite)
-
-/*
- * Missing properties.
- * ------------------------------------------------------------------
- */
-
-BOOST_AUTO_TEST_SUITE(missing_properties)
-
-BOOST_AUTO_TEST_CASE(image)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/no-property-image.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_CASE(cell)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/no-property-cell.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-/*
- * Invalid properties.
- * ------------------------------------------------------------------
- */
-
-BOOST_AUTO_TEST_SUITE(invalid_properties)
-
-BOOST_AUTO_TEST_CASE(image_not_string)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/property-image-not-string.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_CASE(cell_not_array)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/property-cell-not-array.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_CASE(cell_not_array2)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/property-cell-not-array2.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-/*
- * Other errors.
- * ------------------------------------------------------------------
- */
-
-BOOST_AUTO_TEST_SUITE(miscellaneous_errors)
-
-BOOST_AUTO_TEST_CASE(image_not_found)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/image-not-found.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_CASE(not_object)
-{
-    BOOST_REQUIRE_THROW(
-        m_loader.load_sprite("sprites/not-object.json"),
-        std::exception
-    );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-/*
- * Valid sprites.
- * ------------------------------------------------------------------
- */
-
-BOOST_AUTO_TEST_SUITE(valid)
-
-BOOST_AUTO_TEST_CASE(standard)
-{
-    try {
-        auto sprite = m_loader.load_sprite("sprites/simple.json");
-
-        BOOST_REQUIRE_EQUAL(300U, sprite.cell().width());
-        BOOST_REQUIRE_EQUAL(300U, sprite.cell().height());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(margins)
-{
-    try {
-        auto sprite = m_loader.load_sprite("sprites/margins.json");
-
-        BOOST_REQUIRE_EQUAL(3U, sprite.rows());
-        BOOST_REQUIRE_EQUAL(4U, sprite.columns());
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_CASE(draw)
-{
-    try {
-        auto sprite = m_loader.load_sprite("sprites/margins.json");
-
-        auto total = sprite.rows() * sprite.columns();
-        auto x = (400 / 2) - (sprite.cell().width() / 2);
-        auto y = (400 / 2) - (sprite.cell().height() / 2);
-
-        for (unsigned c = 0; c < total; ++c) {
-            window.clear();
-            sprite.draw(window, c, mlk::point(x, y));
-            window.present();
-
-            std::this_thread::sleep_for(1s);
-        }
-    } catch (const std::exception &ex) {
-        BOOST_FAIL(ex.what());
-    }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE_END()
Binary file tests/libclient/sprite/resources/images/margins.png has changed
Binary file tests/libclient/sprite/resources/images/margins.xcf has changed
Binary file tests/libclient/sprite/resources/images/mokodemo.png has changed
--- a/tests/libclient/sprite/resources/sprites/image-not-found.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-  "image": "does-not-exist.png",
-  "cell": [ 0, 0 ]
-}
--- a/tests/libclient/sprite/resources/sprites/margins.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{
-  "image": "images/margins.png",
-  "cell": [ 32, 32 ],
-  "margin": [ 4, 6 ],
-  "space": [ 2, 3 ]
-}
--- a/tests/libclient/sprite/resources/sprites/no-property-cell.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-{
-  "image": "images/mokodemo.png"
-}
--- a/tests/libclient/sprite/resources/sprites/no-property-image.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-{
-  "cell": [ 16, 16 ]
-}
--- a/tests/libclient/sprite/resources/sprites/not-object.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-[
-]
--- a/tests/libclient/sprite/resources/sprites/property-cell-not-array.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-  "image": "images/mokodemo.png",
-  "cell": "hello"
-}
--- a/tests/libclient/sprite/resources/sprites/property-cell-not-array2.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-  "image": "images/mokodemo.png",
-  "cell": [ true, false ]
-}
--- a/tests/libclient/sprite/resources/sprites/property-image-not-string.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-  "image": 123,
-  "cell": [ 0, 0 ]
-}
--- a/tests/libclient/sprite/resources/sprites/simple.json	Thu Dec 22 09:27:09 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-  "image": "images/mokodemo.png",
-  "cell": [ 300, 300 ]
-}