Release v0.6.37: isolate image capture and OCR, fingerprint history duplicates
This commit is contained in:
@@ -59,6 +59,24 @@ int main(int argc, char **argv)
|
||||
app.settings.history = true;
|
||||
app.history->add(clip, L"OCR fixture", app.settings);
|
||||
auto id = app.history->entries().front().id;
|
||||
auto isolated = app.history->recognizeImage(id, config);
|
||||
if (isolated != text) throw std::runtime_error("Helper and in-process OCR results differ");
|
||||
bool cancelled = false;
|
||||
try { app.history->recognizeImage(id, config, [] { return true; }); }
|
||||
catch (const std::exception &) { cancelled = true; }
|
||||
if (!cancelled) throw std::runtime_error("Cancelled OCR request was executed");
|
||||
auto invalid = config;
|
||||
invalid.useTesseract = true;
|
||||
invalid.tesseractPath = (temp / L"missing-tesseract.exe").wstring();
|
||||
bool failed = false;
|
||||
try { app.history->recognizeImage(id, invalid); }
|
||||
catch (const std::exception &) { failed = true; }
|
||||
if (!failed || app.history->entries().front().ocrState != 1)
|
||||
throw std::runtime_error("Failed helper modified history metadata");
|
||||
for (const auto &file : std::filesystem::directory_iterator(temp / L"history"))
|
||||
if (file.path().filename().wstring().starts_with(L"ocr-"))
|
||||
throw std::runtime_error("OCR helper left temporary files");
|
||||
std::cout << "PASS isolated OCR equivalence, cancellation, failure and encrypted IPC cleanup\n";
|
||||
if (tesseract)
|
||||
{
|
||||
app.history->saveOcr(id, L"old Windows result", app.settings);
|
||||
|
||||
Reference in New Issue
Block a user