comparison tests/libclient/js-font/main.cpp @ 42:a47a4477f347

Misc: new style, closes #578
author David Demelier <markand@malikania.fr>
date Tue, 29 Nov 2016 21:21:36 +0100
parents 9af360f34c7d
children fabbe1759cec
comparison
equal deleted inserted replaced
41:3645200f46bf 42:a47a4477f347
19 #include <chrono> 19 #include <chrono>
20 #include <thread> 20 #include <thread>
21 21
22 #include <gtest/gtest.h> 22 #include <gtest/gtest.h>
23 23
24 #include <malikania/js-client-resources-loader.hpp> 24 #include <malikania/js_client_resources_loader.hpp>
25 #include <malikania/js-font.hpp> 25 #include <malikania/js_font.hpp>
26 #include <malikania/js-window.hpp> 26 #include <malikania/js_window.hpp>
27 #include <malikania/resources-locator.hpp> 27 #include <malikania/resources_locator.hpp>
28 28
29 using namespace malikania; 29 namespace mlk = malikania;
30 30
31 using namespace std::chrono_literals; 31 using namespace std::chrono_literals;
32 32
33 class TestFont : public testing::Test { 33 class TestFont : public testing::Test {
34 protected: 34 protected:
35 ResourcesLocatorDirectory m_locator; 35 mlk::directory_resources_locator m_locator;
36 ClientResourcesLoader m_loader; 36 mlk::client_resources_loader m_loader;
37 UniqueContext m_ctx; 37 UniqueContext m_ctx;
38 38
39 public: 39 public:
40 TestFont() 40 TestFont()
41 : m_locator(SOURCE_DIRECTORY "/resources") 41 : m_locator(SOURCE_DIRECTORY "/resources")
42 , m_loader(m_locator) 42 , m_loader(m_locator)
43 { 43 {
44 duk_push_object(m_ctx); 44 duk_push_object(m_ctx);
45 duk_put_global_string(m_ctx, "Malikania"); 45 duk_put_global_string(m_ctx, "Malikania");
46 dukx_put_client_loader(m_ctx, &m_loader); 46 dukx_put_client_loader(m_ctx, m_loader);
47 dukx_load_font(m_ctx); 47 mlk::dukx_load_font(m_ctx);
48 dukx_load_window(m_ctx); 48 mlk::dukx_load_window(m_ctx);
49 } 49 }
50 }; 50 };
51 51
52 TEST_F(TestFont, basic) 52 TEST_F(TestFont, basic)
53 { 53 {
62 "w.setDrawingColor('white');" 62 "w.setDrawingColor('white');"
63 "w.drawText(s, f, { x: 320 - (c.width / 2), y: 240 - (c.height / 2) });" 63 "w.drawText(s, f, { x: 320 - (c.width / 2), y: 240 - (c.height / 2) });"
64 "w.present();" 64 "w.present();"
65 ); 65 );
66 66
67 if (ret != 0) 67 if (ret != 0) {
68 throw dukx_exception(m_ctx, -1); 68 throw dukx_exception(m_ctx, -1);
69 }
69 70
70 std::this_thread::sleep_for(3s); 71 std::this_thread::sleep_for(3s);
71 } catch (const std::exception &ex) { 72 } catch (const std::exception &ex) {
72 FAIL() << ex.what(); 73 FAIL() << ex.what();
73 } 74 }