1 #pragma once 2 3 /** Include all headers to access the dspdfviewer objects */ 4 #include "../adjustedlink.h" 5 #include "../debug.h" 6 #include "../dspdfviewer.h" 7 #include "../hyperlinkarea.h" 8 #include "../pagepart.h" 9 #include "../pdfcacheoption.h" 10 #include "../pdfdocumentreference.h" 11 #include "../pdfpagereference.h" 12 #include "../pdfrenderfactory.h" 13 #include "../pdfviewerwindow.h" 14 #include "../renderedpage.h" 15 #include "../renderingidentifier.h" 16 #include "../renderthread.h" 17 #include "../renderutils.h" 18 #include "../runtimeconfiguration.h" 19 #include "../sconnect.h" 20 #include "../windowrole.h" 21 22 #include <chrono> 23 #include <iostream> 24 25 #include <boost/test/unit_test.hpp> 26 27 namespace TestHelpers { 28 29 /** Returns full path to the specified file */ 30 QString pdfFilename( const std::string& basename ); 31 32 /** Handle to a integration test environment. 33 * Spawns an in-memory X-Server in the background and allows to send 34 * keystrokes and inspect a certain pixel's color. 35 */ 36 class IntegrationTestEnv { 37 public: 38 /** 39 * Starts a dummy X server and loads dspdfviewer with the 40 * given command line arguments. 41 */ 42 IntegrationTestEnv( const std::vector<std::string> & args); 43 44 /** Send a keystroke and wait for a specified time 45 * 46 * See Qt::Key for the list of keys 47 */ 48 void sendKeyAndWait( const int& key, const std::chrono::milliseconds& t); 49 50 /** Inspect pixel color */ 51 QColor grabPixelColor( uint x, uint y); 52 }; 53 54 template<typename T1, typename T2> 55 inline check(const T1 & lhs,const T2 & rhs,int failcode=2)56 void check(const T1& lhs, const T2& rhs, int failcode=2) { 57 if ( ! (lhs == rhs) ) { 58 WARNINGOUT << "Failure:" << lhs << "!=" << rhs; 59 QApplication::exit(failcode); 60 } else { 61 DEBUGOUT << "All right." << lhs << "==" << rhs; 62 } 63 } 64 } 65 66 /** Print a QSize to a standard output stream */ 67 std::ostream& operator << (std::ostream& where, const QSize& what); 68 69 /** Print a QColor to a standard output stream */ 70 std::ostream& operator << (std::ostream& where, const QColor& what); 71