Hopefully fix intermittently failing composer html test

This commit is contained in:
Nyall Dawson 2014-12-01 19:28:50 +11:00
parent 78141c497f
commit 48edab4fe6
5 changed files with 9 additions and 5 deletions

View File

@ -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 ) );
}

View File

@ -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 );

View File

@ -102,7 +102,7 @@ class TestQgsComposerHtml(TestCase):
"""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 @@ class TestQgsComposerHtml(TestCase):
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.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB