[poppler] 2 commits - qt4/src qt4/tests

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Aug 15 08:46:42 PDT 2009


 qt4/src/poppler-page.cc    |    4 +--
 qt4/tests/check_search.cpp |   51 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit ce70ef7d6afc800e24031dae43da301e9e542f0e
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Aug 15 17:45:57 2009 +0200

    Fix backwards search

diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index f3edfe6..9e889ce 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -1,7 +1,7 @@
 /* poppler-page.cc: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
  * Copyright (C) 2005, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2005-2008, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2005-2009, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus at math.uni-koeln.de>
  * Copyright (C) 2006-2009, Pino Toscano <pino at kde.org>
  * Copyright (C) 2008 Carlos Garcia Campos <carlosgc at gnome.org>
@@ -356,7 +356,7 @@ bool Page::search(const QString &text, QRectF &rect, SearchDirection direction,
             gFalse, gTrue, gTrue, gFalse, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
   else if ( direction == PreviousResult )
     found = textPage->findText( u.data(), len, 
-            gTrue, gFalse, gFalse, gTrue, sCase, gFalse, &sLeft, &sTop, &sRight, &sBottom );
+            gFalse, gTrue, gTrue, gFalse, sCase, gTrue, &sLeft, &sTop, &sRight, &sBottom );
 
   textPage->decRefCnt();
 
commit 5b7b1cdc5c3b8652d3ae583b4d7b8b6de625adc2
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Aug 15 17:45:05 2009 +0200

    Add an autotest showing previousresult fails

diff --git a/qt4/tests/check_search.cpp b/qt4/tests/check_search.cpp
index 734bf45..c7e44bc 100644
--- a/qt4/tests/check_search.cpp
+++ b/qt4/tests/check_search.cpp
@@ -7,6 +7,7 @@ class TestSearch: public QObject
     Q_OBJECT
 private slots:
     void bug7063();
+    void testNextAndPrevious();
 };
 
 void TestSearch::bug7063()
@@ -35,6 +36,56 @@ void TestSearch::bug7063()
     delete doc;
 }
 
+void TestSearch::testNextAndPrevious()
+{
+    Poppler::Document *doc;
+    doc = Poppler::Document::load("../../../test/unittestcases/xr01.pdf");
+    QVERIFY( doc );
+  
+    Poppler::Page *page = doc->page(0);
+    QRectF region( QPointF(0,0), page->pageSize() );
+    
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::FromTop, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 161.44) < 0.01 );
+    QVERIFY( qAbs(region.y() - 127.85) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::NextResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 171.46) < 0.01 );
+    QVERIFY( qAbs(region.y() - 127.85) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::NextResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 161.44) < 0.01 );
+    QVERIFY( qAbs(region.y() - 139.81) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::NextResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 171.46) < 0.01 );
+    QVERIFY( qAbs(region.y() - 139.81) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::NextResult, Poppler::Page::CaseSensitive), false );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::PreviousResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 161.44) < 0.01 );
+    QVERIFY( qAbs(region.y() - 139.81) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::PreviousResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 171.46) < 0.01 );
+    QVERIFY( qAbs(region.y() - 127.85) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::PreviousResult, Poppler::Page::CaseSensitive), true );
+    QVERIFY( qAbs(region.x() - 161.44) < 0.01 );
+    QVERIFY( qAbs(region.y() - 127.85) < 0.01 );
+    QVERIFY( qAbs(region.width() - 6.70) < 0.01 );
+    QVERIFY( qAbs(region.height() - 8.85) < 0.01 );
+    QCOMPARE( page->search(QString("is"), region, Poppler::Page::PreviousResult, Poppler::Page::CaseSensitive), false );
+    
+    delete doc;
+}
+
 QTEST_MAIN(TestSearch)
 #include "check_search.moc"
 


More information about the poppler mailing list