// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL
// Masked background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsMaskedLayerBackgroundControlContext* myCtx = CAknsMaskedLayerBackgroundControlContext::NewL(
        id, initialRect, EFalse, 2 );
    CleanupStack::PushL( myCtx );
    myCtx->SetLayerImage( 0, id2 );
    myCtx->SetLayerImage( 1, id3 );
    myCtx->SetLayerRect( 0, nextRect );
    myCtx->SetLayerRect(1, rect3 );
    // Skipped myCtx->SetLayerMaskAndSizeL() since we cannot get CEikEnv::Static()
    CleanupStack::PopAndDestroy( myCtx );
    
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "MaskedBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseBasicBackgroundControlContextOpsL
// Basic background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseBasicBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;

    CAknsBasicBackgroundControlContext* myCtx =
        CAknsBasicBackgroundControlContext::NewL( id, initialRect, EFalse );
    CleanupStack::PushL( myCtx );

    myCtx->SetBitmap( id2 );
    myCtx->SetRect( nextRect );
    myCtx->SetParentPos( TPoint( 0,0 ) );
    myCtx->SetParentContext( NULL );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "BasicBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
void KisTransparencyMaskTest::testMoveMaskItself()
{
    KisImageSP image;
    KisPaintLayerSP layer;
    KisPaintDeviceSP dev;
    KisTransparencyMaskSP mask;

    initImage(image, layer, dev, mask);
    mask->initSelection(layer);
    mask->selection()->pixelSelection()->invert();
    mask->select(QRect(50, 50, 100, 100));

    KisFullRefreshWalker walker(image->bounds());
    KisAsyncMerger merger;

    walker.collectRects(layer, image->bounds());
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_before.png");

    QRect initialRect(0,0,200,100);
    QCOMPARE(layer->exactBounds(), initialRect);
    QCOMPARE(image->projection()->exactBounds(), QRect(50,50,100,50));


    //layer->setX(100);
    //layer->setY(100);

    dbgKrita << "Sel. rect before:" << mask->selection()->selectedExactRect();

    mask->setX(50);
    mask->setY(25);

    dbgKrita << "Sel. rect after:" << mask->selection()->selectedExactRect();


    QCOMPARE(mask->selection()->selectedExactRect(), QRect(100, 75, 100, 100));
    QCOMPARE(layer->paintDevice()->exactBounds(), initialRect);
    QCOMPARE(layer->projection()->exactBounds(), QRect(50, 50, 100, 50));

    dbgKrita << "";

    QRect updateRect(0,0,300,300);

    walker.collectRects(mask, updateRect);
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_after.png");

    QCOMPARE(layer->paintDevice()->exactBounds(), initialRect);
    QCOMPARE(layer->projection()->exactBounds(), QRect(100, 75, 100, 25));
}
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL
// Combined background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsCombinedBackgroundControlContext* myCtx = 
        CAknsCombinedBackgroundControlContext::NewL( EFalse );
    CleanupStack::PushL( myCtx );

    CAknsBasicBackgroundControlContext* mySubCtx1 = 
        CAknsBasicBackgroundControlContext::NewL( id, initialRect, EFalse );

    CAknsBasicBackgroundControlContext* mySubCtx2 = 
        CAknsBasicBackgroundControlContext::NewL( id3, rect3, EFalse );

    MAknsControlContext* retrievedCtx = myCtx->GetControlContext( 0 );
    if ( retrievedCtx )
        {
        // We haven't add anything to the combined context, so this should fail.
        err = KErrGeneral;
        }

    myCtx->AddControlContext( mySubCtx1 );
    retrievedCtx = myCtx->GetControlContext( 0 );
    if ( !retrievedCtx )
        {
        // We have added one context, so this should not fail.
        err = KErrGeneral;
        }
    myCtx->AddControlContext( mySubCtx2 );
    myCtx->RemoveControlContext( 0 );
    myCtx->GetControlContext( 0 );
    if ( !retrievedCtx )
        {
        // We added two contexts, then removed one, so this should not fail.
        err = KErrGeneral;
        }
    myCtx->RemoveControlContext( 0 ); // remove the last remaining one.
    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "CombinedBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
Exemple #5
0
void QtViewportHandler::setInitialScaleIfNeeded()
{
    if (m_rawAttributes.layoutSize.isEmpty() || m_rawAttributes.initialScale < 0)
        return;

    m_zoomOutScale = 0.0;
    m_scaleStack.clear();

    m_hadUserInteraction = false;

    // We must not animate here as the new contents size might be very different
    // than the current one.
    setPageItemRectVisible(initialRect());

    m_rawAttributes.initialScale = -1; // Mark used.
}
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL
// Listbox background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TRect rect4( TSize( 200, 200 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;
    TAknsItemID id4 = KAknsIIDQsnBgColumn0;

    CAknsListBoxBackgroundControlContext* myCtx =
        CAknsListBoxBackgroundControlContext::NewL( id, initialRect, EFalse, id2, nextRect );
    CleanupStack::PushL( myCtx );

    myCtx->SetTiledBitmap( id3 );
    myCtx->SetTiledRect( rect3 );
    myCtx->SetBottomBitmap( id4 );
    myCtx->SetBottomRect( rect4 );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    // Skipped case to update context since we cannot instantiate singleton.

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "ListBoxBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL
// Layered background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsLayeredBackgroundControlContext* myCtx =
        CAknsLayeredBackgroundControlContext::NewL( id, initialRect, EFalse, 2 );
    CleanupStack::PushL( myCtx );

    myCtx->SetLayerImage( 0, id2 );
    myCtx->SetLayerImage( 1, id3 );
    myCtx->SetLayerRect( 0, nextRect );
    myCtx->SetLayerRect( 1, rect3 );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "LayeredBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }