summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-18 18:08:03 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-18 21:42:18 +0300
commit01a29fe1c2d464a79b0bf5c8d3d2760e3cc83817 (patch)
treed30ca3f3c10676cd4502b4430660c5d386898737 /src
parent1d9a6b861ceb672ca62ba0bb5c14df65b7fa7c0b (diff)
downloadManaVerse-01a29fe1c2d464a79b0bf5c8d3d2760e3cc83817.tar.gz
ManaVerse-01a29fe1c2d464a79b0bf5c8d3d2760e3cc83817.tar.bz2
ManaVerse-01a29fe1c2d464a79b0bf5c8d3d2760e3cc83817.tar.xz
ManaVerse-01a29fe1c2d464a79b0bf5c8d3d2760e3cc83817.zip
testDye
Diffstat (limited to 'src')
-rw-r--r--src/resources/image.h1
-rw-r--r--src/test/testlauncher.cpp63
-rw-r--r--src/test/testlauncher.h2
3 files changed, 66 insertions, 0 deletions
diff --git a/src/resources/image.h b/src/resources/image.h
index 556109564..a0df54926 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -57,6 +57,7 @@ class Image : public Resource
friend class OpenGLImageHelper;
friend class SDLGraphics;
friend class SDLImageHelper;
+ friend class TestLauncher;
#ifdef USE_OPENGL
friend class AtlasManager;
friend class MobileOpenGLGraphics;
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 626ac7490..34a126a4e 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -32,12 +32,18 @@
#include "utils/gettext.h"
#include "utils/mkdir.h"
+#include "utils/physfsrwops.h"
+#include "resources/dye.h"
#include "resources/image.h"
+#include "resources/imagehelper.h"
+#include "resources/imagewriter.h"
#include "resources/wallpaper.h"
#include <unistd.h>
+#include <SDL_gfxBlitFunc.h>
+
#ifdef WIN32
#include <windows.h>
#define sleep(seconds) Sleep((seconds) * 1000)
@@ -74,6 +80,8 @@ int TestLauncher::exec()
return testVideoDetection();
else if (mTest == "100")
return testInternal();
+ else if (mTest == "101")
+ return testDye();
return -1;
}
@@ -226,6 +234,61 @@ int TestLauncher::testInternal()
return 0;
}
+int TestLauncher::testDye()
+{
+ SDL_RWops *rw = PHYSFSRWOPS_openRead(
+ "graphics/sprites/arrow_up.png");
+ Dye *d = nullptr;
+
+ logger->log("test1");
+ if (rw)
+ {
+ logger->log("test2");
+ Image *image = d ? sdlImageHelper->load(rw, *d)
+ : sdlImageHelper->load(rw);
+ if (image)
+ {
+ logger->log("test3");
+ const SDL_Rect &rect = image->mBounds;
+ SDL_Surface *surface = sdlImageHelper->create32BitSurface(
+ rect.w, rect.h);
+ if (surface)
+ {
+ logger->log("test4");
+ SDL_gfxBlitRGBA(image->mSDLSurface, nullptr, surface, nullptr);
+ ImageWriter::writePNG(image->mSDLSurface,
+ Client::getTempDirectory() + "/testimage1.png");
+ ImageWriter::writePNG(surface,
+ Client::getTempDirectory() + "/testimage2.png");
+ }
+
+ logger->log("test5");
+ rw = PHYSFSRWOPS_openRead(
+ "graphics/sprites/arrow_up.png");
+ d = new Dye("S:#0000ff,00ff00,5c5cff,ff0000");
+ image = d ? sdlImageHelper->load(rw, *d)
+ : sdlImageHelper->load(rw);
+ if (image)
+ {
+ logger->log("test6");
+ surface = sdlImageHelper->create32BitSurface(
+ rect.w, rect.h);
+ if (surface)
+ {
+ logger->log("test7");
+ SDL_gfxBlitRGBA(image->mSDLSurface, nullptr,
+ surface, nullptr);
+ ImageWriter::writePNG(image->mSDLSurface,
+ Client::getTempDirectory() + "/testimage3.png");
+ ImageWriter::writePNG(surface,
+ Client::getTempDirectory() + "/testimage4.png");
+ }
+ }
+ }
+ }
+ return 0;
+}
+
int TestLauncher::testVideoDetection()
{
file << mTest << std::endl;
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
index 389c898dd..145f11c35 100644
--- a/src/test/testlauncher.h
+++ b/src/test/testlauncher.h
@@ -55,6 +55,8 @@ class TestLauncher
int testInternal();
+ int testDye();
+
int testVideoDetection();
int testBatches();