Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
c3b1de22
Commit
c3b1de22
authored
Jul 27, 2014
by
Christian Schulte zu Berge
Browse files
Fixed AbstractProcessorTest.
parent
c488b267
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/pipeline/abstractprocessor.h
View file @
c3b1de22
...
@@ -58,6 +58,25 @@ namespace campvis {
...
@@ -58,6 +58,25 @@ namespace campvis {
*/
*/
class
CAMPVIS_CORE_API
AbstractProcessor
:
public
HasPropertyCollection
{
class
CAMPVIS_CORE_API
AbstractProcessor
:
public
HasPropertyCollection
{
public:
public:
/**
* Scoped lock of an AbstractProcessor that automatically unlocks the processor on destruction.
* Useful for exception safety.
*/
struct
CAMPVIS_CORE_API
ScopedLock
{
/**
* Constructs a new Scoped lock, locking \a p and unlocking \a p on destruction.
* \param p Processor to lock
* \param unlockInExtraThread Unlock \a p in extra thread (since this might be an expensive operation)
*/
ScopedLock
(
AbstractProcessor
*
p
,
bool
unlockInExtraThread
);
/// Destructor, unlocks the processor
~
ScopedLock
();
AbstractProcessor
*
_p
;
///< The processor to lock
bool
_unlockInExtraThread
;
///< Unlock _p in extra thread (since this might be an expensive operation)
};
/**
/**
* Available invalidation levels
* Available invalidation levels
*/
*/
...
@@ -275,26 +294,6 @@ namespace campvis {
...
@@ -275,26 +294,6 @@ namespace campvis {
sigslot
::
signal1
<
AbstractProcessor
*>
s_validated
;
sigslot
::
signal1
<
AbstractProcessor
*>
s_validated
;
protected:
protected:
/**
* Scoped lock of an AbstractProcessor that automatically unlocks the processor on destruction.
* Useful for exception safety.
*/
struct
CAMPVIS_CORE_API
ScopedLock
{
/**
* Constructs a new Scoped lock, locking \a p and unlocking \a p on destruction.
* \param p Processor to lock
* \param unlockInExtraThread Unlock \a p in extra thread (since this might be an expensive operation)
*/
ScopedLock
(
AbstractProcessor
*
p
,
bool
unlockInExtraThread
);
/// Destructor, unlocks the processor
~
ScopedLock
();
AbstractProcessor
*
_p
;
///< The processor to lock
bool
_unlockInExtraThread
;
///< Unlock _p in extra thread (since this might be an expensive operation)
};
/**
/**
* Gets called from default process() method when having an invalidation level of INVALID_SHADER.
* Gets called from default process() method when having an invalidation level of INVALID_SHADER.
*
*
...
...
test/core/pipeline/abstractprocessortest.cpp
View file @
c3b1de22
...
@@ -30,20 +30,22 @@
...
@@ -30,20 +30,22 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/genericproperty.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagedata.h"
using
namespace
campvis
;
using
namespace
campvis
;
// FIXME: This is not what I was supposed to be. fix me please.
class
DummyTestProcessor
:
public
AbstractProcessor
{
class
DummyTestProcessor
:
public
AbstractProcessor
{
public:
public:
DummyTestProcessor
()
{
DummyTestProcessor
()
_invalidateExternally
=
false
;
:
_boolProperty
(
"BoolProperty"
,
"Bool Property"
,
false
)
this
->
invalidate
(
AbstractProcessor
::
VALID
);
,
_togglePropertyDuringProcess
(
false
)
{
addProperty
(
_boolProperty
);
}
}
~
DummyTestProcessor
()
{}
~
DummyTestProcessor
()
{}
virtual
const
std
::
string
getName
()
const
{
return
"DummyTestProcessor"
;
};
virtual
const
std
::
string
getName
()
const
{
return
"DummyTestProcessor"
;
};
...
@@ -52,19 +54,14 @@ public:
...
@@ -52,19 +54,14 @@ public:
virtual
ProcessorState
getProcessorState
()
const
{
return
AbstractProcessor
::
TESTING
;
};
virtual
ProcessorState
getProcessorState
()
const
{
return
AbstractProcessor
::
TESTING
;
};
virtual
void
updateResult
(
DataContainer
&
dataContainer
)
{
virtual
void
updateResult
(
DataContainer
&
dataContainer
)
{
dataContainer
.
removeData
(
"ImageData"
);
if
(
_togglePropertyDuringProcess
)
{
dataContainer
.
addData
(
"ImageData"
,
new
ImageData
(
2
,
tgt
::
svec3
(
1
,
2
,
1
),
4
));
bool
currentValue
=
_boolProperty
.
getValue
();
}
_boolProperty
.
setValue
(
!
currentValue
);
}
void
setExternalInvalidation
(
bool
status
,
AbstractProcessor
::
InvalidationLevel
level
)
{
_invalidateExternally
=
status
;
this
->
invalidate
(
level
);
this
->
invalidate
(
this
->
getInvalidationLevel
());
}
}
private:
BoolProperty
_boolProperty
;
bool
_
invalidateExternally
;
bool
_
togglePropertyDuringProcess
;
};
};
...
@@ -98,10 +95,26 @@ protected:
...
@@ -98,10 +95,26 @@ protected:
* Tests invalidation of data
* Tests invalidation of data
*/
*/
TEST_F
(
AbstractProcessorTest
,
invalidationTest
)
{
TEST_F
(
AbstractProcessorTest
,
invalidationTest
)
{
this
->
_processor1
.
invalidate
(
AbstractProcessor
::
INVALID_RESULT
);
this
->
_processor1
.
_togglePropertyDuringProcess
=
false
;
this
->
_processor1
.
process
(
this
->
_dataContainer
);
this
->
_processor1
.
process
(
this
->
_dataContainer
);
EXPECT_EQ
(
AbstractProcessor
::
VALID
,
this
->
_processor1
.
getInvalidationLevel
());
EXPECT_EQ
(
AbstractProcessor
::
VALID
,
this
->
_processor1
.
getInvalidationLevel
());
}
this
->
_processor1
.
setExternalInvalidation
(
true
,
AbstractProcessor
::
INVALID_RESULT
);
/**
* Tests processor's locking mechanism
*/
TEST_F
(
AbstractProcessorTest
,
lockingTest
)
{
this
->
_processor1
.
invalidate
(
AbstractProcessor
::
INVALID_RESULT
);
this
->
_processor1
.
_togglePropertyDuringProcess
=
true
;
this
->
_processor1
.
process
(
this
->
_dataContainer
);
this
->
_processor1
.
process
(
this
->
_dataContainer
);
EXPECT_NE
(
AbstractProcessor
::
VALID
,
this
->
_processor1
.
getInvalidationLevel
());
EXPECT_NE
(
AbstractProcessor
::
VALID
,
this
->
_processor1
.
getInvalidationLevel
());
}
{
AbstractProcessor
::
ScopedLock
lock
(
&
this
->
_processor1
,
false
);
bool
currentValue
=
this
->
_processor1
.
_boolProperty
.
getValue
();
this
->
_processor1
.
_boolProperty
.
setValue
(
!
currentValue
);
EXPECT_EQ
(
currentValue
,
this
->
_processor1
.
_boolProperty
.
getValue
());
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment