summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Interface/NXSceneGraphTest.h
blob: bc7ded32bf3657e04b73f7ea5bbced7cea476de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

#ifndef NX_SCENEGRAPHTEST_H
#define NX_SCENEGRAPHTEST_H

#include <cppunit/extensions/HelperMacros.h>

// class NXSceneGraphTest;

#include "Nanorex/Interface/NXSceneGraph.h"

// using namespace Nanorex;

namespace Nanorex {

/* CLASS: NXSGApplyTesterNode */
/**
 * Tests the apply() tree by incrementing a global count variable
 */
class NXSGApplyTesterNode : public NXSGNode {
public:
    NXSGApplyTesterNode() {}
    ~NXSGApplyTesterNode() {}
    bool apply(void) const { ++numApplications; return true; }
    static int const& GetNumApplications(void) { return numApplications; }
    static void ResetNumApplications(void) { numApplications = 0; }
private:
    static int numApplications;
};

/* CLASS: NXSGApplyBlockerNode */
/**
 * Its apply() does nothing and always returns false to block the execution
 */
class NXSGApplyBlockerNode : public NXSGNode {
public:
    NXSGApplyBlockerNode() {}
    ~NXSGApplyBlockerNode() {}
    bool apply(void) const { return false; }
};


#if 0
/* CLASS: NXSGDeleteTesterNode */
/**
 * Overrides the deleteRecursive() method to count number of delete-s instead
 * of actually deleting nodes
 */
class NXSGDeleteTesterNode : public NXSGNode {
public:
    NXSGDeleteTesterNode() {}
    ~NXSGDeleteTesterNode() {}
    static int const& GetNumDeletes(void) { return numDeletes; }
    static void ResetNumDeletes(void) { numDeletes = 0; }
    void deleteRecursive(void);
private:
    static int numDeletes;
};
#endif


/* CLASS: NXSceneGraphTest */
/**
 * Tests the scene-graph API
 */
class NXSceneGraphTest: public CPPUNIT_NS::TestFixture {
    
    CPPUNIT_TEST_SUITE(NXSceneGraphTest);
    CPPUNIT_TEST(refCountTest1);
	CPPUNIT_TEST(refCountTest2);
	CPPUNIT_TEST(childManipTest);
    CPPUNIT_TEST(applyTest1);
	CPPUNIT_TEST(applyTest2);
	// CPPUNIT_TEST(deleteRecursiveTest);
    CPPUNIT_TEST(isLeafTest);
    CPPUNIT_TEST_SUITE_END();
    
public:
    void setUp();
    void tearDown();
    
	// void reset();
    static void makeTree(NXSGNode* nodes[7]);
    static void makeInvertedTree(NXSGNode* nodes[7]);
    
    // tests increment, decrement, accessor
    void refCountTest1();
	void refCountTest2();
	void childManipTest();
    void applyTest1();
	void applyTest2();
	// void deleteRecursiveTest();
    void isLeafTest();
    
private:
    NXSGNode *nodes[7];
};

} // namespace Nanorex

#endif // NX_SCENEGRAPHTEST_H