From 462aa62950543c91949736e2bc9665669c03cfbd Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 30 Dec 2014 16:06:51 +0300 Subject: [PATCH] [drape] test fixes --- drape/drape_tests/drape_tests.pro | 1 + drape/drape_tests/dummy_texture.hpp | 13 ++++++++++ drape/drape_tests/font_texture_tests.cpp | 7 +----- drape/drape_tests/stipple_pen_tests.cpp | 16 ++++-------- drape/drape_tests/texture_of_colors_tests.cpp | 25 +++++++------------ drape/drape_tests/uniform_value_tests.cpp | 2 +- 6 files changed, 30 insertions(+), 34 deletions(-) create mode 100644 drape/drape_tests/dummy_texture.hpp diff --git a/drape/drape_tests/drape_tests.pro b/drape/drape_tests/drape_tests.pro index 82d9b17d1e..6e685a3eef 100644 --- a/drape/drape_tests/drape_tests.pro +++ b/drape/drape_tests/drape_tests.pro @@ -48,3 +48,4 @@ HEADERS += \ glmock_functions.hpp \ memory_comparer.hpp \ img.hpp \ + dummy_texture.hpp diff --git a/drape/drape_tests/dummy_texture.hpp b/drape/drape_tests/dummy_texture.hpp new file mode 100644 index 0000000000..ebbdcbc0fb --- /dev/null +++ b/drape/drape_tests/dummy_texture.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "../pointers.hpp" +#include "../texture.hpp" + +class DummyTexture : public dp::Texture +{ +public: + virtual dp::RefPointer FindResource(Key const & /*key*/) const + { + return dp::RefPointer(); + } +}; diff --git a/drape/drape_tests/font_texture_tests.cpp b/drape/drape_tests/font_texture_tests.cpp index 4454b06447..07b6d44f13 100644 --- a/drape/drape_tests/font_texture_tests.cpp +++ b/drape/drape_tests/font_texture_tests.cpp @@ -1,5 +1,6 @@ #include "../../testing/testing.hpp" #include "img.hpp" +#include "dummy_texture.hpp" #include "../font_texture.hpp" #include "../glyph_manager.hpp" @@ -25,12 +26,6 @@ using namespace dp; namespace { - class DummyTexture : public dp::Texture - { - public: - virtual ResourceInfo const * FindResource(Key const & key) const { return nullptr; } - }; - class UploadedRender { public: diff --git a/drape/drape_tests/stipple_pen_tests.cpp b/drape/drape_tests/stipple_pen_tests.cpp index 0597925b0f..642d78ece2 100644 --- a/drape/drape_tests/stipple_pen_tests.cpp +++ b/drape/drape_tests/stipple_pen_tests.cpp @@ -1,11 +1,13 @@ #include "../../testing/testing.hpp" #include "memory_comparer.hpp" +#include "dummy_texture.hpp" #include "../glconstants.hpp" #include "../stipple_pen_resource.hpp" #include "../texture.hpp" + #include "glmock_functions.hpp" #include @@ -20,14 +22,6 @@ using namespace dp; namespace { - class DummyTexture : public Texture - { - public: - DummyTexture() {} - - virtual ResourceInfo const * FindResource(Key const & key) const { return NULL; } - }; - void TestPacker(StipplePenPacker & packer, uint32_t width, m2::RectU const & expect) { m2::RectU rect = packer.PackResource(width); @@ -410,11 +404,11 @@ UNIT_TEST(StippleMappingTest) info.m_pattern.push_back(10); info.m_pattern.push_back(10); - StipplePenResourceInfo const * r1 = index.MapResource(info); + RefPointer r1 = index.MapResource(info); TEST(IsRectsEqual(r1->GetTexRect(), m2::RectF(1.0f / width, 1.0f / height, 241.0f / width, 1.0f / height)), ()); - StipplePenResourceInfo const * r2 = index.MapResource(info); + RefPointer r2 = index.MapResource(info); TEST(IsRectsEqual(r1->GetTexRect(), r2->GetTexRect()), ()); info.m_pattern.clear(); @@ -451,7 +445,7 @@ UNIT_TEST(StippleMappingTest) StipplePenKey secInfo; secInfo.m_pattern.push_back(20); secInfo.m_pattern.push_back(20); - StipplePenResourceInfo const * r12 = index.MapResource(secInfo); + RefPointer r12 = index.MapResource(secInfo); TEST(IsRectsEqual(r12->GetTexRect(), m2::RectF(1.0f / width, 7.0f / height, 241.0f / width, 7.0f / height)), ()); diff --git a/drape/drape_tests/texture_of_colors_tests.cpp b/drape/drape_tests/texture_of_colors_tests.cpp index 0a9de054de..612e9bdce2 100644 --- a/drape/drape_tests/texture_of_colors_tests.cpp +++ b/drape/drape_tests/texture_of_colors_tests.cpp @@ -1,10 +1,10 @@ #include "../../testing/testing.hpp" #include "memory_comparer.hpp" +#include "dummy_texture.hpp" #include "../glconstants.hpp" #include "../texture_of_colors.hpp" -#include "../texture_set_holder.hpp" #include "../texture.hpp" #include "glmock_functions.hpp" @@ -21,13 +21,6 @@ using namespace dp; namespace { -class SimpleTexture : public Texture -{ -public: - SimpleTexture() {} - - virtual ResourceInfo const * FindResource(Key const & key) const { return NULL; } -}; void TestRects(m2::RectF const & a, m2::RectF const & b) { @@ -55,12 +48,12 @@ UNIT_TEST(ColorPalleteMappingTests) { ColorPalette cp(m2::PointU(32, 16)); - ColorResourceInfo const * info1 = cp.MapResource(dp::Color(0, 0, 0, 0)); - ColorResourceInfo const * info2 = cp.MapResource(dp::Color(1, 1, 1, 1)); - ColorResourceInfo const * info3 = cp.MapResource(dp::Color(0, 0, 0, 0)); + RefPointer info1 = cp.MapResource(dp::Color(0, 0, 0, 0)); + RefPointer info2 = cp.MapResource(dp::Color(1, 1, 1, 1)); + RefPointer info3 = cp.MapResource(dp::Color(0, 0, 0, 0)); - TEST_NOT_EQUAL(info1, info2, ()); - TEST_EQUAL(info1, info3, ()); + TEST_NOT_EQUAL(info1.GetRaw(), info2.GetRaw(), ()); + TEST_EQUAL(info1.GetRaw(), info3.GetRaw(), ()); TestRects(info1->GetTexRect(), m2::RectF(1.0f / 32.0f, 1.0f / 16, 1.0f / 32.0f, 1.0f / 16)); TestRects(info2->GetTexRect(), m2::RectF(3.0f / 32.0f, 1.0f / 16, @@ -81,7 +74,7 @@ UNIT_TEST(ColorPalleteUploadingSingleRow) int const height = 16; InitOpenGLTextures(width, height); - SimpleTexture texture; + DummyTexture texture; texture.Create(width, height, dp::RGBA8); ColorPalette cp(m2::PointU(width, height)); cp.UploadResources(MakeStackRefPointer(&texture)); @@ -147,7 +140,7 @@ UNIT_TEST(ColorPalleteUploadingPartialyRow) int const height = 16; InitOpenGLTextures(width, height); - SimpleTexture texture; + DummyTexture texture; dp::ColorKey key(dp::Color(0, 0, 0, 0)); texture.Create(width, height, dp::RGBA8); ColorPalette cp(m2::PointU(width, height)); @@ -222,7 +215,7 @@ UNIT_TEST(ColorPalleteUploadingMultipyRow) int const height = 16; InitOpenGLTextures(width, height); - SimpleTexture texture; + DummyTexture texture; dp::ColorKey key(dp::Color(0, 0, 0, 0)); texture.Create(width, height, dp::RGBA8); ColorPalette cp(m2::PointU(width, height)); diff --git a/drape/drape_tests/uniform_value_tests.cpp b/drape/drape_tests/uniform_value_tests.cpp index 3f91e5e034..3917975669 100644 --- a/drape/drape_tests/uniform_value_tests.cpp +++ b/drape/drape_tests/uniform_value_tests.cpp @@ -166,7 +166,7 @@ UNIT_TEST(UniformValueTest) } GpuProgramManager * manager = new GpuProgramManager(); - RefPointer program = manager->GetProgram(gpu::SOLID_AREA_PROGRAM); + RefPointer program = manager->GetProgram(gpu::TEXTURING_PROGRAM); program->Bind();