os/ossrv/lowlevellibsandfws/apputils/multipartparser/test/tef/smoketest/src/mppsmoketeststeps.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // mppSmokeTestStepsDom.cpp
    15 // 
    16 //
    17 
    18 
    19 #include "mppsmoketeststeps.h"
    20 
    21 #include <e32svr.h>
    22 #include <e32def.h>
    23 
    24 #include <xml/parser.h>
    25 #include <xml/parserfeature.h>
    26 
    27 //#include <string.h>
    28 #include <charconv.h>
    29 #include <utf.h>
    30 #include <bautils.h>
    31 
    32 	
    33 TVerdict CParseBase64Encoding::doTestStepL()
    34 	{
    35 	CMultipartTestContainer* tester = CMultipartTestContainer::NewLC(Logger());
    36 
    37 	TBool success;
    38 	TPtrC inputFile;
    39 	success = GetStringFromConfig(ConfigSection(), _L("InputFile"), inputFile);
    40 	if (success == EFalse)
    41 		{
    42 		User::Leave(KErrArgument);
    43 		}
    44 	RFs fs;
    45 	fs.Connect();
    46 	success = BaflUtils::FileExists(fs, inputFile);
    47 	if (success == EFalse)
    48 		{
    49 		User::Leave(KErrArgument);
    50 		}
    51 	fs.Close();	
    52 	TPtrC url;
    53 	success = GetStringFromConfig(ConfigSection(), _L("Url"), url);	
    54 	if (success == EFalse)
    55 		{
    56 		User::Leave(KErrArgument);
    57 		}
    58 	TPtrC outputFile;
    59 	success = GetStringFromConfig(ConfigSection(), _L("OutputFile"), outputFile);
    60 	if (success == EFalse)
    61 		{
    62 		User::Leave(KErrArgument);
    63 		}
    64 	
    65 	TInt ret;
    66 	TRAP(ret, tester->ParseFileL(inputFile, url, outputFile));
    67 	if (ret != KErrNone)
    68 		{
    69 		User::Leave(KErrGeneral);
    70 		}
    71 
    72 	// find out if the test passed or failed
    73 	TPtrC filename1;
    74 	success = GetStringFromConfig(ConfigSection(), _L("CompareFile1"), filename1);	
    75 	if (success == EFalse)
    76 		{
    77 		User::Leave(KErrArgument);
    78 		}
    79 	TPtrC filename2;
    80 	success = GetStringFromConfig(ConfigSection(), _L("CompareFile2"), filename2);
    81 	if (success == EFalse)
    82 		{
    83 		User::Leave(KErrArgument);
    84 		}
    85 	TBool skipWhitespace = EFalse;
    86 	success = GetBoolFromConfig(ConfigSection(), _L("SkipWhitespace"), skipWhitespace);
    87 	if (success == EFalse)
    88 		{
    89 		User::Leave(KErrArgument);
    90 		}
    91 	
    92 	ret = tester->CompareFilesL(filename1, filename2, skipWhitespace);
    93 
    94    fs.Connect();
    95    CleanupClosePushL(fs);
    96    //Must not be read-only on hardware or files cannot be
    97    //  deleted, set attr in .iby file. 
    98    User::LeaveIfError(fs.Delete(outputFile));
    99    CleanupStack::PopAndDestroy(1, &fs);
   100    fs.Close();
   101 	
   102 	CleanupStack::PopAndDestroy(1);
   103 	if (ret == KErrNone)
   104 		 {
   105 		 SetTestStepResult(EPass);
   106 		 return EPass;
   107 		 }		
   108 	else
   109 		 {
   110 		 SetTestStepResult(EFail);
   111 		 INFO_PRINTF2(_L("CompareFiles error code: %d"), ret);
   112 		 return EFail;
   113 		 }			
   114 	}
   115 
   116 
   117 
   118