|
93 | 93 |
|
94 | 94 | checkVariablesAreSetForTesseract(tesseract); |
95 | 95 | }); |
| 96 | + |
| 97 | + it(@"config dictionary", ^{ |
| 98 | + |
| 99 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 100 | + configDictionary:@{ |
| 101 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 102 | + kG8ParamLoadSystemDawg : @"F", |
| 103 | + kG8ParamLoadFreqDawg : @"F", |
| 104 | + kG8ParamUserWordsSuffix : @"user-words", |
| 105 | + kG8ParamUserPatternsSuffix : @"user-patterns", |
| 106 | + } |
| 107 | + configFileNames:nil |
| 108 | + cachesRelatedDataPath:nil |
| 109 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 110 | + [[tesseract shouldNot] beNil]; |
| 111 | + [[tesseract.absoluteDataPath should] equal:resourcePath]; |
| 112 | + |
| 113 | + checkVariablesAreSetForTesseract(tesseract); |
| 114 | + }); |
| 115 | + |
| 116 | + it(@"config dictionary and a file", ^{ |
| 117 | + |
| 118 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 119 | + configDictionary:@{ |
| 120 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 121 | + } |
| 122 | + configFileNames:@[recognitionConfigsFilePathFromTheBundle] |
| 123 | + cachesRelatedDataPath:nil |
| 124 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 125 | + [[tesseract shouldNot] beNil]; |
| 126 | + [[tesseract.absoluteDataPath should] equal:resourcePath]; |
| 127 | + |
| 128 | + checkVariablesAreSetForTesseract(tesseract); |
| 129 | + }); |
96 | 130 | }); |
97 | 131 |
|
98 | 132 | let(cashesPath, ^id{ |
|
133 | 167 | return @"tessdata"; |
134 | 168 | }); |
135 | 169 |
|
136 | | - it(@"no tessdata folder in the Caches yet", ^{ |
137 | | - |
138 | | - // proof Caches folder is empty |
139 | | - BOOL folderExists = [fileManager fileExistsAtPath:cachesTessDataPath]; |
140 | | - [[theValue(folderExists) should] equal:theValue(NO)]; |
141 | | - |
142 | | - G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
143 | | - configDictionary:nil |
144 | | - configFileNames:nil |
145 | | - cachesRelatedDataPath:tessdataPath |
146 | | - engineMode:G8OCREngineModeTesseractOnly]; |
147 | | - [[tesseract shouldNot] beNil]; |
148 | | - |
149 | | - [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
150 | | - |
151 | | - [[theValue(doFoldersContainTheSameElements()) should] equal:theValue(YES)]; |
152 | | - }); |
153 | | - |
154 | 170 | let(debugConfigsFilePathFromTheCaches, ^id{ |
155 | 171 | return [[[cachesTessDataPath stringByAppendingPathComponent:tessdataFolderName] stringByAppendingPathComponent:tessConfigsFolderName] stringByAppendingPathComponent:debugConfigsFileName]; |
156 | 172 | }); |
157 | 173 | let(recognitionConfigsFilePathFromTheCaches, ^id{ |
158 | 174 | return [[[cachesTessDataPath stringByAppendingPathComponent:tessdataFolderName] stringByAppendingPathComponent:tessConfigsFolderName] stringByAppendingPathComponent:recognitionConfigsFileName]; |
159 | 175 | }); |
160 | | - |
| 176 | + |
| 177 | + context(@"no tessdata folder in the Caches yet", ^{ |
| 178 | + |
| 179 | + it(@"simple init", ^{ |
| 180 | + // proof Caches folder is empty |
| 181 | + BOOL folderExists = [fileManager fileExistsAtPath:cachesTessDataPath]; |
| 182 | + [[theValue(folderExists) should] equal:theValue(NO)]; |
| 183 | + |
| 184 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 185 | + configDictionary:nil |
| 186 | + configFileNames:nil |
| 187 | + cachesRelatedDataPath:tessdataPath |
| 188 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 189 | + [[tesseract shouldNot] beNil]; |
| 190 | + |
| 191 | + [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
| 192 | + |
| 193 | + [[theValue(doFoldersContainTheSameElements()) should] equal:theValue(YES)]; |
| 194 | + }); |
| 195 | + |
| 196 | + it(@"config dictionary", ^{ |
| 197 | + |
| 198 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 199 | + configDictionary:@{ |
| 200 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 201 | + kG8ParamLoadSystemDawg : @"F", |
| 202 | + kG8ParamLoadFreqDawg : @"F", |
| 203 | + kG8ParamUserWordsSuffix : @"user-words", |
| 204 | + kG8ParamUserPatternsSuffix : @"user-patterns", |
| 205 | + } |
| 206 | + configFileNames:nil |
| 207 | + cachesRelatedDataPath:tessdataPath |
| 208 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 209 | + [[tesseract shouldNot] beNil]; |
| 210 | + [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
| 211 | + |
| 212 | + checkVariablesAreSetForTesseract(tesseract); |
| 213 | + }); |
| 214 | + |
| 215 | + it(@"config dictionary and a file", ^{ |
| 216 | + |
| 217 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 218 | + configDictionary:@{ |
| 219 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 220 | + } |
| 221 | + configFileNames:@[recognitionConfigsFilePathFromTheCaches] |
| 222 | + cachesRelatedDataPath:tessdataPath |
| 223 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 224 | + [[tesseract shouldNot] beNil]; |
| 225 | + [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
| 226 | + |
| 227 | + checkVariablesAreSetForTesseract(tesseract); |
| 228 | + }); |
| 229 | + }); |
| 230 | + |
161 | 231 | it(@"config file path, while there is no tessdata folder yet", ^{ |
162 | 232 |
|
163 | 233 | NSLog(@"debugConfigsFilePathFromTheCaches: %@", debugConfigsFilePathFromTheCaches); |
|
269 | 339 |
|
270 | 340 | checkVariablesAreSetForTesseract(tesseract); |
271 | 341 | }); |
| 342 | + |
| 343 | + it(@"config dictionary", ^{ |
| 344 | + |
| 345 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 346 | + configDictionary:@{ |
| 347 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 348 | + kG8ParamLoadSystemDawg : @"F", |
| 349 | + kG8ParamLoadFreqDawg : @"F", |
| 350 | + kG8ParamUserWordsSuffix : @"user-words", |
| 351 | + kG8ParamUserPatternsSuffix : @"user-patterns", |
| 352 | + } |
| 353 | + configFileNames:nil |
| 354 | + cachesRelatedDataPath:tessdataPath |
| 355 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 356 | + [[tesseract shouldNot] beNil]; |
| 357 | + [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
| 358 | + |
| 359 | + checkVariablesAreSetForTesseract(tesseract); |
| 360 | + }); |
| 361 | + |
| 362 | + it(@"config dictionary and a file", ^{ |
| 363 | + |
| 364 | + G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages |
| 365 | + configDictionary:@{ |
| 366 | + kG8ParamTessdataManagerDebugLevel : @"1", |
| 367 | + } |
| 368 | + configFileNames:@[recognitionConfigsFilePathFromTheCaches] |
| 369 | + cachesRelatedDataPath:tessdataPath |
| 370 | + engineMode:G8OCREngineModeTesseractOnly]; |
| 371 | + [[tesseract shouldNot] beNil]; |
| 372 | + [[tesseract.absoluteDataPath should] equal:cachesTessDataPath]; |
| 373 | + |
| 374 | + checkVariablesAreSetForTesseract(tesseract); |
| 375 | + }); |
272 | 376 | }); |
273 | 377 |
|
274 | 378 | afterEach(^{ |
275 | | - NSLog(@"Removing previous tessdata folder from Caches folder"); |
| 379 | + //NSLog(@"Removing previous tessdata folder from Caches folder"); |
276 | 380 | NSError *error = nil; |
277 | 381 | BOOL fileIsRemoved = [fileManager removeItemAtPath:cachesTessDataPath error:&error]; |
278 | 382 | [[theValue(fileIsRemoved) should] equal:theValue(YES)]; |
|
0 commit comments