-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageOutputTest.cpp
39 lines (37 loc) · 1.27 KB
/
ImageOutputTest.cpp
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
/*@
*@file ImageOutputTest.cpp
*@author Aruna Baijal and Umang Rastogi
*@brief Unit test cases for ImageOutput
*@copyright 2019 Aruna Baijal, Umang Rastogi
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <ImageOutput.hpp>
#include <ReaderWriterMock.hpp>
using ::testing::Return;
using ::testing::_;
TEST(imageOutput, drawBoundary) {
/// Instantiate objects for various classes
ImageOutput imageOutput;
ReaderWriterMock* writerMock = new ReaderWriterMock();
/// Set mock to manipulate images
imageOutput.setWriter(writerMock);
/// Read image from file directory
cv::Mat sampleImage = cv::imread("1_Human.jpg", 1);
/// Define a constant rectangle for testing
cv::Rect r1(414, 0, 321, 642);
std::vector<cv::Rect> detectedMock;
detectedMock.push_back(r1);
/// Add mock implementation to draw boundary on image
cv::Mat z = cv::Mat::zeros(720, 1280, CV_8U);
EXPECT_CALL(*writerMock, drawRectangle(_, _)).WillRepeatedly(
Return(z));
/// Evaluate difference between the images
cv::Mat diff = sampleImage
!= imageOutput.drawBoundary(sampleImage, detectedMock);
/// There should be no difference in the images generated by both methods
bool eq = cv::countNonZero(diff) == 0;
EXPECT_EQ(true, eq);
/// delete mock object
delete writerMock;
}