summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-09 15:19:23 +0000
committerAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-09 15:19:23 +0000
commit5633812ca77f35e52db62e7b432761e0e59253fe (patch)
tree2985071a7a26ae482e9e6e468f7175bf124aa1f8
parentSplitted tests to separate executables (diff)
downloadinkscape-5633812ca77f35e52db62e7b432761e0e59253fe.tar.gz
inkscape-5633812ca77f35e52db62e7b432761e0e59253fe.zip
Removed Object class and temporary test dependencies
(bzr r14954.1.4)
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/object.cpp50
-rw-r--r--src/object.h76
-rw-r--r--src/sp-flowtext.h1
-rw-r--r--testfiles/CMakeLists.txt1
-rw-r--r--testfiles/src/object-set-test.cpp15
-rw-r--r--testfiles/src/object-test.cpp56
-rw-r--r--testfiles/unittest.cpp13
8 files changed, 5 insertions, 209 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 802a79c4f..92436ea9a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -229,7 +229,6 @@ set(inkscape_SRC
message-context.cpp
message-stack.cpp
mod360.cpp
- object.cpp
object-hierarchy.cpp
object-set.cpp
object-snapper.cpp
@@ -355,7 +354,6 @@ set(inkscape_SRC
mod360-test.h
mod360.h
number-opt-number.h
- object.h
object-hierarchy.h
object-set.h
object-snapper.h
diff --git a/src/object.cpp b/src/object.cpp
deleted file mode 100644
index c05d50b3a..000000000
--- a/src/object.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Temporary file
- *
- * Authors:
- * Adrian Boguszewski
- *
- * Copyright (C) 2016 Adrian Boguszewski
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "object.h"
-
-Object::Object(std::string name) : name(name), parent(NULL) { }
-
-Object::~Object() {
- // only for this prototype
- // call destructor on every child
- children.clear_and_dispose(delete_disposer());
- release_signal.emit(this);
-}
-
-const std::string& Object::getName() const {
- return name;
-}
-
-Object *Object::getParent() {
- return parent;
-}
-
-bool Object::isDescendantOf(Object *o) {
- Object* p = parent;
- while(p != NULL) {
- if (p == o) {
- return true;
- }
- p = p->parent;
- }
- return false;
-}
-
-void Object::addChild(Object* o) {
- o->parent = this;
- children.push_back(*o);
-}
-
-sigc::connection Object::connectRelease(sigc::slot<bool, Object*> slot) {
- return release_signal.connect(slot);
-}
-
diff --git a/src/object.h b/src/object.h
deleted file mode 100644
index a5ad5692e..000000000
--- a/src/object.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Temporary file
- *
- * Authors:
- * Adrian Boguszewski
- *
- * Copyright (C) 2016 Adrian Boguszewski
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifndef INKSCAPE_PROTOTYPE_OBJECT_H
-#define INKSCAPE_PROTOTYPE_OBJECT_H
-
-#include <string>
-#include <sigc++/signal.h>
-#include <sigc++/connection.h>
-#include <boost/intrusive/list.hpp>
-
-// this causes some warning, but it's only for this prototype
-class Object;
-struct delete_disposer
-{
- void operator()(Object *delete_this) {
- delete delete_this;
- }
-};
-
-class Object {
-private:
- std::string name;
- Object* parent;
-
- typedef boost::intrusive::list_member_hook<
- boost::intrusive::link_mode<
- boost::intrusive::auto_unlink
- >> list_hook;
- list_hook child_hook;
-
- typedef boost::intrusive::list<
- Object,
- boost::intrusive::constant_time_size<false>,
- boost::intrusive::member_hook<
- Object,
- list_hook,
- &Object::child_hook
- >> list;
- list children;
-
- sigc::signal<bool, Object*> release_signal;
-
-public:
- Object(std::string name);
- virtual ~Object();
-
- list &getChildren() {
- return children;
- }
-
- const std::string &getName() const;
- Object * getParent() ;
-
- sigc::connection connectRelease(sigc::slot<bool, Object*> slot);
- void addChild(Object* o);
- bool isDescendantOf(Object* o);
-
- bool operator==(Object o) {
- return name == o.name;
- }
-
- bool operator!=(Object o) {
- return name != o.name;
- }
-};
-
-#endif //INKSCAPE_PROTOTYPE_OBJECT_H
diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h
index 9ee676893..d0b0a19a4 100644
--- a/src/sp-flowtext.h
+++ b/src/sp-flowtext.h
@@ -8,6 +8,7 @@
#include "libnrtype/Layout-TNG.h"
#include "sp-item.h"
+#include "desktop.h"
#define SP_FLOWTEXT(obj) (dynamic_cast<SPFlowtext*>((SPObject*)obj))
#define SP_IS_FLOWTEXT(obj) (dynamic_cast<const SPFlowtext*>((SPObject*)obj) != NULL)
diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt
index 5bb7ed1e0..e764220bc 100644
--- a/testfiles/CMakeLists.txt
+++ b/testfiles/CMakeLists.txt
@@ -17,7 +17,6 @@ set(TEST_SOURCES
attributes-test
color-profile-test
dir-util-test
- object-test
object-set-test)
set (_optional_unittest_libs )
diff --git a/testfiles/src/object-set-test.cpp b/testfiles/src/object-set-test.cpp
index ff341b162..b0d236128 100644
--- a/testfiles/src/object-set-test.cpp
+++ b/testfiles/src/object-set-test.cpp
@@ -9,11 +9,10 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gtest/gtest.h>
+#include <doc-per-case-test.h>
#include "object-set.h"
-#include "document.h"
-#include "xml/simple-document.h"
-class ObjectSetTest: public testing::Test {
+class ObjectSetTest: public DocPerCaseTest {
public:
ObjectSetTest() {
A = new SPObject();
@@ -71,10 +70,7 @@ TEST_F(ObjectSetTest, Basics) {
TEST_F(ObjectSetTest, Autoremoving) {
SPObject* Q = new SPObject();
- // TODO temporary
- SPDocument *document = new SPDocument();
- Inkscape::XML::Node *rroot = new Inkscape::XML::SimpleDocument();
- Q->invoke_build(document, rroot, 0);
+ Q->invoke_build(_doc, _doc->rroot, 1);
set.add(Q);
EXPECT_TRUE(set.contains(Q));
EXPECT_EQ(1, set.size());
@@ -172,10 +168,7 @@ TEST_F(ObjectSetTest, Removing) {
TEST_F(ObjectSetTest, TwoSets) {
SPObject* Q = new SPObject();
- // TODO temporary
- SPDocument *document = new SPDocument();
- Inkscape::XML::Node *rroot = new Inkscape::XML::SimpleDocument();
- Q->invoke_build(document, rroot, 0);
+ Q->invoke_build(_doc, _doc->rroot, 1);
A->attach(B, nullptr);
A->attach(Q, nullptr);
set.add(A);
diff --git a/testfiles/src/object-test.cpp b/testfiles/src/object-test.cpp
deleted file mode 100644
index 83e90b2ec..000000000
--- a/testfiles/src/object-test.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "gtest/gtest.h"
-#include "object.h"
-
-class ObjectTest: public testing::Test {
-public:
- ObjectTest() {
- object = new Object("parent");
- childOfChild = new Object("childOfChild");
- child = new Object("child");
- child2 = new Object("child2");
- object2 = new Object("object2");
- child3 = new Object("child3");
- }
- ~ObjectTest() {
- delete child3;
- delete child2;
- delete childOfChild;
- delete child;
- delete object2;
- delete object;
- }
- Object* object;
- Object* object2;
- Object* child;
- Object* childOfChild;
- Object* child2;
- Object* child3;
-};
-
-TEST_F(ObjectTest, AddChild) {
- EXPECT_EQ(0, object->getChildren().size());
- object->addChild(child);
- EXPECT_EQ(1, object->getChildren().size());
- EXPECT_EQ(child, &(object->getChildren().front()));
- EXPECT_EQ(object, child->getParent());
-}
-
-TEST_F(ObjectTest, IsDescendantOf) {
- object->addChild(child);
- child->addChild(childOfChild);
- object->addChild(child2);
- object2->addChild(child3);
- EXPECT_TRUE(child->isDescendantOf(object));
- EXPECT_TRUE(childOfChild->isDescendantOf(child));
- EXPECT_TRUE(childOfChild->isDescendantOf(object));
- EXPECT_TRUE(child2->isDescendantOf(object));
- EXPECT_TRUE(child3->isDescendantOf(object2));
- EXPECT_FALSE(child->isDescendantOf(child2));
- EXPECT_FALSE(child2->isDescendantOf(child));
- EXPECT_FALSE(object->isDescendantOf(childOfChild));
- EXPECT_FALSE(object->isDescendantOf(child));
- EXPECT_FALSE(object->isDescendantOf(object2));
- EXPECT_FALSE(object2->isDescendantOf(object));
- EXPECT_FALSE(child2->isDescendantOf(child3));
- EXPECT_FALSE(child3->isDescendantOf(child2));
-}
diff --git a/testfiles/unittest.cpp b/testfiles/unittest.cpp
index 0ec8f0383..e33b4cb43 100644
--- a/testfiles/unittest.cpp
+++ b/testfiles/unittest.cpp
@@ -16,19 +16,6 @@
#include "inkgc/gc-core.h"
#include "inkscape.h"
-namespace {
-
-// Ensure that a known positive test works
-TEST(PreTest, WorldIsSane)
-{
- EXPECT_EQ(4, 2 + 2);
-}
-
-// Example of type casting to avoid compile warnings.
-
-
-} // namespace
-
int main(int argc, char **argv) {
// setup general environment