usbmgmt/usbmgrtest/t_usbmanager_suite/mscc/src/CUsbMsTestStep.cpp
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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 <e32std.h>
       
    20 #include <cusbclasscontrolleriterator.h>
       
    21 #include "CUsbMsTestStep.h"
       
    22 #include <musbclasscontrollernotify.h>
       
    23 
       
    24 class TNotify : public MUsbClassControllerNotify
       
    25 	{
       
    26 	CUsbClassControllerIterator* UccnGetClassControllerIteratorL(){return 0;}			
       
    27 	void UccnError(TInt /*Error*/){}
       
    28 	} owner;
       
    29 	
       
    30 TVerdict CConfigItemTest::doTestStepL()
       
    31 	{
       
    32 	INFO_PRINTF1(_L("CConfigItemTest::doTestStepL"));
       
    33 	SetTestStepResult(EPass);
       
    34 
       
    35 	TPtrC origString;
       
    36 	TPtrC expectedString;
       
    37 	TInt stringLength;
       
    38 	if(	!GetStringFromConfig(ConfigSection(), _L("origString"), origString) ||
       
    39 	   	!GetStringFromConfig(ConfigSection(), _L("expectedString"), expectedString) ||
       
    40 	   	!GetIntFromConfig(ConfigSection(), _L("stringLength"), stringLength))
       
    41 		{
       
    42 		INFO_PRINTF1(_L("Failed to get init data"));
       
    43 		SetTestStepResult(EFail);
       
    44 		return TestStepResult();
       
    45 		}
       
    46 
       
    47 	// Create an active scheduler
       
    48 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    49 	CleanupStack::PushL(sched);
       
    50 	CActiveScheduler::Install(sched);
       
    51 
       
    52 	CUsbMsClassController* controller = CUsbMsClassController::NewL(owner);
       
    53 	
       
    54 	CleanupStack::PopAndDestroy(sched);
       
    55 	
       
    56 	TBuf<64> copiedString;
       
    57 	controller->ConfigItem(origString, copiedString, stringLength);
       
    58 	delete controller;
       
    59 
       
    60 	TEST(copiedString.Compare(expectedString) == 0);
       
    61 
       
    62 	return TestStepResult();
       
    63 	}
       
    64 
       
    65 TVerdict CReadMsConfigTest::doTestStepL()
       
    66 	{
       
    67 	INFO_PRINTF1(_L("CReadMsConfigTest::doTestStepL"));
       
    68 	SetTestStepResult(EPass);
       
    69 	
       
    70 	TPtrC vendorId;
       
    71 	TPtrC productId;
       
    72 	TPtrC productRev;
       
    73 	
       
    74 	if(	!GetStringFromConfig(ConfigSection(), _L("vendorId"), vendorId) ||
       
    75 	   	!GetStringFromConfig(ConfigSection(), _L("productId"), productId) ||
       
    76 	   	!GetStringFromConfig(ConfigSection(), _L("productRev"), productRev))
       
    77 		{
       
    78 		INFO_PRINTF1(_L("Failed to get init data"));
       
    79 		SetTestStepResult(EFail);
       
    80 		return TestStepResult();
       
    81 		}
       
    82 	
       
    83 	// Create an active scheduler
       
    84 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    85 	CleanupStack::PushL(sched);
       
    86 	CActiveScheduler::Install(sched);
       
    87 	
       
    88 	CUsbMsClassController* controller = CUsbMsClassController::NewL(owner);
       
    89 	CleanupStack::PushL(controller);
       
    90 	
       
    91 	controller->ReadMassStorageConfigL();
       
    92 	
       
    93 	// Do comparison
       
    94 	TEST(controller->iMsConfig.iVendorId.Compare(vendorId) == 0 &&
       
    95 		controller->iMsConfig.iProductId.Compare(productId) == 0  &&
       
    96 		controller->iMsConfig.iProductRev.Compare(productRev) == 0);
       
    97 
       
    98 		
       
    99 	// controller and sched
       
   100 	CleanupStack::PopAndDestroy(2);
       
   101 	
       
   102 	return TestStepResult();
       
   103 	}
       
   104