Scroom  0.14
test-helpers.hh
Go to the documentation of this file.
1 /*
2  * Scroom - Generic viewer for 2D data
3  * Copyright (C) 2009-2022 Kees-Jan Dijkzeul
4  *
5  * SPDX-License-Identifier: LGPL-2.1
6  */
7 
8 #pragma once
9 
10 #include <boost/shared_ptr.hpp>
11 
12 #include <gtk/gtk.h>
13 
14 #include <scroom/colormappable.hh>
16 
18 
19 extern int drawingAreaWidth;
20 extern int drawingAreaHeight;
21 
23 
25 {
26 public:
27  using Ptr = boost::shared_ptr<DummyColormapProvider>;
28 
29 private:
31 
32 private:
34 
35 public:
37 
38 public:
39  Colormap::Ptr getColormap() override;
40 };
41 
42 class TestData
43 {
44 public:
45  using Ptr = boost::shared_ptr<TestData>;
46 
47 private:
54  int zoom;
55 
56 private:
58  LayerSpec ls,
61  int zoom);
62 
63 public:
65  const LayerSpec& ls,
68  int zoom);
69 
70  ~TestData();
71  TestData(const TestData&) = delete;
72  TestData(TestData&&) = delete;
73  TestData operator=(const TestData&) = delete;
74  TestData operator=(TestData&&) = delete;
75 
76 
77  void redraw(cairo_t* cr);
78  bool wait();
79 };
80 
81 extern TestData::Ptr testData;
82 
84 
85 class Sleeper
86 {
87 private:
88  unsigned int secs;
89  bool started{false};
90  struct timespec t = {0, 0};
91 
92 public:
93  explicit Sleeper(unsigned int secs);
94 
95  bool operator()();
96 };
97 
99 
100 bool quit();
101 bool reset();
102 bool wait();
103 
104 bool setupTest1bpp(int zoom, int width, int height);
105 bool setupTest2bpp(int zoom, int width, int height);
106 bool setupTest4bpp(int zoom, int width, int height);
107 bool setupTest8bpp(int zoom, int width, int height);
108 bool setupTest8bppColormapped(int zoom, int width, int height);
TestData::tbi
TiledBitmapInterface::Ptr tbi
Definition: test-helpers.hh:52
setupTest8bpp
bool setupTest8bpp(int zoom, int width, int height)
Definition: test-helpers.cc:200
Colormap::createDefault
static Colormap::Ptr createDefault(int n)
Definition: colormappable.hh:51
createTiledBitmap
TiledBitmapInterface::Ptr createTiledBitmap(int bitmapWidth, int bitmapHeight, LayerSpec const &ls)
Definition: tiled-bitmap.cc:28
setupTest4bpp
bool setupTest4bpp(int zoom, int width, int height)
Definition: test-helpers.cc:182
setupTest8bpp
bool setupTest8bpp(int zoom, int width, int height)
Definition: test-helpers.cc:200
measure-load-performance-tests.hh
DummyColormapProvider::colormap
Colormap::Ptr colormap
Definition: test-helpers.hh:30
TestData::wait
bool wait()
Definition: test-helpers.cc:68
main
int main(int argc, char *argv[])
Definition: measure-load-performance.cc:33
TestData::operator=
TestData operator=(const TestData &)=delete
Sleeper
Definition: test-helpers.hh:85
Operations8bpp::create
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition: layeroperations.cc:378
TestData::create
static Ptr create(DummyColormapProvider::Ptr colormapProvider, const LayerSpec &ls, const TiledBitmapInterface::Ptr &tbi, SourcePresentation::Ptr sp, int zoom)
Definition: test-helpers.cc:59
TestData
Definition: test-helpers.hh:42
DummyColormapProvider::DummyColormapProvider
DummyColormapProvider(Colormap::Ptr colormap)
Definition: test-helpers.cc:29
TestData::vi
ViewInterface::Ptr vi
Definition: test-helpers.hh:49
DummyColormapProvider::getColormap
Colormap::Ptr getColormap() override
Definition: test-helpers.cc:39
drawingAreaHeight
int drawingAreaHeight
Definition: test-helpers.cc:23
testData
TestData::Ptr testData
Definition: sampleiterator-tests.cc:20
Operations1bpp::create
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition: layeroperations.cc:262
wait
bool wait()
Definition: test-helpers.cc:134
Sleeper::secs
unsigned int secs
Definition: test-helpers.hh:88
DummyColormapProvider::Ptr
boost::shared_ptr< DummyColormapProvider > Ptr
Definition: test-helpers.hh:27
ViewInterface::Ptr
boost::shared_ptr< ViewInterface > Ptr
Definition: viewinterface.hh:193
SourcePresentation::Ptr
boost::shared_ptr< SourcePresentation > Ptr
Definition: tiledbitmapinterface.hh:198
LayerSpec
std::vector< LayerOperations::Ptr > LayerSpec
Definition: tiledbitmapinterface.hh:190
colormappable.hh
quit
bool quit()
Definition: test-helpers.cc:120
drawingAreaHeight
int drawingAreaHeight
Definition: test-helpers.cc:23
init_tests
void init_tests()
Definition: measure-framerate-tests.cc:152
TestData::Ptr
boost::shared_ptr< TestData > Ptr
Definition: test-helpers.hh:45
reset
bool reset()
Definition: test-helpers.cc:127
ColormapProvider::Ptr
boost::shared_ptr< ColormapProvider > Ptr
Definition: colormappable.hh:149
DummyColormapProvider
Definition: test-helpers.hh:24
TestData::ls
LayerSpec ls
Definition: test-helpers.hh:51
testData
TestData::Ptr testData
Definition: test-helpers.cc:25
ViewInterfaceStub
Definition: measure-framerate-stubs.hh:45
ProgressInterfaceStub
Definition: measure-framerate-stubs.hh:22
Sleeper::t
struct timespec t
Definition: test-helpers.hh:90
measure-framerate-callbacks.hh
layeroperations.hh
ColormapProvider
Definition: colormappable.hh:146
TestData::~TestData
~TestData()
Definition: test-helpers.cc:70
wait
bool wait()
Definition: test-helpers.cc:134
Sleeper::Sleeper
Sleeper(unsigned int secs)
Definition: test-helpers.cc:93
setupTest2bpp
bool setupTest2bpp(int zoom, int width, int height)
Definition: test-helpers.cc:164
reset
bool reset()
Definition: test-helpers.cc:127
Colormap::Ptr
boost::shared_ptr< Colormap > Ptr
Definition: colormappable.hh:31
colormap
const Colormap::Ptr colormap
Definition: colormaphelpers_test.cc:54
TestData::pi
ProgressInterfaceStub::Ptr pi
Definition: test-helpers.hh:48
Sleeper::started
bool started
Definition: test-helpers.hh:89
ProgressInterfaceStub::Ptr
boost::shared_ptr< ProgressInterfaceStub > Ptr
Definition: measure-framerate-stubs.hh:25
Operations::create
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition: layeroperations.cc:574
setupTest1bpp
bool setupTest1bpp(int zoom, int width, int height)
Definition: test-helpers.cc:146
drawingAreaWidth
int drawingAreaWidth
Definition: test-helpers.cc:22
OperationsColormapped::create
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition: layeroperations.cc:723
quit
bool quit()
Definition: test-helpers.cc:120
Source1Bpp
Definition: measure-framerate-stubs.hh:71
Sleeper::operator()
bool operator()()
Definition: test-helpers.cc:98
drawingAreaWidth
int drawingAreaWidth
Definition: test-helpers.cc:22
setupTest8bppColormapped
bool setupTest8bppColormapped(int zoom, int width, int height)
Definition: test-helpers.cc:217
measure-framerate-stubs.hh
DummyColormapProvider::create
static Ptr create(Colormap::Ptr colormap)
Definition: test-helpers.cc:34
Source2Bpp
Definition: measure-framerate-stubs.hh:79
init
void init()
Definition: measure-framerate-callbacks.cc:98
pixelSizeFromZoom
double pixelSizeFromZoom(int zoom)
Definition: cairo-helpers.cc:112
setupTest2bpp
bool setupTest2bpp(int zoom, int width, int height)
Definition: test-helpers.cc:164
TestData::redraw
void redraw(cairo_t *cr)
Definition: test-helpers.cc:80
test-helpers.hh
TiledBitmapInterface::Ptr
boost::shared_ptr< TiledBitmapInterface > Ptr
Definition: tiledbitmapinterface.hh:239
setupTest1bpp
bool setupTest1bpp(int zoom, int width, int height)
Definition: test-helpers.cc:146
TestData::sp
SourcePresentation::Ptr sp
Definition: test-helpers.hh:53
Source8Bpp
Definition: measure-framerate-stubs.hh:95
Scroom::Utils::Rectangle< int >
setupTest4bpp
bool setupTest4bpp(int zoom, int width, int height)
Definition: test-helpers.cc:182
usage
void usage(const std::string &me, const std::string &message=std::string())
Definition: measure-load-performance.cc:20
TestData::colormapProvider
DummyColormapProvider::Ptr colormapProvider
Definition: test-helpers.hh:50
cairo-helpers.hh
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175
TestData::zoom
int zoom
Definition: test-helpers.hh:54
Source4Bpp
Definition: measure-framerate-stubs.hh:87
TestData::TestData
TestData(DummyColormapProvider::Ptr colormapProvider, LayerSpec ls, const TiledBitmapInterface::Ptr &tbi, SourcePresentation::Ptr sp, int zoom)
Definition: test-helpers.cc:43
setupTest8bppColormapped
bool setupTest8bppColormapped(int zoom, int width, int height)
Definition: test-helpers.cc:217