logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp
changeset 16 c5af8598d22c
parent 14 f27aebe284bb
child 17 90fe74753f71
equal deleted inserted replaced
14:f27aebe284bb 16:c5af8598d22c
    30 #include <QTimer>
    30 #include <QTimer>
    31 #include <QGesture>
    31 #include <QGesture>
    32 #include <hblistview.h>
    32 #include <hblistview.h>
    33 #include <hblistviewitem.h>
    33 #include <hblistviewitem.h>
    34 #include <hbmessagebox.h>
    34 #include <hbmessagebox.h>
       
    35 #include <hbnotificationdialog.h>
       
    36 #include <hbstringutil.h>
    35 
    37 
    36 int actionCount = 0;
    38 int actionCount = 0;
    37 Qt::Orientation windowOrientation = Qt::Vertical;
    39 Qt::Orientation windowOrientation = Qt::Vertical;
    38 bool testMenuShown = false;
    40 bool testMenuShown = false;
       
    41 HbPopup::Placement testPopupShowPlacement = HbPopup::TopLeftCorner;
    39 bool testDialogShown = false;
    42 bool testDialogShown = false;
    40 HbMainWindow* testWindow = 0;
    43 HbMainWindow* testWindow = 0;
    41 HbView* testView = 0;
    44 HbView* testView = 0;
    42 int testViewCount = 0;
    45 int testViewCount = 0;
    43 HbAction* testSoftkeyAction = 0;
    46 HbAction* testSoftkeyAction = 0;
    54 Hb::ActivationReason testActivationReason = Hb::ActivationReasonNormal;
    57 Hb::ActivationReason testActivationReason = Hb::ActivationReasonNormal;
    55 QString testActivityId = "LogsViewMatches";
    58 QString testActivityId = "LogsViewMatches";
    56 QList<HbListViewItem*> testViewItems;
    59 QList<HbListViewItem*> testViewItems;
    57 bool testEnsureVisibleCalled = false;
    60 bool testEnsureVisibleCalled = false;
    58 bool testScrollToCalled = false;
    61 bool testScrollToCalled = false;
       
    62 Qt::LayoutDirection testLayoutDirection = Qt::LeftToRight;
       
    63 bool testConversionEnabled = false;
    59 
    64 
    60 void HbStubHelper::reset()
    65 void HbStubHelper::reset()
    61 {
    66 {
    62     actionCount = 0;
    67     actionCount = 0;
    63     testMenuShown = false;
    68     testMenuShown = false;
    71     testActivities.clear();
    76     testActivities.clear();
    72     qDeleteAll(testViewItems);
    77     qDeleteAll(testViewItems);
    73     testViewItems.clear();
    78     testViewItems.clear();
    74     testScrollToCalled = false;
    79     testScrollToCalled = false;
    75     testEnsureVisibleCalled = false;
    80     testEnsureVisibleCalled = false;
       
    81     testPopupShowPlacement = HbPopup::TopLeftCorner;
       
    82     testConversionEnabled = false;
    76 }
    83 }
    77 
    84 
    78 int HbStubHelper::widgetActionsCount()
    85 int HbStubHelper::widgetActionsCount()
    79 {
    86 {
    80     return actionCount;
    87     return actionCount;
    83 bool HbStubHelper::menuShown()
    90 bool HbStubHelper::menuShown()
    84 {
    91 {
    85     return testMenuShown;
    92     return testMenuShown;
    86 }
    93 }
    87 
    94 
       
    95 int HbStubHelper::menuShownPlacement()
       
    96 {
       
    97     return testPopupShowPlacement;
       
    98 }
       
    99 
    88 bool HbStubHelper::dialogShown()
   100 bool HbStubHelper::dialogShown()
    89 {
   101 {
    90     return testDialogShown;
   102     return testDialogShown;
    91 }
   103 }
    92 
   104 
   154 }
   166 }
   155 
   167 
   156 bool HbStubHelper::listEnsureVisibleCalled()
   168 bool HbStubHelper::listEnsureVisibleCalled()
   157 {
   169 {
   158     return testEnsureVisibleCalled;
   170     return testEnsureVisibleCalled;
       
   171 }
       
   172 
       
   173 void HbStubHelper::stringUtilDigitConversion(bool enabled)
       
   174 {
       
   175     testConversionEnabled = enabled;
       
   176 }
       
   177 
       
   178 QString testNotifDialogText;
       
   179 void HbNotificationDialog::launchDialog(const QString &title, QGraphicsScene *scene)
       
   180 {
       
   181     Q_UNUSED(scene);
       
   182     testNotifDialogText = title;
   159 }
   183 }
   160 
   184 
   161 // -----------------------------------------------------------------------------
   185 // -----------------------------------------------------------------------------
   162 //
   186 //
   163 // -----------------------------------------------------------------------------
   187 // -----------------------------------------------------------------------------
   182 QApplication::~QApplication()
   206 QApplication::~QApplication()
   183 {
   207 {
   184     
   208     
   185 }
   209 }
   186 
   210 
       
   211 void QApplication::setLayoutDirection(Qt::LayoutDirection direction)
       
   212 {
       
   213     testLayoutDirection = direction;
       
   214 }
       
   215 
       
   216 Qt::LayoutDirection QApplication::layoutDirection()
       
   217 {
       
   218     return testLayoutDirection;
       
   219 }
       
   220 
   187 bool QGraphicsWidget::close()
   221 bool QGraphicsWidget::close()
   188 {
   222 {
   189     testIsWidgetOpen = false;
   223     testIsWidgetOpen = false;
       
   224     return true;
   190 }
   225 }
   191 
   226 
   192 void QWidget::setVisible(bool visible)
   227 void QWidget::setVisible(bool visible)
   193 {
   228 {
   194     Q_UNUSED(visible);
   229     Q_UNUSED(visible);
   220 }
   255 }
   221     
   256     
   222 bool HbActivityManager::addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   257 bool HbActivityManager::addActivity(const QString &activityId, const QVariant &data, const QVariantHash &parameters)
   223 {
   258 {
   224     testActivities.append(parameters);
   259     testActivities.append(parameters);
   225 }
   260     return true;
       
   261 }
       
   262 
   226 bool HbActivityManager::removeActivity(const QString &activityId)
   263 bool HbActivityManager::removeActivity(const QString &activityId)
   227 {
   264 {
   228     if ( !testActivities.isEmpty() ){
   265     if ( !testActivities.isEmpty() ){
   229         testActivities.takeFirst();
   266         testActivities.takeFirst();
   230     }
   267     }
       
   268     return true;
   231 }
   269 }
   232 QList<QVariantHash> HbActivityManager::activities() const
   270 QList<QVariantHash> HbActivityManager::activities() const
   233 {
   271 {
   234     return testActivities;
   272     return testActivities;
   235 }
   273 }
   286 void HbMenu::open(QObject *receiver, const char *member)
   324 void HbMenu::open(QObject *receiver, const char *member)
   287 {
   325 {
   288    Q_UNUSED(receiver)
   326    Q_UNUSED(receiver)
   289    Q_UNUSED(member)   
   327    Q_UNUSED(member)   
   290    testMenuShown = true;
   328    testMenuShown = true;
       
   329 }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 void HbPopup::setPreferredPos(const QPointF& position, HbPopup::Placement placement)
       
   336 {
       
   337     Q_UNUSED(position);
       
   338     testPopupShowPlacement = placement;
   291 }
   339 }
   292 
   340 
   293 void HbDialog::open(QObject *receiver, const char *member)
   341 void HbDialog::open(QObject *receiver, const char *member)
   294 {
   342 {
   295    Q_UNUSED(receiver)
   343    Q_UNUSED(receiver)
   368 }
   416 }
   369 
   417 
   370 HbView *HbMainWindow::addView(QGraphicsWidget *widget)
   418 HbView *HbMainWindow::addView(QGraphicsWidget *widget)
   371 {
   419 {
   372     testViewCount++;
   420     testViewCount++;
   373     testViews.append( static_cast<HbView*>(widget) );
   421     HbView* view = static_cast<HbView*>(widget);
       
   422     testViews.append( view );
       
   423     return view;
   374 }
   424 }
   375 
   425 
   376 void HbMainWindow::setCurrentView(HbView *view, bool animate, Hb::ViewSwitchFlags flags)
   426 void HbMainWindow::setCurrentView(HbView *view, bool animate, Hb::ViewSwitchFlags flags)
   377 {
   427 {
   378     Q_UNUSED(flags)
   428     Q_UNUSED(flags)
   472     Q_UNUSED(position);
   522     Q_UNUSED(position);
   473     Q_UNUSED(xMargin);
   523     Q_UNUSED(xMargin);
   474     Q_UNUSED(yMargin);
   524     Q_UNUSED(yMargin);
   475     testEnsureVisibleCalled = true;
   525     testEnsureVisibleCalled = true;
   476 }
   526 }
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 //
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 QString HbStringUtil::convertDigitsTo( const QString str, const DigitType digitType )
       
   533 {
       
   534     Q_UNUSED(digitType);
       
   535     if ( testConversionEnabled ){
       
   536         return ( QString("conv") + str );
       
   537     }
       
   538     return str;
       
   539 }
       
   540 
       
   541 bool QObject::eventFilter(QObject *obj, QEvent *event)
       
   542 {
       
   543     Q_UNUSED(obj)
       
   544     Q_UNUSED(event)
       
   545     return false;
       
   546 }
       
   547 
       
   548 void QObject::installEventFilter(QObject *obj)
       
   549 {
       
   550     Q_UNUSED(obj)
       
   551 }