diff tests/libclient/sprite/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 d4f5f7231b84
children fabbe1759cec
line wrap: on
line diff
--- a/tests/libclient/sprite/main.cpp	Sun Nov 27 20:50:38 2016 +0100
+++ b/tests/libclient/sprite/main.cpp	Tue Nov 29 21:21:36 2016 +0100
@@ -22,25 +22,25 @@
 
 #include <gtest/gtest.h>
 
-#include <malikania/client-resources-loader.hpp>
-#include <malikania/resources-locator.hpp>
+#include <malikania/client_resources_loader.hpp>
+#include <malikania/resources_locator.hpp>
 #include <malikania/sprite.hpp>
 #include <malikania/window.hpp>
 
-using namespace malikania;
+namespace mlk = malikania;
 
 using namespace std::chrono_literals;
 
 namespace {
 
-Window window(400, 400);
+mlk::window window(400, 400);
 
 } // !namespace
 
 class TestSprite : public testing::Test {
 protected:
-    ResourcesLocatorDirectory m_locator;
-    ClientResourcesLoader m_loader;
+    mlk::directory_resources_locator m_locator;
+    mlk::client_resources_loader m_loader;
 
 public:
     TestSprite()
@@ -58,7 +58,7 @@
 TEST_F(TestSprite, missingPropertyImage)
 {
     try {
-        m_loader.loadSprite("sprites/no-property-image.json");
+        m_loader.load_sprite("sprites/no-property-image.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -68,7 +68,7 @@
 TEST_F(TestSprite, missingPropertyCell)
 {
     try {
-        m_loader.loadSprite("sprites/no-property-cell.json");
+        m_loader.load_sprite("sprites/no-property-cell.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -83,7 +83,7 @@
 TEST_F(TestSprite, imageNotString)
 {
     try {
-        m_loader.loadSprite("sprites/property-image-not-string.json");
+        m_loader.load_sprite("sprites/property-image-not-string.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -93,7 +93,7 @@
 TEST_F(TestSprite, cellNotArray)
 {
     try {
-        m_loader.loadSprite("sprites/property-cell-not-array.json");
+        m_loader.load_sprite("sprites/property-cell-not-array.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -103,7 +103,7 @@
 TEST_F(TestSprite, cellNotArray2)
 {
     try {
-        m_loader.loadSprite("sprites/property-cell-not-array2.json");
+        m_loader.load_sprite("sprites/property-cell-not-array2.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -118,7 +118,7 @@
 TEST_F(TestSprite, imageNotFound)
 {
     try {
-        m_loader.loadSprite("sprites/image-not-found.json");
+        m_loader.load_sprite("sprites/image-not-found.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -128,7 +128,7 @@
 TEST_F(TestSprite, notObject)
 {
     try {
-        m_loader.loadSprite("sprites/not-object.json");
+        m_loader.load_sprite("sprites/not-object.json");
 
         FAIL() << "exception expected";
     } catch (const std::exception &) {
@@ -143,7 +143,7 @@
 TEST_F(TestSprite, standard)
 {
     try {
-        Sprite sprite = m_loader.loadSprite("sprites/simple.json");
+        auto sprite = m_loader.load_sprite("sprites/simple.json");
 
         ASSERT_EQ(300U, sprite.cell().width());
         ASSERT_EQ(300U, sprite.cell().height());
@@ -155,7 +155,7 @@
 TEST_F(TestSprite, margins)
 {
     try {
-        Sprite sprite = m_loader.loadSprite("sprites/margins.json");
+        auto sprite = m_loader.load_sprite("sprites/margins.json");
 
         ASSERT_EQ(3U, sprite.rows());
         ASSERT_EQ(4U, sprite.columns());
@@ -167,16 +167,15 @@
 TEST_F(TestSprite, draw)
 {
     try {
-        Sprite sprite = m_loader.loadSprite("sprites/margins.json");
+        auto sprite = m_loader.load_sprite("sprites/margins.json");
 
-        unsigned total = sprite.rows() * sprite.columns();
-
+        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, Point(x, y));
+            sprite.draw(window, c, mlk::point(x, y));
             window.present();
 
             std::this_thread::sleep_for(1s);