imageseriestest.cpp 3 KB
Newer Older
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
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universitt Mnchen
//      Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// 
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
// 
// ================================================================================================

/**
 * Author: Hossain Mahmud <mahmud@in.tum.de>
 * Date: March 2014
 */

Hossain Mahmud's avatar
Hossain Mahmud committed
30
31
32
33
34
35
#include "gtest/gtest.h"

#include "core/datastructures/imageseries.h"

#include "core/datastructures/imagedata.h"

36
37
38
/**
 * Test class for ImageSeries class.
 */
Hossain Mahmud's avatar
Hossain Mahmud committed
39
40
41
42
43
44
45
46
47
48
class ImageSeriesTest : public testing::Test {
protected:
    ImageSeriesTest() {
        _image = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
        _dh = campvis::DataHandle(_image);

        _imgSeries2.addImage(_image);
        _imgSeries3.addImage(_dh);
    }

49
50
    ~ImageSeriesTest() {        
        //delete _image;    // Don't even think about it. Check DataHandle.h
Hossain Mahmud's avatar
Hossain Mahmud committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    }

    virtual void SetUp() {
    }

    virtual void TearDown() {
    }


protected:
    campvis::ImageSeries _imgSeries1, _imgSeries2, _imgSeries3;
    campvis::ImageData* _image;
    campvis::DataHandle _dh;

};

67
68
69
70
71
72
73
74
/**
 * Tests trivial functions of the class
 * 
 * addImage()
 * getNumImages()
 * getImage()
 */
TEST_F(ImageSeriesTest, miscellaneousTest) {
Hossain Mahmud's avatar
Hossain Mahmud committed
75
76
77
78
79
80
81
    EXPECT_EQ(0, _imgSeries1.getNumImages());
    EXPECT_EQ(1, _imgSeries2.getNumImages());
    EXPECT_EQ(1, _imgSeries3.getNumImages());

    _imgSeries3.addImage(_image);
    EXPECT_EQ(2, _imgSeries3.getNumImages());

82
    EXPECT_EQ(_dh.getData(), _imgSeries3.getImage(_imgSeries3.getNumImages()-1).getData());
Hossain Mahmud's avatar
Hossain Mahmud committed
83
84
85
}


86
87
88
/**
 * Tests the method clone()
 */
Hossain Mahmud's avatar
Hossain Mahmud committed
89
90
91
92
93
94
95
96
97
TEST_F(ImageSeriesTest, cloneTest) {
    campvis::ImageSeries* tempSeries = _imgSeries2.clone();
    EXPECT_EQ(_imgSeries2.getNumImages(), tempSeries->getNumImages());
    EXPECT_EQ(_imgSeries2.getLocalMemoryFootprint(), tempSeries->getLocalMemoryFootprint());
    EXPECT_EQ(_imgSeries2.getVideoMemoryFootprint(), tempSeries->getVideoMemoryFootprint());
    EXPECT_EQ(_imgSeries2.getImage(_imgSeries2.getNumImages()-1).getTimestamp(), tempSeries->getImage(tempSeries->getNumImages()-1).getTimestamp());

    delete tempSeries;
}