radiohswidget/stub/xqaiwrequest.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  XQAiwRequest stub for FM Radio home screen widget
       
    15 *               unit testing.
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QVariant>
       
    21 
       
    22 // User includes
       
    23 #include "xqaiwrequest.h"
       
    24 #include "xqrequestinfo.h"
       
    25 #include "radioservicedef.h"
       
    26 #include "radiologger.h"
       
    27 
       
    28 extern QVariantList request_mocks;
       
    29 extern int send_count;
       
    30 
       
    31 /*!
       
    32     \class XQAiwRequest
       
    33     \brief Stub implementation of XQAiwRequest for unit testing
       
    34 */
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 
       
    38 XQAiwRequest::XQAiwRequest(const QString &interface,
       
    39     const QString &operation, bool isEmbedded) :
       
    40     mOperation(operation),
       
    41     mRequestCount(0)
       
    42 {
       
    43     LOG_METHOD_ENTER;
       
    44 }
       
    45 
       
    46 XQAiwRequest::~XQAiwRequest()
       
    47 {
       
    48     LOG_METHOD_ENTER;
       
    49 }
       
    50 
       
    51 static void replyRequestOk(QVariant reply)
       
    52 {
       
    53     LOG_METHOD_ENTER;
       
    54 }
       
    55 
       
    56 void XQAiwRequest::setOperation(const QString &operation)
       
    57 {
       
    58     LOG_METHOD_ENTER;
       
    59     mOperation = operation;
       
    60 }
       
    61 
       
    62 void XQAiwRequest::setSynchronous(bool synchronous)
       
    63 {
       
    64     LOG_METHOD_ENTER;
       
    65 }
       
    66 
       
    67 void XQAiwRequest::setEmbedded(bool embedded)
       
    68 {
       
    69     LOG_METHOD_ENTER;
       
    70 }
       
    71 
       
    72 bool XQAiwRequest::send()
       
    73 {
       
    74     LOG_METHOD_ENTER;
       
    75     pendingRequests.append(mOperation);
       
    76     replyAfterDelay();
       
    77     return true;
       
    78 }
       
    79 
       
    80 void XQAiwRequest::setInfo(const XQRequestInfo &info)
       
    81 {
       
    82     LOG_METHOD_ENTER;
       
    83 }
       
    84 
       
    85 bool XQAiwRequest::replyAfterDelay()
       
    86 {
       
    87     LOG_METHOD;
       
    88     QString operationStr;
       
    89     bool ret = true;
       
    90     if (mRequestCount < send_count) {
       
    91         replyRequestOk((request_mocks.at(mRequestCount)).toList());
       
    92         ret = false;
       
    93     }
       
    94     return ret;
       
    95 }
       
    96 
       
    97 void XQAiwRequest::replyRequestOk(const QVariantList &reply)
       
    98 {
       
    99     LOG_METHOD_ENTER;
       
   100     ++mRequestCount;
       
   101     emit requestOk(reply);
       
   102 }