videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/videolistselectiondialogtester.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 14:59:52 +0300
changeset 15 cf5481c2bc0b
child 40 13331705e488
permissions -rw-r--r--
Revision: 201011 Kit: 201015

/**
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   VideoListSelectionDialogTester class
* 
*/

#ifndef __VIDEOLISTSELECTIONDIALOGTESTER_H__
#define __VIDEOLISTSELECTIONDIALOGTESTER_H__

#include "videolistselectiondialog.h"

class VideoListSelectionDialogTesterHelper : public QObject
{
    Q_OBJECT
    
signals:
    
    void markAllSignal(int);
    
    void selectionChangedSignal(const QItemSelection&, const QItemSelection&);
    
    void singleItemSelectedSignal(const QModelIndex&);
    
    void modelReadySignal();
    
    void updateCounterSignal();
    
    void primaryActionTriggeredSignal();
    
    void finishedSignal(HbAction*);
    
public:
    
    VideoListSelectionDialogTesterHelper(VideoListSelectionDialog *testable = 0) 
    : mTestable(testable) {};
    
    ~VideoListSelectionDialogTesterHelper() {};
    
    bool connectSignals()
    {
        if(!mTestable)
        {
            return false;
        }
        // disconnect first to make sure there signals are not connected twice
        disconnectSignals();
        if(!connect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int))))
        {
            return false;
        }
        if(!connect(this, SIGNAL(selectionChangedSignal(const QItemSelection&, const QItemSelection&)), 
                mTestable, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&))))
        {
            return false;
        }
        if(!connect(this, SIGNAL(singleItemSelectedSignal(const QModelIndex&)), 
                mTestable, SLOT(singleItemSelectedSlot(const QModelIndex&))))
        {
            return false;
        }
        if(!connect(this, SIGNAL(modelReadySignal()), mTestable, SLOT(modelReadySlot())))
        {
            return false;
        }
        if(!connect(this, SIGNAL(updateCounterSignal()), mTestable, SLOT(updateCounterSlot())))
        {
            return false;
        }
        if(!connect(this, SIGNAL(primaryActionTriggeredSignal()), 
                mTestable, SLOT(primaryActionTriggeredSlot())))
        {
            return false;
        }
        if(!connect(this, SIGNAL(finishedSignal(HbAction*)), mTestable, SLOT(finishedSlot(HbAction*))))
        {
            return false;
        }
        return true;
    }
    
    void disconnectSignals()
    {
        disconnect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int)));
        disconnect(this, SIGNAL(selectionChangedSignal(const QItemSelection&, const QItemSelection&)), 
                        mTestable, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&)));
        disconnect(this, SIGNAL(singleItemSelectedSignal(const QModelIndex&)), 
                        mTestable, SLOT(singleItemSelectedSlot(const QModelIndex&)));
        disconnect(this, SIGNAL(modelReadySignal()), mTestable, SLOT(modelReadySlot()));
        disconnect(this, SIGNAL(updateCounterSignal()), mTestable, SLOT(updateCounterSlot()));
        disconnect(this, SIGNAL(primaryActionTriggeredSignal()), 
                        mTestable, SLOT(primaryActionTriggeredSlot()));
        disconnect(this, SIGNAL(finishedSignal(HbAction*)), mTestable, SLOT(finishedSlot(HbAction*)));
    }
    
    void emitMarkAllStateChanged(int state)
    {
        emit markAllSignal(state);
    }

    void emitSelectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
    {
        emit selectionChangedSignal(selected, deselected);
    }
    
    void emitSingleItemSelectedSlot(const QModelIndex &index)
    {
        emit singleItemSelectedSignal(index);
    }
    
    void emitModelReadySlot()
    {
        emit modelReadySignal();
    }
    
    void emitUpdateCounterSlot()
    {
        emit updateCounterSignal();
    }
    
    void emitPrimaryActionTriggeredSlot()
    {
        emit primaryActionTriggeredSignal();
    }
    
    void emitFinishedSlot(HbAction *action)
    {
        emit finishedSignal(action);
    }
    
    VideoListSelectionDialog *mTestable;
};

#endif