/*!
 Tests albumArt() request when album art is not in local cache.
 Single request.
 */
void TestMpCollectionAlbumArtManager::testAlbumArtNoCache()
{
    const HbIcon icon = mTest->albumArt(1);
    // Verify that:
    // - It returned default icon
    // - A request has been made to thumbnail manager
    QVERIFY(icon.isNull() == false);
    QCOMPARE(mTest->mPendingRequest, true);
    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
}
/*!
 Tests albumArt() request when thumbnail request fails.
 */
void TestMpCollectionAlbumArtManager::testAlbumArtFail()
{
    mTest->mThumbnailManager->mGetThumbFails = true;
    const HbIcon icon = mTest->albumArt(0);
    // Verify that:
    // - It returned default icon
    // - There is no request pending from thumbnail manager
    QVERIFY(icon.isNull() == false);
    QCOMPARE(mTest->mPendingRequest, false);
    QCOMPARE(mTest->mRequestQueue.count(), 0);
}
/*!
 Tests albumArt() request when art is in local cache.
 */
void TestMpCollectionAlbumArtManager::testAlbumArtCache()
{
    mTest->mImageCache.insert(0, new HbIcon(mIcon));

    const HbIcon icon = mTest->albumArt(0);
    // Verify that:
    // - A valid icon has been returned
    // - No request has been sent to thumbnail manager
    QVERIFY(icon.isNull() == false);
    QCOMPARE(mTest->mPendingRequest, false);
    QCOMPARE(mTest->mRequestQueue.count(), 0);
    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 0);
}
/*!
 Tests albumArt() request when art is not in local cache.
 Request more than 1 to test request queue.
 */
void TestMpCollectionAlbumArtManager::testAlbumArtNoCacheQueue()
{
    for ( int i = 0; i < 3; i++) {
        const HbIcon icon = mTest->albumArt(i);
        QVERIFY(icon.isNull() == false);
    }
    // Verify that:
    // - Max number of requests were sent to thumbnail manager
    // - A request has been queued
    QCOMPARE(mTest->mPendingRequest, true);
    QCOMPARE(mTest->mRequestQueue.count(), 2);
    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);
}
Ejemplo n.º 5
0
/*!
 Get icon.
 \param entry const reference to CaEntry.
 \param sie const reference to icon size.
 \retval icon.
 */
HbIcon CaMenuIconUtility::getEntryIcon(const CaEntry& entry,
        const QSizeF &size)
{
    HbIcon icon;
    QString filename(entry.iconDescription().filename());
    if (!filename.isEmpty()) {
        icon = HbIcon(filename);
    }
    if (icon.isNull() || !(icon.size().isValid())) {
        icon = HbIcon(QDir(".").absoluteFilePath("resource/application.png"));
    }
    if (entry.entryTypeName() == "widget") {
        icon.addBadge(Qt::AlignBottom | Qt::AlignLeft,
                    HbIcon("qtg_small_homescreen"));
    }
    return icon;
}
/*!
 Tests cancel() request.
 */
void TestMpCollectionAlbumArtManager::testCancel()
{
    // First send enough requests to trigger requests to be queued.
    for ( int i = 0; i < 3; i++) {
        const HbIcon icon = mTest->albumArt(i);
        QVERIFY(icon.isNull() == false);
    }
    QCOMPARE(mTest->mPendingRequest, true);
    QCOMPARE(mTest->mRequestQueue.count(), 2);
    QCOMPARE(mTest->mThumbnailManager->mThumbnailReqCounter, 1);

    // Verify that:
    // - All requests to thumbnail manager are cancelled
    // - Queue is emptied
    mTest->cancel();
    QCOMPARE(mTest->mPendingRequest, false);
    QCOMPARE(mTest->mRequestQueue.count(), 0);
    QCOMPARE(mTest->mThumbnailManager->mCancelCounter, 1);
}
Ejemplo n.º 7
0
/*!
    @beta

    Inserts the \a text and \a icon into the combobox at the given \a index.
    If the index is equal to or higher than the total number of items, 
    the new item is appended to the list of existing items.
    If the index is zero or negative, the new item is prepended to the list of existing items.

    \sa insertItem
 */
void HbComboBox::insertItem( int index, const HbIcon &icon,
    const QString &text, const QVariant &userData )
{
    Q_D( HbComboBox );
    if( text.isEmpty( ) ) {
        return;
    }

    if( !d->mModel ) {
        QStandardItemModel* model = new QStandardItemModel( this );
        setModel( model );
    }
    if ( !d->mModel->rowCount( ) ) {
        d->mModel->insertRow( 0 );
        d->mModel->insertColumn( 0 );
        if( d->mModel->index( 0, 0 ).isValid( ) ) {
            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
            setCurrentIndex( 0 );
        }
        if( !icon.isNull( ) && d->mModel->index( 0, 0 ).isValid( ) ) {
            d->mModel->setData( d->mModel->index( 0, 0 ), icon.qicon( ), Qt::DecorationRole );
        }
        if( userData.isValid( ) && d->mModel->index( 0, 0 ).isValid( ) ) {
            d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
        }
    } else {
        int rowCount = d->mModel->rowCount( );
        if( index >= rowCount ) {
            d->mModel->insertRow( rowCount );
            d->mModel->setData( d->mModel->index( rowCount, 0 ), text, Qt::DisplayRole );
            if( !icon.isNull( ) ) {
                d->mModel->setData( d->mModel->index( rowCount, 0 ), icon, Qt::DecorationRole );
            }
            if( userData.isValid( ) ) {
                d->mModel->setData( d->mModel->index( rowCount, 0 ), userData, Qt::UserRole );
            }
            if( d->mCurrentIndex.row( ) == index ) {
                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
                d->currentIndexChanged( d->mCurrentIndex );
            }
        } else if( index <= 0 ) {
            d->mModel->insertRow( 0 );
            d->mModel->setData( d->mModel->index( 0, 0 ), text, Qt::DisplayRole );
            if( !icon.isNull( ) ) {
                d->mModel->setData( d->mModel->index( 0, 0 ), icon, Qt::DecorationRole );
            }
            if( userData.isValid( ) ) {
                d->mModel->setData( d->mModel->index( 0, 0 ), userData, Qt::UserRole );
            }
            if( d->mCurrentIndex.row( ) >= 0 ) {
                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
                d->currentIndexChanged( d->mCurrentIndex );
            }
        } else {
            d->mModel->insertRow( index );
            d->mModel->setData( d->mModel->index( index, 0 ), text, Qt::DisplayRole );
            if( !icon.isNull( ) ) {
                d->mModel->setData( d->mModel->index( index, 0 ), icon, Qt::DecorationRole );
            }
            if( userData.isValid( ) ) {
                d->mModel->setData( d->mModel->index( index, 0 ), userData, Qt::UserRole );
            }
            if( d->mCurrentIndex.row( ) <= index ) {
                d->mCurrentIndex = d->mModel->index( d->mCurrentIndex.row( ) + 1, 0 );
                d->currentIndexChanged( d->mCurrentIndex );
            }
        }
    }
}