#import "PopplerPageTest.h" #import "TestSettings.h" #include @implementation PopplerPageTest - (void) setUp { document = [[PopplerDocument alloc] initWithPath: kTestDocument]; } - (void) tearDown { [document release]; } - (void) testPageOrientation { PopplerPage* page = [document page: 1]; [self assertInt: [page orientation] equals: POPPLER_PAGE_ORIENTATION_PORTRAIT]; } - (void) testPageSize { PopplerPage* page = [document page: 1]; NSSize size = [page size]; [self assertTrue: size.width > 0.0]; [self assertTrue: size.height > 0.0]; [self assertTrue: size.height > size.width]; } - (void) testFindText { PopplerPage* page = [document page: 2]; NSArray* hits = [page findText: @"NEXTSTEP"]; [self assertTrue: [hits count] > 0]; // FIXME // The following fails for an unkown reason. Find again // in the same page returns only 1 hit (30 expected). // In Vindaloo, there is no such problem so i guess it is // related to the testing environment in some way. //NSArray* hits2 = [page findText: @"NEXTSTEP"]; //[self assertTrue: [hits2 count] > 0]; //[self assertInt: [hits2 count] equals: [hits count]]; float lastY = FLT_MAX; unsigned i; for (i = 0; i < [hits count]; i++) { PopplerTextHit* hit = [hits objectAtIndex: i]; [self assertTrue: NSMinX([hit hitArea]) >= 0]; [self assertTrue: NSMinY([hit hitArea]) >= 0]; [self assertTrue: NSWidth([hit hitArea]) >= 0]; [self assertTrue: NSHeight([hit hitArea]) >= 0]; [self assertTrue: NSMinX([hit hitArea]) < NSMaxX([hit hitArea])]; [self assertTrue: NSMinY([hit hitArea]) < NSMaxY([hit hitArea])]; [self assertTrue: NSMinY([hit hitArea]) <= lastY]; lastY = NSMinY([hit hitArea]); } } @end