Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -46,10 +46,10 @@ int main() | |||||
// constructor gives correct integer values normalized to float (arguments are r, g, b, a; in order) | // constructor gives correct integer values normalized to float (arguments are r, g, b, a; in order) | ||||
{ | { | ||||
Color c(51, 102, 153); | Color c(51, 102, 153); | ||||
DISTRHO_ASSERT_EQUAL(c.red, 0.2f, "red value is 0.2 (integer 51)"); | |||||
DISTRHO_ASSERT_EQUAL(c.green, 0.4f, "green value is 0.4 (integer 102)"); | |||||
DISTRHO_ASSERT_EQUAL(c.blue, 0.6f, "blue value is 0.6 (integer 153)"); | |||||
DISTRHO_ASSERT_EQUAL(c.alpha, 1.0f, "alpha value is 1"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(c.red, 0.2f, "red value is 0.2 (integer 51)"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(c.green, 0.4f, "green value is 0.4 (integer 102)"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(c.blue, 0.6f, "blue value is 0.6 (integer 153)"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(c.alpha, 1.0f, "alpha value is 1"); | |||||
Color white(255, 255, 255); | Color white(255, 255, 255); | ||||
DISTRHO_ASSERT_EQUAL(white.red, 1.0f, "white's red value is 1"); | DISTRHO_ASSERT_EQUAL(white.red, 1.0f, "white's red value is 1"); | ||||
@@ -177,9 +177,9 @@ int main() | |||||
// half point, round to 1 decimal point due to precision loss | // half point, round to 1 decimal point due to precision loss | ||||
Color grey = Color::fromHTML("#7b7b7b"); | Color grey = Color::fromHTML("#7b7b7b"); | ||||
DISTRHO_ASSERT_EQUAL(std::round(grey.red*10)/10, 0.5f, "grey's rounded red value is 0.5"); | |||||
DISTRHO_ASSERT_EQUAL(std::round(grey.green*10)/10, 0.5f, "grey's rounded green value is 0.5"); | |||||
DISTRHO_ASSERT_EQUAL(std::round(grey.blue*10)/10, 0.5f, "grey's rounded blue value is 0.5"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(std::round(grey.red*10)/10, 0.5f, "grey's rounded red value is 0.5"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(std::round(grey.green*10)/10, 0.5f, "grey's rounded green value is 0.5"); | |||||
DISTRHO_ASSERT_SAFE_EQUAL(std::round(grey.blue*10)/10, 0.5f, "grey's rounded blue value is 0.5"); | |||||
} | } | ||||
// check bounds | // check bounds | ||||
@@ -17,40 +17,34 @@ BUILD_CXX_FLAGS += -Wno-extra -Wno-missing-field-initializers | |||||
# --------------------------------------------------------------------------------------------------------------------- | # --------------------------------------------------------------------------------------------------------------------- | ||||
TESTS = Application Color Point NanoSubWidgets | |||||
MANUAL_TESTS = | |||||
UNIT_TESTS = Application Color Point | |||||
ifeq ($(HAVE_CAIRO),true) | ifeq ($(HAVE_CAIRO),true) | ||||
TESTS += Demo.cairo | |||||
WTESTS += Window.cairo | |||||
MANUAL_TESTS += Demo.cairo | |||||
UNIT_TESTS += Window.cairo | |||||
endif | endif | ||||
ifeq ($(HAVE_OPENGL),true) | ifeq ($(HAVE_OPENGL),true) | ||||
TESTS += Demo.opengl | |||||
WTESTS += Window.opengl | |||||
MANUAL_TESTS += Demo.opengl | |||||
MANUAL_TESTS += NanoSubWidgets | |||||
UNIT_TESTS += Window.opengl | |||||
endif | |||||
ifeq ($(HAVE_STUB),true) | |||||
UNIT_TESTS += Window.stub | |||||
endif | endif | ||||
ifeq ($(HAVE_VULKAN),true) | ifeq ($(HAVE_VULKAN),true) | ||||
TESTS += Demo.vulkan | |||||
WTESTS = Window.vulkan | |||||
UNIT_TESTS += Window.vulkan | |||||
endif | endif | ||||
TARGETS = $(TESTS:%=../build/tests/%$(APP_EXT)) | |||||
TARGETS += $(WTESTS:Window.%=../build/tests/Window.%$(APP_EXT)) | |||||
MANUAL_TARGETS = $(MANUAL_TESTS:%=../build/tests/%$(APP_EXT)) | |||||
UNIT_TARGET = $(UNIT_TESTS:%=../build/tests/%$(APP_EXT)) | |||||
OBJS = $(TESTS:%=../build/tests/%.cpp.o) | |||||
OBJS += $(WTESTS:Window.%=../build/tests/Window.cpp.%.o) | |||||
ALL_OBJS = $(MANUAL_TESTS:%=../build/tests/%.cpp.o) | |||||
ALL_OBJS += $(UNIT_TESTS:%=../build/tests/%.cpp.o) | |||||
# --------------------------------------------------------------------------------------------------------------------- | # --------------------------------------------------------------------------------------------------------------------- | ||||
ifeq ($(HAVE_CAIRO),true) | |||||
endif | |||||
ifeq ($(HAVE_OPENGL),true) | |||||
endif | |||||
ifeq ($(HAVE_VULKAN),true) | |||||
endif | |||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
all: $(TARGETS) | |||||
all: $(MANUAL_TARGETS) $(UNIT_TARGET) | |||||
# --------------------------------------------------------------------------------------------------------------------- | # --------------------------------------------------------------------------------------------------------------------- | ||||
@@ -61,8 +55,8 @@ endef | |||||
# valgrind --leak-check=full $@ | # valgrind --leak-check=full $@ | ||||
run: $(TARGETS) | |||||
$(foreach TEST,$(TARGETS),$(call RUN_TEST,$(TEST))) | |||||
run: $(UNIT_TARGET) | |||||
$(foreach TEST,$^,$(call RUN_TEST,$(TEST))) | |||||
# --------------------------------------------------------------------------------------------------------------------- | # --------------------------------------------------------------------------------------------------------------------- | ||||
@@ -92,6 +86,11 @@ clean: | |||||
@echo "Compiling $< (OpenGL)" | @echo "Compiling $< (OpenGL)" | ||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | ||||
../build/tests/%.cpp.stub.o: %.cpp | |||||
-@mkdir -p ../build/tests | |||||
@echo "Compiling $< (Stub)" | |||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||||
../build/tests/%.cpp.vulkan.o: %.cpp | ../build/tests/%.cpp.vulkan.o: %.cpp | ||||
-@mkdir -p ../build/tests | -@mkdir -p ../build/tests | ||||
@echo "Compiling $< (Vulkan)" | @echo "Compiling $< (Vulkan)" | ||||
@@ -112,10 +111,17 @@ clean: | |||||
@echo "Linking $*" | @echo "Linking $*" | ||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | $(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | ||||
../build/tests/%.stub$(APP_EXT): ../build/tests/%.cpp.stub.o | |||||
@echo "Linking $*" | |||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) -o $@ | |||||
../build/tests/%.vulkan$(APP_EXT): ../build/tests/%.cpp.vulkan.o | ../build/tests/%.vulkan$(APP_EXT): ../build/tests/%.cpp.vulkan.o | ||||
@echo "Linking $*" | @echo "Linking $*" | ||||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | $(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | ||||
# --------------------------------------------------------------------------------------------------------------------- | |||||
# linking steps (special, links against DGL static lib) | |||||
../build/tests/Demo.cairo$(APP_EXT): ../build/tests/Demo.cpp.cairo.o ../build/libdgl-cairo.a | ../build/tests/Demo.cairo$(APP_EXT): ../build/tests/Demo.cpp.cairo.o ../build/libdgl-cairo.a | ||||
@echo "Linking Demo (Cairo)" | @echo "Linking Demo (Cairo)" | ||||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | $(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | ||||
@@ -1,6 +1,42 @@ | |||||
This directory contains several tests for DPF related things, from graphics to plugin stuff to utilities. | This directory contains several tests for DPF related things, from graphics to plugin stuff to utilities. | ||||
Each *.cpp file is meant to be its own test. | Each *.cpp file is meant to be its own test. | ||||
In order to test DPF components individually, these tests do not link against DGL directly, | |||||
but will directly import the needed source code. | |||||
All files must be self-contained, in order to prevent surprises in regards global state and initialization stuff. | |||||
In order to test DPF components individually, some of these tests do not link against DGL but import/include its files. | |||||
All test files must be self-contained, in order to prevent surprises in regards global state and initialization stuff. | |||||
The following tests are present: | |||||
- Application | |||||
Verifies that creating an application instance and its event loop is working correctly. | |||||
This test should automatically close itself without errors after a few seconds | |||||
- Circle | |||||
TODO | |||||
- Color | |||||
Runs a few unit-tests on top of the Color class. Mostly complete but still WIP. | |||||
- Demo | |||||
A full window with widgets to verify that contents are being drawn correctly, window can be resized and events work. | |||||
Can be used in both Cairo and OpenGL modes, the Vulkan variant does not work right now. | |||||
- Line | |||||
TODO | |||||
- NanoSubWidgets | |||||
Verifies that NanoVG subwidgets are being drawn properly, and that hide/show calls work as intended. | |||||
There should be a grey background with 3 squares on top, one of hiding every half second in a sequence. | |||||
- Point | |||||
Runs a few unit-tests on top of the Point class. Mostly complete but still WIP. | |||||
- Rectangle | |||||
TODO | |||||
- Triangle | |||||
TODO | |||||
- Window | |||||
Runs a few basic tests with Window showing, hiding and event loop. | |||||
Will try to create a window on screen. | |||||
Should automatically close after a few seconds. |
@@ -14,10 +14,6 @@ | |||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
*/ | */ | ||||
#if !(defined(DGL_CAIRO) || defined(DGL_OPENGL) || defined(DGL_VULKAN)) | |||||
# error test setup failed, must be for cairo, opengl or vulkan | |||||
#endif | |||||
#include "tests.hpp" | #include "tests.hpp" | ||||
#define DPF_TEST_POINT_CPP | #define DPF_TEST_POINT_CPP | ||||
@@ -24,6 +24,9 @@ | |||||
#define DISTRHO_ASSERT_NOT_EQUAL(v1, v2, msg) \ | #define DISTRHO_ASSERT_NOT_EQUAL(v1, v2, msg) \ | ||||
if (v1 == v2) { d_stderr2("Test condition failed: %s; file:%s line:%i", msg, __FILE__, __LINE__); return 1; } | if (v1 == v2) { d_stderr2("Test condition failed: %s; file:%s line:%i", msg, __FILE__, __LINE__); return 1; } | ||||
#define DISTRHO_ASSERT_SAFE_EQUAL(v1, v2, msg) \ | |||||
if (d_isNotEqual(v1, v2)) { d_stderr2("Test condition failed: %s; file:%s line:%i", msg, __FILE__, __LINE__); return 1; } | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||