Permalink
Browse files

Color select test

  • Loading branch information...
feragon committed Aug 12, 2016
1 parent 6b2f39e commit 8046a300f03a0dd1c4f48418a1609ec4478bdaf4
Showing with 57 additions and 3 deletions.
  1. +4 −3 unittest/CMakeLists.txt
  2. +53 −0 unittest/ui/testcolorselect.cpp
View
@@ -70,7 +70,8 @@ if(WITH_QTUI)
ui/uitests.cpp
ui/testlayers.cpp
ui/testlinepatterns.cpp
ui/testcommandline.cpp)
ui/testcommandline.cpp
ui/testcolorselect.cpp)
include_directories("${CMAKE_SOURCE_DIR}/lcUI")
include_directories("${PROJECT_BINARY_DIR}/../lcUI") #Include ui_* files
@@ -82,5 +83,5 @@ include_directories("${CMAKE_SOURCE_DIR}/lcadluascript")
include_directories("${CMAKE_SOURCE_DIR}/lcviewernoqt")
include_directories("${CMAKE_SOURCE_DIR}/lcDXFDWG")
include_directories("${CMAKE_SOURCE_DIR}/third_party")
#add_executable(lcunittest ${src} ${hdrs})
#target_link_libraries(lcunittest lckernel lcviewernoqt gtest ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${LOG4CXX_LIBRARIES})
add_executable(lcunittest ${src} ${hdrs})
target_link_libraries(lcunittest lckernel lcviewernoqt gtest ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${LOG4CXX_LIBRARIES})
@@ -0,0 +1,53 @@
#include <gtest/gtest.h>
#include "uitests.h"
#include <widgets/colorselect.h>
TEST(ColorSelectTest, Selection) {
QApplication app(argc, argv);
ColorSelect colorSelect(0, false, false);
ColorSelect colorSelect_ByBlock_ByLayer(0, true, true);
auto nbColors = QColor::colorNames().size();
/*
* Check for ByBlock and ByLayer (+ 2 for separator and custom color)
*/
EXPECT_EQ(nbColors + 4, colorSelect_ByBlock_ByLayer.count());;
EXPECT_EQ(nbColors + 2, colorSelect.count());
/*
* Check color selection
*/
auto lcColor = lc::Color(255, 0, 0, 255);
auto lcMetaColor = lc::MetaColor(lcColor);
colorSelect.setCurrentText("red");
EXPECT_TRUE(
lcColor.red() == colorSelect.color().red() &&
lcColor.green() == colorSelect.color().green() &&
lcColor.blue() == colorSelect.color().blue()
);
EXPECT_TRUE(
lcMetaColor.red() == colorSelect.metaColor()->red() &&
lcMetaColor.green() == colorSelect.metaColor()->green() &&
lcMetaColor.blue() == colorSelect.metaColor()->blue()
);
}
TEST(ColorSelectTest, CustomColor) {
QApplication app(argc, argv);
ColorSelect colorSelect(0, false, false);
lc::Color lcColor(1, 2, 3, 4);
lc::MetaColor lcMetaColor(lcColor);
colorSelect.setColor(lcColor);
EXPECT_TRUE(
lcColor.red() == colorSelect.color().red() &&
lcColor.green() == colorSelect.color().green() &&
lcColor.blue() == colorSelect.color().blue()
);
EXPECT_TRUE(
lcMetaColor.red() == colorSelect.metaColor()->red() &&
lcMetaColor.green() == colorSelect.metaColor()->green() &&
lcMetaColor.blue() == colorSelect.metaColor()->blue()
);
}

0 comments on commit 8046a30

Please sign in to comment.