25#include <allheaders.h>
26#include "gmock/gmock.h"
38class QuickTest :
public testing::Test {
44 const time_t end_time = time(
nullptr);
46 <<
"The test took too long - " << ::testing::PrintToString(end_time -
start_time_);
60 return instance->classicProgress(progress);
87 using ::testing::AllOf;
88 using ::testing::AtLeast;
89 using ::testing::DoAll;
92 using ::testing::Return;
93 using ::testing::SaveArg;
95 auto api = std::make_unique<tesseract::TessBaseAPI>();
96 ASSERT_FALSE(api->Init(tessdatadir, lang)) <<
"Could not initialize tesseract.";
97 Image image = pixRead(imgname);
98 ASSERT_TRUE(image !=
nullptr) <<
"Failed to read test image.";
103 int currentProgress = -1;
104 EXPECT_CALL(progressSink, classicProgress(AllOf(Gt<int &>(currentProgress), Le(100))))
106 .WillRepeatedly(DoAll(SaveArg<0>(¤tProgress), Return(
false)));
107 EXPECT_CALL(progressSink, cancel(_)).Times(AtLeast(5)).WillRepeatedly(Return(
false));
109 EXPECT_EQ(api->Recognize(&progressSink.
monitor),
false);
110 EXPECT_GE(currentProgress, 50) <<
"The reported progress did not reach 50%";
118 using ::testing::AllOf;
119 using ::testing::AtLeast;
120 using ::testing::DoAll;
123 using ::testing::Return;
124 using ::testing::SaveArg;
126 auto api = std::make_unique<tesseract::TessBaseAPI>();
127 ASSERT_FALSE(api->Init(tessdatadir, lang)) <<
"Could not initialize tesseract.";
128 Image image = pixRead(imgname);
129 ASSERT_TRUE(image !=
nullptr) <<
"Failed to read test image.";
130 api->SetImage(image);
134 int currentProgress = -1;
135 EXPECT_CALL(progressSink, classicProgress(_)).Times(0);
136 EXPECT_CALL(progressSink, progress(AllOf(Gt<int &>(currentProgress), Le(100))))
138 .WillRepeatedly(DoAll(SaveArg<0>(¤tProgress), Return(
false)));
139 EXPECT_CALL(progressSink, cancel(_)).Times(AtLeast(5)).WillRepeatedly(Return(
false));
141 EXPECT_EQ(api->Recognize(&progressSink.
monitor),
false);
142 EXPECT_GE(currentProgress, 50) <<
"The reported progress did not reach 50%";
void ClassicProgressTester(const char *imgname, const char *tessdatadir, const char *lang)
void NewProgressTester(const char *imgname, const char *tessdatadir, const char *lang)
TEST(TesseractInstanceTest, TestMultipleTessInstances)
void * cancel_this
monitor-aware progress callback
PROGRESS_FUNC progress_callback
returns true to cancel
PROGRESS_FUNC2 progress_callback2
called whenever progress increases
int16_t progress
chars in this buffer(0)
CANCEL_FUNC cancel
for errcode use
ClassicMockProgressSink()
MOCK_METHOD1(classicProgress, bool(int))
MOCK_METHOD1(cancel, bool(int))
static ClassicMockProgressSink * instance
MOCK_METHOD1(progress, bool(int))