Permalink
Browse files

Unit tests for layers and line patterns

  • Loading branch information...
feragon committed Aug 2, 2016
1 parent d40cc4c commit b5c9abb1fa17216c9d3485d7472e0c70e1bb9d45
View
@@ -143,7 +143,7 @@ set(EXTRA_LIBS
#Create library for unit tests
if(WITH_UNITTESTS)
add_library(lcui SHARED ${UI_srcs} ${UI_hdrs})
add_library(lcui SHARED ${UI_srcs} ${UI_hdrs} ${UI_HEADERS} ${UI_RESOURCES})
target_link_libraries(lcui ${EXTRA_LIBS})
endif(WITH_UNITTESTS)
@@ -31,7 +31,7 @@ AddLinePatternDialog::AddLinePatternDialog(lc::Document_SPtr document, lc::DxfLi
ui->saveButton->setText(SAVE_AS_NEW_TEXT);
auto editButton = new QPushButton(EDIT_TEXT);
editButton = new QPushButton(EDIT_TEXT);
connect(editButton, &QPushButton::pressed, this, &AddLinePatternDialog::onEditButtonPressed);
ui->buttonLayout->addWidget(editButton);
}
@@ -37,10 +37,12 @@ class AddLinePatternDialog : public QDialog {
void generatePreview();
private:
protected:
Ui::AddLinePatternDialog* ui;
QPushButton* editButton;
QVBoxLayout* _layout;
private:
lc::Document_SPtr _document;
lc::DxfLinePattern_CSPtr _linePattern;
View
@@ -8,9 +8,8 @@ Layers::Layers(lc::Document_SPtr document, QWidget *parent) :
ui->setupUi(this);
setDocument(document);
model = new LayerModel(this);
setDocument(document);
ui->layerList->setModel(model);
ui->layerList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
@@ -78,7 +77,6 @@ void Layers::on_layerList_clicked(const QModelIndex& index) {
}
auto layer = model->layerAt(index.row());
if(index.column() != LayerModel::NAME) {
auto locked = layer->isFrozen();
@@ -145,17 +143,17 @@ void Layers::replaceLayer(lc::Layer_CSPtr oldLayer, lc::Layer_CSPtr newLayer) {
}
void Layers::updateLayerList() {
if(_document != nullptr) {
std::vector<lc::Layer_CSPtr> layersVector;
std::vector<lc::Layer_CSPtr> layersVector;
if(_document != nullptr) {
auto layersMap = _document->allLayers();
for(auto layer : layersMap) {
layersVector.push_back(layer.second);
}
model->setLayers(layersVector);
}
model->setLayers(layersVector);
}
void Layers::on_addLayerEvent(const lc::AddLayerEvent &) {
View
@@ -30,15 +30,16 @@ class Layers : public QDockWidget {
void on_deleteButton_clicked();
void on_layerList_clicked(const QModelIndex& index);
void changeLayerName(lc::Layer_CSPtr& layer, const std::string& name);
protected:
Ui::Layers* ui;
LayerModel* model;
void createLayer(lc::Layer_CSPtr layer);
void deleteLayer(lc::Layer_CSPtr layer);
void replaceLayer(lc::Layer_CSPtr oldLayer, lc::Layer_CSPtr newLayer);
void changeLayerName(lc::Layer_CSPtr& layer, const std::string& name);
private:
Ui::Layers* ui;
LayerModel* model;
lc::Document_SPtr _document;
void updateLayerList();
@@ -1,6 +1,8 @@
#include "linepatternpathpart.h"
#include "ui_linepatternpathpart.h"
#include <iostream>
LinePatternPathPart::LinePatternPathPart(QWidget* parent) :
LinePatternPathPart(1, parent) {
}
@@ -19,16 +21,17 @@ LinePatternPathPart::LinePatternPathPart(double value, QWidget* parent) :
int typeIndex;
if(value == 0) {
typeIndex = ui->type->findData(PATH_DOT_NAME);
typeIndex = ui->type->findText(PATH_DOT_NAME);
ui->value->setDisabled(true);
}
else if(value > 0) {
typeIndex = ui->type->findData(PATH_PLAIN_NAME);
typeIndex = ui->type->findText(PATH_PLAIN_NAME);
}
else {
typeIndex = ui->type->findData(PATH_SPACE_NAME);
typeIndex = ui->type->findText(PATH_SPACE_NAME);
}
if (typeIndex != -1) {
ui->type->setCurrentIndex(typeIndex);
}
@@ -56,7 +56,7 @@ function FractalTree.drawTree(b, x1, y1, angle, depth)
local x2 = x1 + (math.cos(math.rad(angle)) * depth * 10.0);
local y2 = y1 + (math.sin(math.rad(angle)) * depth * 10.0);
b:append(Line(Coord(x1, y1), Coord(x2, y2), active_layer()));
b:append(Line(Coord(x1, y1), Coord(x2, y2), active_layer(), MetaInfo()));
FractalTree.drawTree(b, x2, y2, angle - 20, depth - 1);
FractalTree.drawTree(b, x2, y2, angle + 20, depth - 1);
end
@@ -186,10 +186,10 @@ function Gear:calc(N, phi, Pc)
local fKeep = first
table.remove(points, 1)
for k,v in pairs(points) do
table.insert(entities, Line(Coord(first.x,first.y), Coord(v.x,v.y),layer))
table.insert(entities, Line(Coord(first.x,first.y), Coord(v.x,v.y),layer,MetaInfo()))
first=v
end
table.insert(entities, Line(Coord(first.x,first.y), Coord(fKeep.x,fKeep.y),layer))
table.insert(entities, Line(Coord(first.x,first.y), Coord(fKeep.x,fKeep.y),layer,MetaInfo()))
return entities
end
@@ -108,9 +108,9 @@ function create_main_window()
linePatternSelect = lc.LinePatternSelect()
if(hideUI ~= true) then
add_toolbar()
add_toolbar()
if(hideUI ~= true) then
mainWindow:showMaximized()
end
@@ -58,7 +58,7 @@ ReplaceLinePattern::ReplaceLinePattern(std::shared_ptr<Document> document, cons
void ReplaceLinePattern::processInternal() {
document()->removeDocumentMetaType(_oldLinePattern);
document()->removeDocumentMetaType(_newLinePattern);
document()->addDocumentMetaType(_newLinePattern);
}
void ReplaceLinePattern::undo() const {
View
@@ -7,6 +7,7 @@ ADD_DEFINITIONS("-Wall")
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(PkgConfig)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#LOG4CXX
pkg_check_modules(LOG4CXX REQUIRED liblog4cxx)
@@ -37,23 +38,38 @@ testmatrices.h
beziertest.h
testselection.h
testintersect.h)
if(WITH_QTUI)
find_package(Qt5Widgets)
find_package(Qt5Core)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Test)
set(EXTRA_LIBS ${EXTRA_LIBS} lcui Qt5::Widgets Qt5::Test)
set(EXTRA_LIBS
${EXTRA_LIBS}
lcui
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Test)
set(hdrs
${hdrs}
ui/testcommandline.h
ui/clicommandtest.h)
ui/clicommandtest.h
ui/uitests.h
ui/widgets/layers.h
ui/dialogs/addlinepatterndialog.h)
set(src
${src}
ui/testtoolbar.cpp
ui/testluaui.cpp
ui/testluaoperations.cpp)
ui/testluaoperations.cpp
ui/uitests.cpp
ui/testlayers.cpp
ui/testlinepatterns.cpp)
include_directories("${CMAKE_SOURCE_DIR}/lcUI")
include_directories("${PROJECT_BINARY_DIR}/../lcUI") #Include ui_* files
include_directories("${CMAKE_SOURCE_DIR}/lcviewerqt")
endif(WITH_QTUI)

0 comments on commit b5c9abb

Please sign in to comment.