/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Test next and previous work as expected to move // between search matches. void VectorGraphicSearchTest::testNextPrevious()
{
OUString aURL = getFullUrl(u"Pangram.pdf");
SvFileStream aStream(aURL, StreamMode::READ);
GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
aGraphic.makeAvailable();
{ // Start from the beginning of the page
VectorGraphicSearch aSearch(aGraphic);
CPPUNIT_ASSERT_EQUAL(true, aSearch.search(u"lazy"_ustr));
// no previous - we are at the begin
CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(0, aSearch.index()); // nothing was yet found, so it is 0
// next - first position found
CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
// next - second position found
CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
// next - not found, index unchanged
CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
// previous - first position
CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
// previous - not found, index unchanged
CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
// next - second position found
CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
}
{ // Start from the end of the page
VectorGraphicSearch aSearch(aGraphic);
CPPUNIT_ASSERT_EQUAL( true, aSearch.search(u"lazy"_ustr, { SearchStartPosition::End, false, false }));
// no next - we are at the end
CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
CPPUNIT_ASSERT_EQUAL(0, aSearch.index()); // nothing was yet found, so it is 0
// previous - second position found
CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
// previous - first position found
CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
// previous - not found, index unchanged
CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
// next - second position
CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
// next - not found, index unchanged
CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
// previous - first match found
CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.