The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_sdl_utils.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 //#define GETTEXT_DOMAIN "wesnoth-test"
16 //
17 //#include "tests/test_sdl_utils.hpp"
18 //
19 //#include "image.hpp"
20 //
21 //#include "utils/functional.hpp"
22 //#include <boost/test/auto_unit_test.hpp>
23 //
24 //#include <iomanip>
25 
26 //static const std::string root = "data/test/test/image";
27 
28 //static void
29 //compare_image(
30 // const surface& src
31 // , const surface& dst
32 // , const std::string message)
33 //{
34 // BOOST_REQUIRE_MESSAGE(
35 // src->w == dst->w
36 // , message
37 // << "source width »"
38 // << src->w
39 // << "« destination width »"
40 // << dst->w
41 // << "«.\n"
42 // );
43 //
44 // BOOST_REQUIRE_MESSAGE(
45 // src->h == dst->h
46 // , message
47 // << "source height »"
48 // << src->w
49 // << "« destination heigth »"
50 // << dst->w
51 // << "«.\n"
52 // );
53 //
54 // const_surface_lock src_lock(src);
55 // const_surface_lock dst_lock(dst);
56 //
57 // const Uint32* src_pixels = src_lock.pixels();
58 // const Uint32* dst_pixels = dst_lock.pixels();
59 //
60 // const unsigned pixels = src->w * src->h;
61 //
62 // unsigned matches = 0;
63 //
64 // for(unsigned i = 0; i < pixels; ++i, ++src_pixels, ++dst_pixels) {
65 // matches += (*src_pixels == *dst_pixels);
66 // }
67 //
68 // BOOST_CHECK_MESSAGE(
69 // pixels == matches
70 // , message
71 // << "of the " << pixels
72 // << " pixels in the image " << matches
73 // << " match.\n"
74 // );
75 //}
76 
77 //static void
78 //test_blend(const surface& dst, const Uint8 amount, const Uint32 color)
79 //{
80 // std::stringstream sstr;
81 // sstr << std::hex << std::setfill('0')
82 // << "Blend image amount »"
83 // << std::setw(2) << static_cast<Uint32>(amount)
84 // << "« color »"
85 // << std::setw(8) << color
86 // << "« : ";
87 //
88 // const std::string filename =
89 // blend_get_filename("data/test/test/image/blend/", amount, color);
90 //
91 // BOOST_REQUIRE_EQUAL(image::exists(filename), true);
92 //
93 // const surface& src = image::get_image(filename);
94 // compare_image(src, dst, sstr.str());
95 //}
96 
97 //BOOST_AUTO_TEST_CASE(test_blend_surface)
98 //{
99 //
100 // BOOST_REQUIRE_EQUAL(image::exists(root + "/base.png"), true);
101 //
102 // const surface base = image::get_image(root + "/base.png");
103 //
104 // blend_image(base, std::bind(&test_blend, _1, _2, _3));
105 //}
106