Skip to content
Permalink
Browse files

Hopefully fix intermittently failing composer html test

  • Loading branch information
nyalldawson committed Dec 1, 2014
1 parent 78141c4 commit 48edab4fe6c28991f86482b09d24283040a9112f
@@ -376,6 +376,8 @@ double QgsComposerHtml::findNearbyPageBreak( double yPos )
//of maxSearchDistance
int changes = 0;
QRgb currentColor;
bool currentPixelTransparent = false;
bool previousPixelTransparent = false;
QRgb pixelColor;
QList< QPair<int, int> > candidates;
int minRow = qMax( idealPos - maxSearchDistance, 0 );
@@ -391,12 +393,14 @@ double QgsComposerHtml::findNearbyPageBreak( double yPos )
//since this is likely a line break, or gap between table cells, etc
//but very unlikely to be midway through a text line or picture
pixelColor = mRenderedPage->pixel( col, candidateRow );
if ( pixelColor != currentColor )
currentPixelTransparent = qAlpha( pixelColor ) == 0;
if ( pixelColor != currentColor && !( currentPixelTransparent && previousPixelTransparent ) )
{
//color has changed
currentColor = pixelColor;
changes++;
}
previousPixelTransparent = currentPixelTransparent;
}
candidates.append( qMakePair( candidateRow, changes ) );
}
@@ -200,7 +200,7 @@ void TestQgsComposerHtml::tableMultiFrame()
void TestQgsComposerHtml::htmlMultiFrameSmartBreak()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, false );
QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 10, 10, 100, 50 );
QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 10, 10, 100, 52 );
htmlItem->addFrame( htmlFrame );
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
htmlItem->setUseSmartBreaks( true );
@@ -209,7 +209,7 @@ void TestQgsComposerHtml::htmlMultiFrameSmartBreak()
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "test_html.html" ) ) );
htmlItem->frame( 0 )->setFrameEnabled( true );
QgsCompositionChecker checker1( "composerhtml_smartbreaks1", mComposition );
bool result = checker1.testComposition( mReport );
bool result = checker1.testComposition( mReport, 0, 200 );

//page2
QgsCompositionChecker checker2( "composerhtml_smartbreaks2", mComposition );
@@ -102,7 +102,7 @@ def testHtmlSmartBreaks(self):
"""Test rendering to multiframes with smart breaks."""
composerHtml = QgsComposerHtml(self.mComposition, False)
htmlFrame = QgsComposerFrame(self.mComposition, composerHtml,
10, 10, 100, 50)
10, 10, 100, 52)
composerHtml.addFrame(htmlFrame)
composerHtml.setResizeMode(
QgsComposerMultiFrame.RepeatUntilFinished)
@@ -113,7 +113,7 @@ def testHtmlSmartBreaks(self):
print "Checking page 1"
myPage = 0
checker1 = QgsCompositionChecker('composerhtml_smartbreaks1', self.mComposition)
myTestResult, myMessage = checker1.testComposition( myPage )
myTestResult, myMessage = checker1.testComposition( myPage, 200 )
assert myTestResult, myMessage

print "Checking page 2"
Binary file not shown.
Binary file not shown.

0 comments on commit 48edab4

Please sign in to comment.
You can’t perform that action at this time.