Example #1
0
void TestOptionalContent::checkNestedLayers()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load(TESTDATADIR "/unittestcases/NestedLayers.pdf");
    QVERIFY( doc );

    QVERIFY( doc->hasOptionalContent() );

    Poppler::OptContentModel *optContent = doc->optionalContentModel();
    QModelIndex index;

    index = optContent->index( 0, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Black Text and Green Snow" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    index = optContent->index( 1, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Mountains and Image" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    // This is a sub-item of "Mountains and Image"
    QModelIndex subindex = optContent->index( 0, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Image" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    index = optContent->index( 2, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Starburst" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    index = optContent->index( 3, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Watermark" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    delete doc;
}
Example #2
0
void TestOptionalContent::checkNoOptionalContent()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load(TESTDATADIR "/unittestcases/orientation.pdf");
    QVERIFY( doc );

    QCOMPARE( doc->hasOptionalContent(), false );

    delete doc;
}
Example #3
0
void TestOptionalContent::checkVisPolicy()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load(TESTDATADIR "/unittestcases/vis_policy_test.pdf");
    QVERIFY( doc );

    QVERIFY( doc->hasOptionalContent() );

    Poppler::OptContentModel *optContent = doc->optionalContentModel();
    QModelIndex index;
    index = optContent->index( 0, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "A" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );
    index = optContent->index( 1, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "B" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    delete doc;
}
Example #4
0
void TestOptionalContent::checkRadioButtons()
{
    Poppler::Document *doc;
    doc = Poppler::Document::load(TESTDATADIR "/unittestcases/ClarityOCGs.pdf");
    QVERIFY( doc );

    QVERIFY( doc->hasOptionalContent() );

    Poppler::OptContentModel *optContent = doc->optionalContentModel();
    QModelIndex index;

    index = optContent->index( 0, 0, QModelIndex() );
    QCOMPARE( optContent->data( index, Qt::DisplayRole ).toString(), QString( "Languages" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( index, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    // These are sub-items of the "Languages" label
    QModelIndex subindex = optContent->index( 0, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    subindex = optContent->index( 1, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 2, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    // RBGroup of languages, so turning on Japanese should turn off English
    QVERIFY( optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole ) );

    subindex = optContent->index( 0, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 2, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );

    subindex = optContent->index( 1, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    // and turning on French should turn off Japanese
    QVERIFY( optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole ) );

    subindex = optContent->index( 0, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 2, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 1, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );


    // and turning off French should leave them all off
    QVERIFY( optContent->setData( subindex, QVariant( false ), Qt::CheckStateRole ) );

    subindex = optContent->index( 0, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "English" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 2, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "Japanese" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    subindex = optContent->index( 1, 0, index );
    QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QString( "French" ) );
    QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );

    delete doc;
}