Need help in getting started with writing the integration test

Tobias Deiminger haxtibal at posteo.de
Sat Jun 9 07:17:46 UTC 2018


Am 08.06.2018 18:57 schrieb Dileep Sankhla:
> Secondly, I'm doing like this to create and add a typewriter
> annotation to page:
> 
> part.m_document->setViewportPage(0);
> 
> Okular::Annotation * annot = nullptr;
> Okular::TextAnnotation * ta = new Okular::TextAnnotation();
> annot = ta;
> ta->setFlags( ta->flags() | Okular::Annotation::FixedRotation );
> ta->setTextType( Okular::TextAnnotation::InPlace );
> ta->setInplaceIntent( Okular::TextAnnotation::TypeWriter );
> ta->style().setWidth( 0.0 );
> ta->style().setColor( QColor(255,255,255,0) );
> 
> annot->setBoundingRectangle( Okular::NormalizedRect( 0.8, 0.1, 0.85,
> 0.15 ) );
> annot->setContents( QStringLiteral("annot contents") );
> 
> // Add annotation to page
> part.m_document->addPageAnnotation( 0, annot );

That's a good test, but I wouldn't implement it in parttest.cpp. You're 
only testing Okular::TextAnnotation and Okular::Document, without GUI 
functionality required. You don't need a Okular::Part to create a 
Okular::Document. Just instantiate a Okular::Document standalone. And 
you don't need to have all typewriter tests in the same cpp file, better 
partition them according to which API you're targeting. Where do 
Okular::Annotation and Okular::Document do come from? They're from 
libOkular5Core.so. Then for example, annotationstest.cpp is about 
testing libOkular5Core. How about moving this test to 
annotationstest.cpp?

> I'm sleeping the UI thread with QThread::sleep(5) for 5 seconds in
> order to hold the output widget and I'm not getting any visual of the
> added annotation. I want to compare different properties from
> Okular::Annotation::getAnnotationPropertiesDomeNode. May you help me
> where I'm wrong or what I'm missing?

Guess if you don't involve GUI, this issue doesn't bother you at all. 
With GUI, you would probably would have to manually trigger the event 
loop (QApplication::processEvents) once.

Cheers
Tobias



More information about the Okular-devel mailing list