added test case for screenspaceimage

This commit is contained in:
Michael Nilsson
2016-03-17 17:45:27 -04:00
parent 1436269959
commit 4b6b34cd74
3 changed files with 23 additions and 9 deletions

View File

@@ -55,6 +55,8 @@ public:
virtual void update() = 0;
virtual bool isReady() const = 0;
bool isEnabled() const;
glm::vec2 euclideanPosition() const {return _euclideanPosition.value();};
glm::vec2 sphericalPosition() const {return _sphericalPosition.value();};
void move(glm::vec2 v){
if(_useFlatScreen.value()){
glm::vec2 pos = _euclideanPosition.value();

View File

@@ -41,11 +41,3 @@ Fragment getFragment(){
return frag;
}
/* out vec4 _out_color_;
void main() {
Fragment f = getFragment();
_out_color_ = f.color;
gl_FragDepth = f.depth;
} */

View File

@@ -21,10 +21,14 @@
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#define private public
#include "gtest/gtest.h"
// make private variables public, only for testing!!
#include <modules/base/rendering/screenspaceimage.h>
/*
* For each test the following is run:
* Constructor() -> setUp() -> test -> tearDown() -> Deconstructor()
*/
@@ -52,9 +56,25 @@ protected:
TEST_F(ScreenSpaceRenderableTest, initialize){
bool isReady = _ssr.isReady();
ASSERT_TRUE(!isReady) << "ScreenSpaceImage is ready before initialize";
// cannot test initialize, crashes at createplane becasue of opengl functions. needs mocking
//_ssr.initialize();
//isReady = _ssr.isReady();
//ASSERT_TRUE(!isReady) << "ScreenSpaceImage is not ready after initialize";
//_ssr.deinitialize();
//isReady = _ssr.isReady();
//ASSERT_TRUE(!isReady) << "ScreenSpaceImage is still ready after deinitialize";
}
TEST_F(ScreenSpaceRenderableTest, move){
glm::vec2 v1 = _ssr.sphericalPosition();
glm::vec2 v2 = glm::vec2(2.0f, 5.0f);
_ssr.move(v2);
ASSERT_EQ(_ssr.sphericalPosition(), v1 + v2);
}
}//namespace openspace