Mercurial > malikania
diff tests/libclient/js-animation/main.cpp @ 36:9af360f34c7d
Misc: use raw duktape API
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Aug 2016 14:30:51 +0200 |
parents | d4f5f7231b84 |
children | 3645200f46bf |
line wrap: on
line diff
--- a/tests/libclient/js-animation/main.cpp Fri Jul 01 13:32:08 2016 +0200 +++ b/tests/libclient/js-animation/main.cpp Wed Aug 10 14:30:51 2016 +0200 @@ -21,8 +21,8 @@ #include <gtest/gtest.h> -#include <malikania/client-resources-loader.hpp> #include <malikania/elapsed-timer.hpp> +#include <malikania/js-client-resources-loader.hpp> #include <malikania/js-animation.hpp> #include <malikania/js-animator.hpp> #include <malikania/js-window.hpp> @@ -36,42 +36,38 @@ protected: ResourcesLocatorDirectory m_locator; ClientResourcesLoader m_loader; - - duk::Context m_ctx; + UniqueContext m_ctx; public: TestAnimation() : m_locator(SOURCE_DIRECTORY "/resources") , m_loader(m_locator) { - duk::putGlobal(m_ctx, "Malikania", duk::Object()); - - loadMalikaniaAnimation(m_ctx); - loadMalikaniaAnimator(m_ctx); - loadMalikaniaWindow(m_ctx); - - /* Store the loader */ - duk::putGlobal(m_ctx, "\xff""\xff""loader", &m_loader); + duk_push_object(m_ctx); + duk_put_global_string(m_ctx, "Malikania"); + dukx_load_animation(m_ctx); + dukx_load_animator(m_ctx); + dukx_load_window(m_ctx); + dukx_put_client_loader(m_ctx, &m_loader); } }; TEST_F(TestAnimation, basic) { try { - auto ret = duk::pevalString(m_ctx, + 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 duk::exception(m_ctx, -1); - } + if (ret != 0) + throw dukx_exception(m_ctx, -1); ElapsedTimer timer; while (timer.elapsed() < 8000) { - auto ret = duk::pevalString(m_ctx, + auto ret = duk_peval_string(m_ctx, "w.setDrawingColor('lightskyblue');" "w.clear();" "d.draw(w, { x: 320 - 16, y: 240 - 16 });" @@ -79,9 +75,8 @@ "w.present();" ); - if (ret != 0) { - throw duk::exception(m_ctx, -1); - } + if (ret != 0) + throw dukx_exception(m_ctx, -1); } std::this_thread::sleep_for(3s);