wlanutilities/wlanqtutilities/tsrc/context/wlanqtutilstestcontext.h
changeset 38 2dc6da6fb431
child 39 7b3e49e4608a
equal deleted inserted replaced
29:dbe86d96ce5b 38:2dc6da6fb431
       
     1 /*
       
     2 * Copyright (c) 2009-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:
       
    15 * This is the header file for Wlan Qt Utilities test context.
       
    16 */
       
    17  
       
    18 #ifndef WLANQTUTILSTESTCONTEXT_H
       
    19 #define WLANQTUTILSTESTCONTEXT_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QSharedPointer>
       
    23 #include "wlanqtutilsconnection.h"
       
    24 
       
    25 class WlanQtUtilsAp;
       
    26 
       
    27 /**
       
    28  * This is context for esock library.
       
    29  */
       
    30 class WlanQtUtilsCtxEsock : public QObject
       
    31 {
       
    32     Q_OBJECT
       
    33 
       
    34 public:
       
    35     WlanQtUtilsCtxEsock();
       
    36     ~WlanQtUtilsCtxEsock();
       
    37 
       
    38     /**
       
    39      * Initializes context.
       
    40      */
       
    41     void initialize();
       
    42 
       
    43     /** Return value of RConnection::Start(). */
       
    44     int startRetValue_;
       
    45 };
       
    46 
       
    47 /**
       
    48  * This class is a helper class for testing purposes. It derives all properties of WlanQtUtilsConnection.
       
    49  * In addition, this class contains member variables for setting some Connection Monitor specific
       
    50  * values which cannot be easily generated from member variables of WlanQtUtilsConnection.
       
    51  * E.g., connection status has different enum in Connection Monitor and Wlan Qt Utilities. This class
       
    52  * enables setting both of those. Connmon version is set so that the stub can return it when
       
    53  * requested, and Wlan Qt Utilities version is used for verifying that tested code returns right
       
    54  * value.
       
    55  */
       
    56 class WlanQtUtilsCtxActiveConn : public WlanQtUtilsConnection
       
    57 {
       
    58 public:
       
    59     WlanQtUtilsCtxActiveConn();
       
    60     ~WlanQtUtilsCtxActiveConn();
       
    61 
       
    62     /** Bearer type in connmon format. */
       
    63     int connMonBearerType_;
       
    64     /** Connection status in connmon format. */
       
    65     int connMonConnectionStatus_;
       
    66     /** WLAN connection mode in connmon format. */
       
    67     int connMonWlanConnectionMode_;
       
    68     /** WLAN security mode in connmon format. */
       
    69     int connMonWlanSecurityMode_;
       
    70     /** Application UIDs that map to application strings. */
       
    71     QList<int> applicationUids_;
       
    72 };
       
    73 
       
    74 /**
       
    75  * This class represents active connections.
       
    76  */
       
    77 class WlanQtUtilsCtxActiveConnections : public QObject
       
    78 {
       
    79     Q_OBJECT
       
    80 
       
    81 public:
       
    82     WlanQtUtilsCtxActiveConnections();
       
    83     ~WlanQtUtilsCtxActiveConnections();
       
    84 
       
    85     /**
       
    86      * Initializes context.
       
    87      */
       
    88     void initialize();
       
    89 
       
    90     /**
       
    91      * Creates a list of active connections for scan results.
       
    92      * 
       
    93      * @param[in] numberOfActiveConns Number of active connections that are created.
       
    94      * @param[in] firstIapId IAP ID of the first connection to be created.
       
    95      */
       
    96     void createDefaultActiveConnList(int numberOfActiveConns, int firstIapId);
       
    97 
       
    98     /**
       
    99      * Verifies that the given active connection list returned by the real application matches
       
   100      * with the one in the context.
       
   101      * 
       
   102      * @param[in] activeConnList Active connections that are verified against the context.
       
   103      */
       
   104     void verifyActiveConnList(QList<WlanQtUtilsConnection *> activeConnList);
       
   105 
       
   106     /**
       
   107      * Finds an active connection matching with the given connection ID from the context.
       
   108      * Asserts if connection with given connection ID is not found.
       
   109      * 
       
   110      * @param connectionId Connection ID.
       
   111      * @return Active connection.
       
   112      */
       
   113     WlanQtUtilsCtxActiveConn *findActiveConn(uint connectionId) const;
       
   114 
       
   115     /**
       
   116      * List of active connections that RConnectionMonitor stub will return in response to
       
   117      * RConnectionMonitor::Get*Attribute() functions.
       
   118      */
       
   119     QList<WlanQtUtilsCtxActiveConn *> activeConnList_;
       
   120 
       
   121     // TODO: We need return values for all different RConnectionMonitor::Get*Attribute() functions
       
   122     //       to test error cases.
       
   123 
       
   124 private:
       
   125     
       
   126     /**
       
   127      * Destroys and clears the list of WLAN APs.
       
   128      */
       
   129     void clearActiveConnList();
       
   130 };
       
   131 
       
   132 /**
       
   133  * This class represents WLAN APs that represent the results of WLAN scanning triggered by
       
   134  * RConnectionMonitor::GetPckgAttribute()
       
   135  */
       
   136 class WlanQtUtilsWlanScanResult : public QObject
       
   137 {
       
   138     Q_OBJECT
       
   139 
       
   140 public:
       
   141     WlanQtUtilsWlanScanResult();
       
   142     ~WlanQtUtilsWlanScanResult();
       
   143 
       
   144     /**
       
   145      * Initializes context.
       
   146      */
       
   147     void initialize();
       
   148 
       
   149     /**
       
   150      * Creates a list of WLAN APs for scan results.
       
   151      * 
       
   152      * @param[in] numberOfWlanAps Number of WLAN APs that are created.
       
   153      */
       
   154     void createDefaultWlanScanResultList(int numberOfWlanAps);
       
   155 
       
   156     /**
       
   157      * Verifies that the given WLAN AP list returned by the real application matches
       
   158      * with the one in the context.
       
   159      * 
       
   160      * @param[in] wlanApList WLAN APs that are verified against the context.
       
   161      */
       
   162     void verifyWlanScanResultList(
       
   163         QList< QSharedPointer<WlanQtUtilsAp> > wlanApList); // TODO: Maybe boolean return value
       
   164 
       
   165     /**
       
   166      * List of WLAN access points that RConnectionMonitor stub will return in response to
       
   167      * RConnectionMonitor::GetPckgAttribute().
       
   168      */
       
   169     QList<WlanQtUtilsAp *> wlanScanResultList_;
       
   170     
       
   171     /**
       
   172      * Should scan be completed immediately or not?
       
   173      */
       
   174     bool completeWlanScan_;
       
   175     
       
   176     /** Return value of RConnectionMonitor::GetPckgAttribute(). */
       
   177     int scanRetValue_;
       
   178     
       
   179 private:
       
   180     
       
   181     /**
       
   182      * Destroys and clears the list of WLAN APs.
       
   183      */
       
   184     void clearWlanScanResultList();
       
   185 };
       
   186 
       
   187 /**
       
   188  * Test context for RConnectionMonitor.
       
   189  */
       
   190 class WlanQtUtilsCtxConnMon : public QObject
       
   191 {
       
   192     Q_OBJECT
       
   193 
       
   194 public:
       
   195     WlanQtUtilsCtxConnMon();
       
   196     ~WlanQtUtilsCtxConnMon();
       
   197 
       
   198     /**
       
   199      * Initializes context.
       
   200      */
       
   201     void initialize();
       
   202 
       
   203     /** Results of WLAN scanning. */
       
   204     WlanQtUtilsWlanScanResult wlanScanResult_;
       
   205 
       
   206     /** List of active connections. */
       
   207     WlanQtUtilsCtxActiveConnections activeConnections_;
       
   208 };
       
   209 
       
   210 /**
       
   211  * Test context for Internet connectivity test library.
       
   212  */
       
   213 class WlanQtUtilsCtxIct : public QObject
       
   214 {
       
   215     Q_OBJECT
       
   216 
       
   217 public:
       
   218     WlanQtUtilsCtxIct();
       
   219     ~WlanQtUtilsCtxIct();
       
   220 
       
   221     /**
       
   222      * Initializes context.
       
   223      */
       
   224     void initialize();
       
   225 };
       
   226 
       
   227 /**
       
   228  * Test context. The purpose of this context is to provide values that are used in stubs
       
   229  * and in verification of outputs in test cases.
       
   230  * 
       
   231  * In stubs, context is used to verify the inputs of parameters and to set output
       
   232  * parameters into a specific value.
       
   233  * 
       
   234  * In test cases, context is used to verify that the output parameters match with the once
       
   235  * set in the stub.
       
   236  */
       
   237 class WlanQtUtilsTestContext : public QObject
       
   238 {
       
   239     Q_OBJECT
       
   240 
       
   241 public:
       
   242     WlanQtUtilsTestContext();
       
   243     ~WlanQtUtilsTestContext();
       
   244     
       
   245     /**
       
   246      * Initializes context.
       
   247      */
       
   248     void initialize();
       
   249 
       
   250     /** Context for esock library. */
       
   251     WlanQtUtilsCtxEsock esock_;
       
   252     /** Context for connmon library. */
       
   253     WlanQtUtilsCtxConnMon connMon_;
       
   254     /** Context for ICTS library. */
       
   255     WlanQtUtilsCtxIct ict_;
       
   256 };
       
   257 
       
   258 #endif // WLANQTUTILSTESTCONTEXT_H