summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-01-03 11:50:41 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2021-01-03 11:50:41 +0100
commit756da05c384e3d9258fc07cf9441d899238503f1 (patch)
treeb3385216148d51a2378a2bed5dfc3f0a27d4f1ec /test
parent645250e1cd8ce9bc1faea599df7a1b05836bfeb8 (diff)
Add dggui namespace to libdggui components.
Diffstat (limited to 'test')
-rw-r--r--test/imagecachetest.cc2
-rw-r--r--test/paintertest.cc46
-rw-r--r--test/resource_test.cc4
-rw-r--r--test/translationtest.cc2
-rw-r--r--test/uitests/benchmarktest.cc26
-rw-r--r--test/uitests/filebrowsertest.cc14
-rw-r--r--test/uitests/framewidgettest.cc60
-rw-r--r--test/uitests/powerwidgettest.cc12
-rw-r--r--test/uitests/resizetest.cc16
-rw-r--r--test/uitests/tabwidgettest.cc48
10 files changed, 115 insertions, 115 deletions
diff --git a/test/imagecachetest.cc b/test/imagecachetest.cc
index 6fa08d4..3e7b4fc 100644
--- a/test/imagecachetest.cc
+++ b/test/imagecachetest.cc
@@ -30,7 +30,7 @@
#include <dggui/image.h>
class TestableImageCache
- : public GUI::ImageCache
+ : public dggui::ImageCache
{
public:
std::size_t count(const std::string& filename)
diff --git a/test/paintertest.cc b/test/paintertest.cc
index 611693c..5a1c44a 100644
--- a/test/paintertest.cc
+++ b/test/paintertest.cc
@@ -36,7 +36,7 @@ class TestColour
public:
TestColour(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
: colour(r, g, b, a) {}
- TestColour(const GUI::Colour& colour)
+ TestColour(const dggui::Colour& colour)
: colour(colour) {}
bool operator!=(const TestColour& other) const
@@ -49,7 +49,7 @@ public:
;
}
- const GUI::Colour colour;
+ const dggui::Colour colour;
};
std::ostream& operator<<(std::ostream& stream, const TestColour& col)
@@ -63,28 +63,28 @@ std::ostream& operator<<(std::ostream& stream, const TestColour& col)
}
class TestableCanvas
- : public GUI::Canvas
+ : public dggui::Canvas
{
public:
TestableCanvas(std::size_t width, std::size_t height)
: pixbuf(width, height)
{}
- GUI::PixelBufferAlpha& getPixelBuffer() override
+ dggui::PixelBufferAlpha& getPixelBuffer() override
{
return pixbuf;
}
private:
- GUI::PixelBufferAlpha pixbuf;
+ dggui::PixelBufferAlpha pixbuf;
};
class TestImage
- : public GUI::Image
+ : public dggui::Image
{
public:
TestImage(std::uint8_t width, std::uint8_t height, bool alpha)
- : GUI::Image(":resources/logo.png") // just load some default image
+ : dggui::Image(":resources/logo.png") // just load some default image
{
_width = width;
_height = height;
@@ -98,7 +98,7 @@ public:
{
for(std::uint8_t y = 0; y < _height; ++y)
{
- image_data[x + _width * y] = GUI::Colour(x, y, 0, alpha ? 128 : 255);
+ image_data[x + _width * y] = dggui::Colour(x, y, 0, alpha ? 128 : 255);
image_data_raw[4 * (x + _width * y) + 0] = x;
image_data_raw[4 * (x + _width * y) + 1] = y;
image_data_raw[4 * (x + _width * y) + 2] = 0;
@@ -124,35 +124,35 @@ public:
void testDrawImage()
{
// Success criterion is simply to not assert in the drawing routines...
- GUI::Image image(":resources/logo.png");
+ dggui::Image image(":resources/logo.png");
{ // Image fits in pixelbuffer
TestableCanvas canvas(image.width(), image.height());
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(0, 0, image);
}
{ // Image fits in pixelbuffer, negative offset
TestableCanvas canvas(image.width(), image.height());
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(-10, -10, image);
}
{ // Image too big for pixelbuffer
TestableCanvas canvas(image.width() / 2, image.height() / 2);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(0, 0, image);
}
{ // Image fits in pixelbuffer but offset so it is drawn over the edge.
TestableCanvas canvas(image.width(), image.height());
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(10, 10, image);
}
{ // Image is offset to the right and down so nothing is to be drawn.
TestableCanvas canvas(image.width(), image.height());
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(image.width() + 1,
image.height() + 1,
image);
@@ -160,7 +160,7 @@ public:
{ // Image is offset to the left and up so nothing is to be drawn.
TestableCanvas canvas(image.width(), image.height());
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawImage(-1 * (image.width() + 1),
-1 * (image.height() + 1),
image);
@@ -170,7 +170,7 @@ public:
void testDrawText()
{
// Success criterion is simply to not assert in the drawing routines...
- GUI::Font font;
+ dggui::Font font;
// a string with unicode characters
std::string someText = "Hello World - лæ Библиотека";
std::size_t width = font.textWidth(someText);
@@ -178,31 +178,31 @@ public:
{ // Text fits in pixelbuffer
TestableCanvas canvas(width, height);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(0, 0, font, someText);
}
{ // Text fits in pixelbuffer, negative offset
TestableCanvas canvas(width, height);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(-10, -10, font, someText);
}
{ // Text too big for pixelbuffer
TestableCanvas canvas(width / 2, height / 2);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(0, 0, font, someText);
}
{ // Text fits in pixelbuffer but offset so it is drawn over the edge.
TestableCanvas canvas(width, height);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(10, 10, font, someText);
}
{ // Text is offset to the right and down so nothing is to be drawn.
TestableCanvas canvas(width, height);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(width + 1,
height + 1,
font, someText);
@@ -210,7 +210,7 @@ public:
{ // Text is offset to the left and up so nothing is to be drawn.
TestableCanvas canvas(width, height);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
painter.drawText(-1 * (width + 1),
-1 * (height + 1),
font, someText);
@@ -221,7 +221,7 @@ public:
void testClipping()
{
TestableCanvas canvas(100, 100);
- GUI::Painter painter(canvas);
+ dggui::Painter painter(canvas);
{ // Without alpha
TestImage image(16, 16, false);
diff --git a/test/resource_test.cc b/test/resource_test.cc
index 929544c..5781ff2 100644
--- a/test/resource_test.cc
+++ b/test/resource_test.cc
@@ -31,11 +31,11 @@
#include "drumkit_creator.h"
class ResourceTester
- : public GUI::Resource
+ : public dggui::Resource
{
public:
ResourceTester(const std::string& name)
- : GUI::Resource(name)
+ : dggui::Resource(name)
{}
bool probeIsInternal()
diff --git a/test/translationtest.cc b/test/translationtest.cc
index 7525881..bf33599 100644
--- a/test/translationtest.cc
+++ b/test/translationtest.cc
@@ -68,7 +68,7 @@ public:
#else
setenv("LANG", "da_DK.UTF-8", 1);
#endif
- UITranslation t;
+ dggui::UITranslation t;
// Look up translation from .mo file
uUNIT_ASSERT_EQUAL(std::string("Trommesæt"),
diff --git a/test/uitests/benchmarktest.cc b/test/uitests/benchmarktest.cc
index 5566942..59a6968 100644
--- a/test/uitests/benchmarktest.cc
+++ b/test/uitests/benchmarktest.cc
@@ -34,10 +34,10 @@
#include <dggui/canvas.h>
class TimedCanvas
- : public GUI::Canvas
+ : public dggui::Canvas
{
public:
- GUI::PixelBufferAlpha& getPixelBuffer() override
+ dggui::PixelBufferAlpha& getPixelBuffer() override
{
return pixbuf;
}
@@ -48,7 +48,7 @@ public:
}
private:
- GUI::PixelBufferAlpha pixbuf{800, 600};
+ dggui::PixelBufferAlpha pixbuf{800, 600};
};
class TimedScope
@@ -82,16 +82,16 @@ private:
int main()
{
TimedCanvas canvas;
- GUI::Painter painter(canvas);
- GUI::Image image_no_alpha(":benchmarktest_resources/image_no_alpha.png");
- GUI::Image image_full_alpha(":benchmarktest_resources/image_full_alpha.png");
- GUI::Image image_edge_alpha(":benchmarktest_resources/image_edge_alpha.png");
- GUI::Image image_inner_alpha(":benchmarktest_resources/image_inner_alpha.png");
+ dggui::Painter painter(canvas);
+ dggui::Image image_no_alpha(":benchmarktest_resources/image_no_alpha.png");
+ dggui::Image image_full_alpha(":benchmarktest_resources/image_full_alpha.png");
+ dggui::Image image_edge_alpha(":benchmarktest_resources/image_edge_alpha.png");
+ dggui::Image image_inner_alpha(":benchmarktest_resources/image_inner_alpha.png");
{
TimedCanvas canvas;
TimedScope timed("Pixelbuffer resize", 100000);
- painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 1.f));
+ painter.setColour(dggui::Colour(1.f, 1.f, 1.f, 1.f));
for(int i = 0; i < 100000; ++i)
{
canvas.resize(i % 1000 + 100, i % 1000 + 100);
@@ -108,7 +108,7 @@ int main()
{
TimedScope timed("Filled rect, with alpha", 100000);
- painter.setColour(GUI::Colour(1.f, 1.f, 1.f, 0.5f));
+ painter.setColour(dggui::Colour(1.f, 1.f, 1.f, 0.5f));
for(int i = 0; i < 100000; ++i)
{
painter.drawRectangle(0, 0, 800, 600);
@@ -148,11 +148,11 @@ int main()
}
{
- GUI::PixelBuffer wpixbuf(800, 600);
- std::vector<GUI::PixelBufferAlpha*> children;
+ dggui::PixelBuffer wpixbuf(800, 600);
+ std::vector<dggui::PixelBufferAlpha*> children;
for(int i = 0; i < 100; ++i)
{
- auto child = new GUI::PixelBufferAlpha(300, 300);
+ auto child = new dggui::PixelBufferAlpha(300, 300);
child->x = i * 2;
child->y = i * 2;
children.push_back(child);
diff --git a/test/uitests/filebrowsertest.cc b/test/uitests/filebrowsertest.cc
index 7c309d9..8cede7e 100644
--- a/test/uitests/filebrowsertest.cc
+++ b/test/uitests/filebrowsertest.cc
@@ -36,11 +36,11 @@
#include <filebrowser.h>
class TestWindow
- : public GUI::Window
+ : public dggui::Window
{
public:
TestWindow()
- : GUI::Window(nullptr)
+ : dggui::Window(nullptr)
{
setCaption("FileBrowserTest Window");
CONNECT(eventHandler(), closeNotifier,
@@ -100,22 +100,22 @@ public:
return !closing;
}
- void repaintEvent(GUI::RepaintEvent* repaintEvent)
+ void repaintEvent(dggui::RepaintEvent* repaintEvent)
{
- GUI::Painter painter(*this);
+ dggui::Painter painter(*this);
label.resize(width(), 30);
//painter.clear();
- painter.setColour(GUI::Colour(0,1,0));
+ painter.setColour(dggui::Colour(0,1,0));
painter.drawFilledRectangle(0, 0, width(), height());
}
private:
bool closing{false};
- GUI::Button button{this};
- GUI::Label label{this};
+ dggui::Button button{this};
+ dggui::Label label{this};
GUI::FileBrowser file_browser{this};
};
diff --git a/test/uitests/framewidgettest.cc b/test/uitests/framewidgettest.cc
index 4f0e0fd..97f9ed0 100644
--- a/test/uitests/framewidgettest.cc
+++ b/test/uitests/framewidgettest.cc
@@ -40,65 +40,65 @@
// TODO: fix segfault on close
-class Widget1 : public GUI::Widget
+class Widget1 : public dggui::Widget
{
public:
- Widget1(GUI::Widget* parent) : GUI::Widget(parent)
+ Widget1(dggui::Widget* parent) : dggui::Widget(parent)
{
layout.setResizeChildren(true);
- layout.setHAlignment(GUI::HAlignment::center);
+ layout.setHAlignment(dggui::HAlignment::center);
label1.setText("Label1");
- label1.setAlignment(GUI::TextAlignment::left);
+ label1.setAlignment(dggui::TextAlignment::left);
layout.addItem(&label1);
label2.setText("Label2");
- label2.setAlignment(GUI::TextAlignment::center);
+ label2.setAlignment(dggui::TextAlignment::center);
layout.addItem(&label2);
label3.setText("Label3");
- label3.setAlignment(GUI::TextAlignment::right);
+ label3.setAlignment(dggui::TextAlignment::right);
layout.addItem(&label3);
}
private:
- GUI::VBoxLayout layout{this};
- GUI::Label label1{this};
- GUI::Label label2{this};
- GUI::Label label3{this};
+ dggui::VBoxLayout layout{this};
+ dggui::Label label1{this};
+ dggui::Label label2{this};
+ dggui::Label label3{this};
};
-class Widget2 : public GUI::Widget
+class Widget2 : public dggui::Widget
{
public:
- Widget2(GUI::Widget* parent) : GUI::Widget(parent)
+ Widget2(dggui::Widget* parent) : dggui::Widget(parent)
{
layout.setSpacing(10);
layout.setResizeChildren(true);
- layout.setVAlignment(GUI::VAlignment::top);
+ layout.setVAlignment(dggui::VAlignment::top);
label1.setText("Label1");
- label1.setAlignment(GUI::TextAlignment::right);
+ label1.setAlignment(dggui::TextAlignment::right);
layout.addItem(&label1);
label2.setText("Label2");
- label2.setAlignment(GUI::TextAlignment::left);
+ label2.setAlignment(dggui::TextAlignment::left);
layout.addItem(&label2);
layout.addItem(&checkbox);
}
private:
- GUI::HBoxLayout layout{this};
- GUI::Label label1{this};
- GUI::Label label2{this};
- GUI::CheckBox checkbox{this};
+ dggui::HBoxLayout layout{this};
+ dggui::Label label1{this};
+ dggui::Label label2{this};
+ dggui::CheckBox checkbox{this};
};
-class TestWindow : public GUI::Window
+class TestWindow : public dggui::Window
{
public:
- TestWindow() : GUI::Window(nullptr)
+ TestWindow() : dggui::Window(nullptr)
{
setCaption("FrameWidgetTest Window");
CONNECT(eventHandler(), closeNotifier, this,
@@ -107,7 +107,7 @@ public:
layout.setSpacing(10);
layout.setResizeChildren(true);
- layout.setHAlignment(GUI::HAlignment::center);
+ layout.setHAlignment(dggui::HAlignment::center);
layout.addItem(&frame1);
layout.addItem(&frame2);
@@ -141,22 +141,22 @@ public:
return !closing;
}
- void repaintEvent(GUI::RepaintEvent* repaintEvent) override
+ void repaintEvent(dggui::RepaintEvent* repaintEvent) override
{
- GUI::Painter painter(*this);
- painter.setColour(GUI::Colour(0.85));
+ dggui::Painter painter(*this);
+ painter.setColour(dggui::Colour(0.85));
painter.drawFilledRectangle(0, 0, width() - 1, height() - 1);
}
private:
bool closing{false};
- GUI::VBoxLayout layout{this};
+ dggui::VBoxLayout layout{this};
- GUI::FrameWidget frame1{this, true};
- GUI::FrameWidget frame2{this, false};
- GUI::FrameWidget frame3{this, true};
- GUI::FrameWidget frame4{this, false};
+ dggui::FrameWidget frame1{this, true};
+ dggui::FrameWidget frame2{this, false};
+ dggui::FrameWidget frame3{this, true};
+ dggui::FrameWidget frame4{this, false};
Widget1 w1_1{this};
Widget1 w1_2{this};
diff --git a/test/uitests/powerwidgettest.cc b/test/uitests/powerwidgettest.cc
index 41aff67..4d01168 100644
--- a/test/uitests/powerwidgettest.cc
+++ b/test/uitests/powerwidgettest.cc
@@ -43,11 +43,11 @@
#include <powerwidget.h>
class TestWindow
- : public GUI::Window
+ : public dggui::Window
{
public:
TestWindow()
- : GUI::Window()
+ : dggui::Window()
{
setCaption("PowerWidgetTest Window");
CONNECT(eventHandler(), closeNotifier, this,
@@ -96,10 +96,10 @@ public:
return !closing;
}
- void repaintEvent(GUI::RepaintEvent* repaintEvent) override
+ void repaintEvent(dggui::RepaintEvent* repaintEvent) override
{
- GUI::Painter painter(*this);
- painter.setColour(GUI::Colour(0.85));
+ dggui::Painter painter(*this);
+ painter.setColour(dggui::Colour(0.85));
painter.drawFilledRectangle(0, 0, width() - 1, height() - 1);
}
@@ -108,7 +108,7 @@ private:
Settings settings;
SettingsNotifier settings_notifier{settings};
- PowerWidget w{this, settings, settings_notifier};
+ GUI::PowerWidget w{this, settings, settings_notifier};
};
int main()
diff --git a/test/uitests/resizetest.cc b/test/uitests/resizetest.cc
index 28439d1..17748bf 100644
--- a/test/uitests/resizetest.cc
+++ b/test/uitests/resizetest.cc
@@ -35,11 +35,11 @@
#include <dggui/painter.h>
class TestWindow
- : public GUI::Window
+ : public dggui::Window
{
public:
TestWindow()
- : GUI::Window(nullptr)
+ : dggui::Window(nullptr)
{
setCaption("ResizeTest Window");
CONNECT(eventHandler(), closeNotifier,
@@ -71,19 +71,19 @@ public:
return !closing;
}
- void repaintEvent(GUI::RepaintEvent* repaintEvent)
+ void repaintEvent(dggui::RepaintEvent* repaintEvent)
{
- GUI::Painter painter(*this);
+ dggui::Painter painter(*this);
//painter.clear();
- painter.setColour(GUI::Colour(0,1,0));
+ painter.setColour(dggui::Colour(0,1,0));
painter.drawFilledRectangle(0, 0, width(), height());
auto currentSize = std::make_pair(width(), height());
auto currentPosition = std::make_pair(x(), y());
{
- painter.setColour(GUI::Colour(1,0,0));
+ painter.setColour(dggui::Colour(1,0,0));
char str[64];
sprintf(str, "reported: (%d, %d); (%d, %d)",
(int)reportedPosition.first,
@@ -98,7 +98,7 @@ public:
}
{
- painter.setColour(GUI::Colour(1,0,0));
+ painter.setColour(dggui::Colour(1,0,0));
char str[64];
sprintf(str, "current: (%d, %d); (%d, %d)",
(int)currentPosition.first,
@@ -115,7 +115,7 @@ public:
private:
bool closing{false};
- GUI::Font font{":resources/font.png"};
+ dggui::Font font{":resources/font.png"};
std::pair<std::size_t, std::size_t> reportedSize;
std::pair<int, int> reportedPosition;
};
diff --git a/test/uitests/tabwidgettest.cc b/test/uitests/tabwidgettest.cc
index 36a69cc..804e979 100644
--- a/test/uitests/tabwidgettest.cc
+++ b/test/uitests/tabwidgettest.cc
@@ -38,67 +38,67 @@
#include <dggui/painter.h>
class Widget1
- : public GUI::Widget
+ : public dggui::Widget
{
public:
- Widget1(GUI::Widget* parent)
- : GUI::Widget(parent)
+ Widget1(dggui::Widget* parent)
+ : dggui::Widget(parent)
{
layout.setResizeChildren(true);
- layout.setHAlignment(GUI::HAlignment::center);
+ layout.setHAlignment(dggui::HAlignment::center);
label1.setText("Label1");
- label1.setAlignment(GUI::TextAlignment::left);
+ label1.setAlignment(dggui::TextAlignment::left);
layout.addItem(&label1);
label2.setText("Label2");
- label2.setAlignment(GUI::TextAlignment::center);
+ label2.setAlignment(dggui::TextAlignment::center);
layout.addItem(&label2);
label3.setText("Label3");
- label3.setAlignment(GUI::TextAlignment::right);
+ label3.setAlignment(dggui::TextAlignment::right);
layout.addItem(&label3);
}
private:
- GUI::VBoxLayout layout{this};
- GUI::Label label1{this};
- GUI::Label label2{this};
- GUI::Label label3{this};
+ dggui::VBoxLayout layout{this};
+ dggui::Label label1{this};
+ dggui::Label label2{this};
+ dggui::Label label3{this};
};
class Widget2
- : public GUI::Button
+ : public dggui::Button
{
public:
- Widget2(GUI::Widget* parent)
- : GUI::Button(parent)
+ Widget2(dggui::Widget* parent)
+ : dggui::Button(parent)
{
setText("Widget2");
}
};
class Widget3
- : public GUI::Widget
+ : public dggui::Widget
{
public:
- Widget3(GUI::Widget* parent)
- : GUI::Widget(parent)
+ Widget3(dggui::Widget* parent)
+ : dggui::Widget(parent)
{
label.move(100, 80);
label.resize(100, 20);
label.setText("Widget3");
}
private:
- GUI::Label label{this};
+ dggui::Label label{this};
};
class TestWindow
- : public GUI::Window
+ : public dggui::Window
{
public:
TestWindow()
- : GUI::Window(nullptr)
+ : dggui::Window(nullptr)
{
setCaption("TabWidgetTest Window");
CONNECT(eventHandler(), closeNotifier,
@@ -126,16 +126,16 @@ public:
return !closing;
}
- void repaintEvent(GUI::RepaintEvent* repaintEvent) override
+ void repaintEvent(dggui::RepaintEvent* repaintEvent) override
{
- GUI::Painter painter(*this);
- painter.setColour(GUI::Colour(0.85));
+ dggui::Painter painter(*this);
+ painter.setColour(dggui::Colour(0.85));
painter.drawFilledRectangle(0, 0, width() - 1, height() - 1);
}
private:
bool closing{false};
- GUI::TabWidget tabs{this};
+ dggui::TabWidget tabs{this};
Widget1 widget1{this};
Widget2 widget2{this};
Widget3 widget3{this};