dosservices/tsrc/public/basic/dosservertestplugin/src/Tfdosplugin.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2004 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 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <tftestmacros.h>
       
    21 #include <ctfatestenvironment.h>
       
    22 #include <psvariables.h>
       
    23 #include "dosenums.h"
       
    24 #include "siftrace.h"
       
    25 #include "ctfdosplugin.h"
       
    26 #include "ctfdoscontrol.h"
       
    27 #include "ctfdoscontroltestcaseparam.h"
       
    28 #include "ctfdoscontroltestcase.h"
       
    29 #include <psvariables.h>
       
    30 
       
    31 static void SharedDataUseCaseSuiteL( CTFATestSuite* aSuite );
       
    32 
       
    33 static void ExtensionUseCaseSuiteL( CTFATestSuite* aSuite );
       
    34 
       
    35 
       
    36 
       
    37 /***************************** Extension *********************************/  
       
    38 // DOSSERVER [Open and Close Extension]
       
    39 // Opens and closes the extension service.
       
    40 // Tested function:
       
    41 //   - RDosExtension::Open()
       
    42 //   - RDosExtension::Close()																					
       
    43 const TTFDosServerControlTestCaseState KTFExtensionOpenCloseStates[2] =
       
    44     {
       
    45         { ETFDosExtension_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    46         { ETFDosExtension_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
    47     };
       
    48 
       
    49 // DOSSERVER [Call Function Sync]
       
    50 // Tests sync CallFunction with invalid parameter.
       
    51 // Tested function:
       
    52 //   - RDosExtension::CallFunction() ( sync )
       
    53 const TTFDosServerControlTestCaseState KTFExtensionInvalidSyncCallFunctionStates[3] =
       
    54     {
       
    55         { ETFDosExtension_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    56         { ETFDosExtension_CallFunction, 500, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    57         { ETFDosExtension_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
    58     };
       
    59 
       
    60 // DOSSERVER [Call Function Async]
       
    61 // Tests async CallFunction with invalid parameter.
       
    62 // Tested function:
       
    63 //   - RDosExtension::CallFunction() ( async )
       
    64 const TTFDosServerControlTestCaseState KTFExtensionInvalidAsyncCallFunctionStates[3] =
       
    65     {
       
    66         { ETFDosExtension_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    67         { ETFDosExtension_CallFunctionAndComplete, 600, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    68         { ETFDosExtension_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
    69     };
       
    70 
       
    71 // DOSSERVER [General Event]
       
    72 // Tests async CallFunction with invalid parameter.
       
    73 const TTFDosServerControlTestCaseState KTFExtensionGeneralEventStates[4] =
       
    74     {
       
    75         { ETFDosExtension_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    76         { ETFDosExtension_GeneralEvent, KLDSYDummyEvent, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    77         { ETFDosEvent_Synchronized, 5, 0, KErrNone, ETFDOSDummyEvent, ETFDosFlags_IgnoreUnexpectedEvents },
       
    78         { ETFDosExtension_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
    79     };
       
    80 
       
    81 // DOSSERVER [General Event Array]
       
    82 const TTFDosServerControlTestCaseState KTFExtensionGeneralEventArrayStates[4] =
       
    83     {
       
    84         { ETFDosExtension_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    85         { ETFDosExtension_GeneralEventArray, KLDSYDummyEvent, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
    86         { ETFDosEvent_Synchronized, 5, 0, KErrNone, ETFDOSDummyEvent, ETFDosFlags_IgnoreUnexpectedEvents },
       
    87         { ETFDosExtension_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
    88     };
       
    89 
       
    90 
       
    91 /***************************** SharedData *********************************/   
       
    92 // DOSSERVER [Open and Close SharedData]
       
    93 // Opens and closes the SharedData service.
       
    94 // Tested function:
       
    95 //   - RDosSharedData::Open()
       
    96 //   - RDosSharedData::Close()
       
    97 const TTFDosServerControlTestCaseState KTFSharedDataOpenCloseStates[2] = 
       
    98     {
       
    99         { ETFDosSharedData_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   100         { ETFDosSharedData_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
   101     };
       
   102           
       
   103 // DOSSERVER [SharedData - RequestFreeDiskSpace]
       
   104 // Fill the diskspace and request 256kb of free diskspace from SharedData
       
   105 // Tested function:
       
   106 //	 - RDosSharedData::RequestFreeDiskSpace()
       
   107 const TTFDosServerControlTestCaseState KTFSharedDataRequestFreeDiskSpace[9] = 
       
   108     {
       
   109         { ETFDosSharedData_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   110         { ETFRFs_Connect, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents | ETFDosFlags_IgnoreParameters },
       
   111         { ETFDosSharedData_FillDisk, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   112         { ETFDosSharedData_CheckDiskSpace, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreParameters },
       
   113         { ETFDosSharedData_RequestFreeDiskSpace, 256, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents},
       
   114         { ETFDosSharedData_CheckDiskSpace, 256, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreParameters },
       
   115         { ETFDosSharedData_ReleaseDisk, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   116         { ETFRFs_Close,   0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents | ETFDosFlags_IgnoreParameters },
       
   117         { ETFDosSharedData_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents }
       
   118     };
       
   119 
       
   120 // DOSSERVER [SharedData - RequestFreeDiskSpaceCancel]
       
   121 // Fill the diskspace, request 128kb of free diskspace and cancel the request
       
   122 // Tested function:
       
   123 //	 - RDosSharedData::RequestFreeDiskSpaceCancel()
       
   124 const TTFDosServerControlTestCaseState KTFSharedDataRequestFreeDiskSpaceCancel[10] = 
       
   125     {
       
   126         { ETFDosSharedData_Open, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   127         { ETFRFs_Connect, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents | ETFDosFlags_IgnoreParameters },
       
   128         { ETFDosSharedData_FillDisk, 64, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   129         { ETFDosSharedData_CheckDiskSpace, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreParameters },
       
   130         { ETFDosSharedData_RequestFreeDiskSpace, 256, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents},
       
   131         { ETFDosSharedData_RequestFreeDiskSpaceCancel, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents},
       
   132         { ETFDosSharedData_Close, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   133         { ETFDosSharedData_CheckDiskSpace, 0, 1, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreParameters },
       
   134         { ETFDosSharedData_ReleaseDisk, 0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents },
       
   135         { ETFRFs_Close,   0, 0, KErrNone, ETFDosEvent_None, ETFDosFlags_IgnoreUnexpectedEvents | ETFDosFlags_IgnoreParameters }
       
   136     };
       
   137 
       
   138 // C++ default constructor can NOT contain any code, that
       
   139 // might leave.
       
   140 //
       
   141 CTFDosPlugin::CTFDosPlugin( TAny* aInitParams )
       
   142 : iInitParams( ( CTFStubModuleInterface::TInterfaceInitParams* ) aInitParams )
       
   143 	{
       
   144 	}
       
   145 
       
   146 // Two-phased constructor.
       
   147 CTFDosPlugin* CTFDosPlugin::NewL( TAny* aInitParams )
       
   148 	{
       
   149 	return new ( ELeave ) CTFDosPlugin( aInitParams );
       
   150 	}
       
   151 
       
   152 // Destructor.
       
   153 CTFDosPlugin::~CTFDosPlugin()
       
   154 	{
       
   155     iInitParams = NULL;
       
   156 	}
       
   157 
       
   158 
       
   159 CTFStub* CTFDosPlugin::GetStubL( void )
       
   160     {
       
   161     return new ( ELeave ) CTFDosControl();
       
   162     }
       
   163 
       
   164 
       
   165 void CTFDosPlugin::BuildTestSuiteL( CTFATestSuite* aRootSuite )
       
   166     {
       
   167     // Memory checks are disabled since DSY runs in separate thread and heap.
       
   168     aRootSuite->Environment().SetTestCaseFlags( ETFMayLeakMemory | ETFMayLeakRequests | ETFMayLeakHandles );
       
   169     TF_START_TEST_DECLARATION_L( aRootSuite );
       
   170         // Use case test cases
       
   171         TF_ADD_TEST_SUITE_L( _L( "Use Case Tests" ) );
       
   172             TF_ADD_TEST_SUITE_FUNCTION_L( _L( "SharedData Tests" ), SharedDataUseCaseSuiteL );            
       
   173             TF_ADD_TEST_SUITE_FUNCTION_L( _L( "Extension" ), ExtensionUseCaseSuiteL );
       
   174         TF_END_TEST_SUITE();
       
   175     TF_END_TEST_DECLARATION();
       
   176     }
       
   177 
       
   178 
       
   179 MTFStubTestCase* CTFDosPlugin::GetStubTestCaseL( TInt aTestCaseId )
       
   180     {
       
   181     TF_START_STUB_TEST_CASES( aTestCaseId );
       
   182 
       
   183 	
       
   184 	TF_DOS_SERVER_CONTROL_TEST_CASE_L( 1, KTFSharedDataOpenCloseStates ) ;
       
   185 		
       
   186 	TF_DOS_SERVER_CONTROL_TEST_CASE_L( 2, KTFSharedDataRequestFreeDiskSpace ) ;
       
   187 		
       
   188 	TF_DOS_SERVER_CONTROL_TEST_CASE_L( 3, KTFSharedDataRequestFreeDiskSpaceCancel ) ;	
       
   189 
       
   190     TF_DOS_SERVER_CONTROL_TEST_CASE_L( 4, KTFExtensionOpenCloseStates ) ;
       
   191     
       
   192     TF_DOS_SERVER_CONTROL_TEST_CASE_L( 5, KTFExtensionInvalidSyncCallFunctionStates ) ;
       
   193     
       
   194     TF_DOS_SERVER_CONTROL_TEST_CASE_L( 6, KTFExtensionInvalidAsyncCallFunctionStates ) ;
       
   195     
       
   196     TF_DOS_SERVER_CONTROL_TEST_CASE_L( 7, KTFExtensionGeneralEventStates ) ;
       
   197     
       
   198     TF_DOS_SERVER_CONTROL_TEST_CASE_L( 8, KTFExtensionGeneralEventArrayStates ) ;        
       
   199     
       
   200   TF_END_STUB_TEST_CASES();
       
   201     }
       
   202     
       
   203 
       
   204 
       
   205 static void SharedDataUseCaseSuiteL( CTFATestSuite* aSuite )
       
   206 	{
       
   207 	TF_INIT_TEST_SUITE_FUNCTION( aSuite );
       
   208 	TF_ADD_TEST_CASE_L( 1, _L( "DOSSERVER [Open and Close SharedData]" ) );
       
   209 	TF_ADD_TEST_CASE_L( 2, _L( "DOSSERVER [SharedData - Request]" ) );
       
   210 	TF_ADD_TEST_CASE_L( 3, _L( "DOSSERVER [SharedData - Cancel Request]" ) );
       
   211 	}
       
   212 
       
   213 static void ExtensionUseCaseSuiteL( CTFATestSuite* aSuite )
       
   214     {
       
   215     TF_INIT_TEST_SUITE_FUNCTION( aSuite );
       
   216     TF_ADD_TEST_CASE_L( 4, _L( "DOSSERVER [Open and Close Extension]" ) );
       
   217     TF_ADD_TEST_CASE_L( 5, _L( "DOSSERVER [Call Function Sync]" ) );
       
   218     TF_ADD_TEST_CASE_L( 6, _L( "DOSSERVER [Call Function Async]" ) );
       
   219     TF_ADD_TEST_CASE_L( 7, _L( "DOSSERVER [General Event]" ) );
       
   220     TF_ADD_TEST_CASE_L( 8, _L( "DOSSERVER [General Event Array]" ) );
       
   221     }
       
   222 
       
   223 // End of File