1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/contentmgmt/referencedrmagent/tcaf/source/SupplierStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,719 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <test/testexecutelog.h>
1.23 +#include <s32mem.h>
1.24 +#include "cafserver.h"
1.25 +#include "SupplierStep.h"
1.26 +#include "supplier.h"
1.27 +#include "cafmimeheader.h"
1.28 +#include "caferr.h"
1.29 +#include "metadataarray.h"
1.30 +#include "supplieroutputfile.h"
1.31 +#include "attribute.h"
1.32 +#include "bitset.h"
1.33 +
1.34 +#include <uri8.h>
1.35 +#ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
1.36 +#include <http.h>
1.37 +#include <http/rhttpsession.h>
1.38 +#include <http/rhttptransaction.h>
1.39 +#include <http/rhttpheaders.h>
1.40 +#endif
1.41 +
1.42 +using namespace ContentAccess;
1.43 +
1.44 +
1.45 +/*
1.46 + * This step imports a DCF file into CAF
1.47 + *
1.48 + */
1.49 +CCafSupplierStep::~CCafSupplierStep()
1.50 + {
1.51 + }
1.52 +
1.53 +CCafSupplierStep::CCafSupplierStep(CCAFServer& aParent) : iParent(aParent)
1.54 + {
1.55 + SetTestStepName(KCAFSupplierStep);
1.56 + }
1.57 +
1.58 +
1.59 +TVerdict CCafSupplierStep::doTestStepL()
1.60 + {
1.61 + SetTestStepResult(EInconclusive);
1.62 +
1.63 + RFs fs;
1.64 + RFile file;
1.65 + TBuf8 <128> readBuffer;
1.66 +
1.67 + INFO_PRINTF1(_L("Supplier Test - Agent provides output files"));
1.68 +
1.69 + TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType;
1.70 + TInt expectedLeave;
1.71 +
1.72 + // Get parameters from INI file
1.73 + GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
1.74 + GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
1.75 + GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
1.76 + GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
1.77 + GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
1.78 +
1.79 + StartApparcServerL();
1.80 +
1.81 + __UHEAP_MARK;
1.82 +
1.83 + HBufC8 *mime = ConvertDes16toHBufC8LC(mimeType);
1.84 +
1.85 + CCafMimeHeader *header = CCafMimeHeader::NewL(mime->Des());
1.86 + CleanupStack::PushL(header);
1.87 +
1.88 + CSupplier *mySupplier = CSupplier::NewLC();
1.89 + mySupplier->SetOutputDirectoryL(outputDirectory);
1.90 +
1.91 + // ignore return value, just exercises code for CCover
1.92 + mySupplier->IsImportSupported(header->StandardMimeData(EContentType));
1.93 +
1.94 + CImportFile *import = NULL;
1.95 + TRAPD(leaveResult, import = mySupplier->ImportFileL(*header, suggestedFileName));
1.96 + if(leaveResult != expectedLeave)
1.97 + {
1.98 + SetTestStepResult(EFail);
1.99 + }
1.100 + if(leaveResult == KErrNone)
1.101 + {
1.102 + CleanupStack::PushL(import);
1.103 +
1.104 + // read the input file and pass it to the CAF
1.105 + fs.Connect();
1.106 + CleanupClosePushL(fs);
1.107 +
1.108 + TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
1.109 + CleanupClosePushL(file);
1.110 + while(result == KErrNone)
1.111 + {
1.112 + result = file.Read(readBuffer);
1.113 + if(readBuffer.Length() == 0)
1.114 + break;
1.115 + User::LeaveIfError(import->WriteData(readBuffer));
1.116 + }
1.117 + CleanupStack::PopAndDestroy(&file);
1.118 + User::LeaveIfError(import->WriteDataComplete());
1.119 +
1.120 + TInt n = import->OutputFileCountL();
1.121 + for(TInt i = 0; i < n; i++)
1.122 + {
1.123 + // get output file name
1.124 + TPtrC OutputFileName = import->OutputFileL(i).FileName();
1.125 + INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
1.126 +
1.127 + // get output file type (content or receipt)
1.128 + TOutputType outputType = import->OutputFileL(i).OutputType();
1.129 +
1.130 + if(outputType == EReceipt)
1.131 + {
1.132 + INFO_PRINTF1(_L("Output File is a receipt"));
1.133 + }
1.134 + else
1.135 + {
1.136 + INFO_PRINTF1(_L("Output File is content"));
1.137 + }
1.138 +
1.139 + // get output file mime type
1.140 + TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
1.141 + HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
1.142 + INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
1.143 + CleanupStack::PopAndDestroy(mime);
1.144 + }
1.145 + CleanupStack::PopAndDestroy(&fs);
1.146 + CleanupStack::PopAndDestroy(import);
1.147 + }
1.148 + CleanupStack::PopAndDestroy(mySupplier);
1.149 + CleanupStack::PopAndDestroy(header);
1.150 + CleanupStack::PopAndDestroy(mime);
1.151 + __UHEAP_MARKEND;
1.152 +
1.153 + if (TestStepResult() != EFail)
1.154 + {
1.155 + SetTestStepResult(EPass);
1.156 + }
1.157 +
1.158 + return TestStepResult();
1.159 + }
1.160 +
1.161 +
1.162 +
1.163 +/*
1.164 + * This step imports a DCF file into CAF
1.165 + *
1.166 + */
1.167 +CCafSupplierAsyncStep::~CCafSupplierAsyncStep()
1.168 + {
1.169 + }
1.170 +
1.171 +CCafSupplierAsyncStep::CCafSupplierAsyncStep(CCAFServer& aParent) : iParent(aParent)
1.172 + {
1.173 + SetTestStepName(KCAFSupplierAsyncStep);
1.174 + }
1.175 +
1.176 +
1.177 +TVerdict CCafSupplierAsyncStep::doTestStepL()
1.178 + {
1.179 + SetTestStepResult(EInconclusive);
1.180 +
1.181 + RFs fs;
1.182 + RFile file;
1.183 + TBuf8 <128> readBuffer;
1.184 + TRequestStatus status;
1.185 +
1.186 + INFO_PRINTF1(_L("Asynchronous Supplier Test - Agent provides output files"));
1.187 +
1.188 + TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType;
1.189 + TInt expectedLeave;
1.190 +
1.191 + // Get parameters from INI file
1.192 + GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
1.193 + GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
1.194 + GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
1.195 + GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
1.196 + GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
1.197 +
1.198 + StartApparcServerL();
1.199 +
1.200 +
1.201 + __UHEAP_MARK;
1.202 +
1.203 + HBufC8 *mime = ConvertDes16toHBufC8LC(mimeType);
1.204 +
1.205 + CCafMimeHeader *header = CCafMimeHeader::NewL(mime->Des());
1.206 + CleanupStack::PushL(header);
1.207 +
1.208 + CSupplier *mySupplier = CSupplier::NewLC();
1.209 + mySupplier->SetOutputDirectoryL(outputDirectory);
1.210 +
1.211 + // ignore return value, just exercises code for CCover
1.212 + mySupplier->IsImportSupported(header->StandardMimeData(EContentType));
1.213 +
1.214 + CImportFile *import = NULL;
1.215 + TRAPD(leaveResult, import = mySupplier->ImportFileL(*header, suggestedFileName));
1.216 + if(leaveResult != expectedLeave)
1.217 + {
1.218 + SetTestStepResult(EFail);
1.219 + }
1.220 + if(leaveResult == KErrNone)
1.221 + {
1.222 + CleanupStack::PushL(import);
1.223 +
1.224 + // read the input file and pass it to the CAF
1.225 + fs.Connect();
1.226 + CleanupClosePushL(fs);
1.227 +
1.228 + TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
1.229 + CleanupClosePushL(file);
1.230 + while(result == KErrNone)
1.231 + {
1.232 + result = file.Read(readBuffer);
1.233 + if(readBuffer.Length() == 0)
1.234 + break;
1.235 + status = KRequestPending;
1.236 + import->WriteData(readBuffer,status);
1.237 + User::WaitForRequest(status);
1.238 + }
1.239 + CleanupStack::PopAndDestroy(&file);
1.240 + status = KRequestPending;
1.241 + import->WriteDataComplete(status);
1.242 + User::WaitForRequest(status);
1.243 +
1.244 + TInt n = import->OutputFileCountL();
1.245 + for(TInt i = 0; i < n; i++)
1.246 + {
1.247 + // get output file name
1.248 + TPtrC OutputFileName = import->OutputFileL(i).FileName();
1.249 + INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
1.250 +
1.251 + // get output file type (content or receipt)
1.252 + TOutputType outputType = import->OutputFileL(i).OutputType();
1.253 +
1.254 + if(outputType == EReceipt)
1.255 + {
1.256 + INFO_PRINTF1(_L("Output File is a receipt"));
1.257 + }
1.258 + else
1.259 + {
1.260 + INFO_PRINTF1(_L("Output File is content"));
1.261 + }
1.262 +
1.263 + // get output file mime type
1.264 + TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
1.265 + HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
1.266 + INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
1.267 + CleanupStack::PopAndDestroy(mime);
1.268 + }
1.269 +
1.270 + CleanupStack::PopAndDestroy(&fs);
1.271 + CleanupStack::PopAndDestroy(import);
1.272 + }
1.273 + CleanupStack::PopAndDestroy(mySupplier);
1.274 + CleanupStack::PopAndDestroy(header);
1.275 + CleanupStack::PopAndDestroy(mime);
1.276 + __UHEAP_MARKEND;
1.277 +
1.278 + if (TestStepResult() != EFail)
1.279 + {
1.280 + SetTestStepResult(EPass);
1.281 + }
1.282 +
1.283 + return TestStepResult();
1.284 + }
1.285 +
1.286 +
1.287 +
1.288 +/*
1.289 + * This step imports a DCF file into CAF
1.290 + *
1.291 + */
1.292 +CCafClientOutputSupplierStep::~CCafClientOutputSupplierStep()
1.293 + {
1.294 + }
1.295 +
1.296 +CCafClientOutputSupplierStep::CCafClientOutputSupplierStep(CCAFServer& aParent) : iParent(aParent)
1.297 + {
1.298 + SetTestStepName(KCAFClientOutputSupplierStep);
1.299 + }
1.300 +
1.301 +void CCafClientOutputSupplierStep::CheckContentMimeL(CImportFile* aImport, TDes8& aContentMime, TDesC8& aExpectedContentMime)
1.302 + {
1.303 + if(!aImport->ContentMimeTypeL(aContentMime))
1.304 + {
1.305 + //Agent can't determine the content MIME type with available data at the moment
1.306 +
1.307 + INFO_PRINTF1(_L("Content MIME Type can't be determined"));
1.308 + SetTestStepResult(EFail);
1.309 + return;
1.310 + }
1.311 +
1.312 +
1.313 + //If we reach here, we are expecting a correct Content MIME type
1.314 + HBufC *mime = ConvertDes8toHBufC16LC(aContentMime);
1.315 + INFO_PRINTF2(_L("Content MIME Type: %S"), mime);
1.316 + CleanupStack::PopAndDestroy(mime);
1.317 +
1.318 + if(aContentMime.CompareF(aExpectedContentMime) == 0)
1.319 + {
1.320 + SetTestStepResult(EPass);
1.321 + }
1.322 + else
1.323 + {
1.324 + ERR_PRINTF1(_L("Content MIME Type doesn't match expected"));
1.325 + SetTestStepResult(EFail);
1.326 + }
1.327 +
1.328 + }
1.329 +
1.330 +
1.331 +TVerdict CCafClientOutputSupplierStep::doTestStepL()
1.332 + {
1.333 + SetTestStepResult(EInconclusive);
1.334 +
1.335 + RFs fs;
1.336 + RFile file;
1.337 + TBuf8 <128> readBuffer;
1.338 + TBuf8 <255> mimetype8;
1.339 + TFileName outputFileName;
1.340 + RFile outputFile;
1.341 + CImportFile *import = NULL;
1.342 +
1.343 + // first output file will be a.txt
1.344 + _LIT(KOutputFileName, "C:\\something.drm");
1.345 + outputFileName.Copy(KOutputFileName);
1.346 +
1.347 + INFO_PRINTF1(_L("Supplier Test - Client provides output files"));
1.348 +
1.349 + TPtrC outputDirectory, sourceFileName, suggestedFileName, mimeType, expectedContentMime;
1.350 + TInt expectedLeave;
1.351 + TBool checkContentMime = EFalse;
1.352 + TBuf8<KMaxDataTypeLength> contentMimeType;
1.353 +
1.354 + // Get parameters from INI file
1.355 + GetStringFromConfig(ConfigSection(),_L("OutputPath"),outputDirectory);
1.356 + GetStringFromConfig(ConfigSection(),_L("SourceFileName"),sourceFileName);
1.357 + GetStringFromConfig(ConfigSection(),_L("SuggestedFileName"),suggestedFileName);
1.358 + GetStringFromConfig(ConfigSection(),_L("MimeType"),mimeType);
1.359 + GetIntFromConfig(ConfigSection(),_L("LeaveResult"),expectedLeave);
1.360 + GetStringFromConfig(ConfigSection(),_L("ExpectedContentMime"),expectedContentMime);
1.361 + GetBoolFromConfig(ConfigSection(),_L("CheckContentMime"),checkContentMime);
1.362 +
1.363 +
1.364 + StartApparcServerL();
1.365 +
1.366 + __UHEAP_MARK;
1.367 +
1.368 + mimetype8.Copy(mimeType);
1.369 +
1.370 + // fill in meta data - just the mime type really
1.371 + CMetaDataArray *array = CMetaDataArray::NewL();
1.372 + CleanupStack::PushL(array);
1.373 + _LIT8(KContentType,"content-type");
1.374 + array->AddL(KContentType(), mimetype8);
1.375 +
1.376 + // create a supplier session
1.377 + CSupplier *mySupplier = CSupplier::NewL();
1.378 + CleanupStack::PushL(mySupplier);
1.379 +
1.380 + // check import is supported, ignore return value, just exercises code for CCover
1.381 + mySupplier->IsImportSupported(array->SearchL(KContentType()));
1.382 +
1.383 + // create import session
1.384 + TRAPD(leaveResult, import = mySupplier->ImportFileL(mimetype8, *array));
1.385 + if(leaveResult != expectedLeave)
1.386 + {
1.387 + SetTestStepResult(EFail);
1.388 + }
1.389 + if(leaveResult == KErrNone)
1.390 + {
1.391 + CleanupStack::PushL(import);
1.392 +
1.393 + // read the input file and pass it to the CAF
1.394 + fs.Connect();
1.395 + CleanupClosePushL(fs);
1.396 + TInt result = file.Open(fs, sourceFileName, EFileRead | EFileStream | EFileShareAny);
1.397 + CleanupClosePushL(file);
1.398 +
1.399 + TParsePtrC parse(suggestedFileName);
1.400 + TPtrC desiredOutFileName( parse.Name() );
1.401 +
1.402 + while(result == KErrNone)
1.403 + {
1.404 + result = file.Read(readBuffer);
1.405 + if(readBuffer.Length() == 0)
1.406 + break;
1.407 + result = import->WriteData(readBuffer);
1.408 + while(result == KErrCANewFileHandleRequired)
1.409 + {
1.410 +
1.411 + if(checkContentMime)
1.412 + {
1.413 +
1.414 + //If CheckContentMimeL failed, Client code should assume content MIME type wouldn't
1.415 + //be available until after the supply session has finished. The imported data could be
1.416 + //output to default location
1.417 + //In this test step, data are always output to default location regardless of content MIME
1.418 + //type
1.419 + TBuf8<KMaxDataTypeLength> expectedContentMime8bit;
1.420 + expectedContentMime8bit.Copy(expectedContentMime);
1.421 + CheckContentMimeL(import, contentMimeType, expectedContentMime8bit);
1.422 + //no more check needed in following iterations
1.423 + checkContentMime = EFalse;
1.424 +
1.425 + //At this point client should decide where to save the file based on content mime
1.426 +
1.427 + }
1.428 +
1.429 + const TInt KMaxExtLen = 28;
1.430 + TBuf<KMaxExtLen> suggestedExt;
1.431 + User::LeaveIfError(import->GetSuggestedOutputFileExtension(suggestedExt));
1.432 + outputFileName.Copy(outputDirectory);
1.433 + outputFileName.Append(desiredOutFileName);
1.434 + outputFileName.Append(suggestedExt);
1.435 + // create a new outputfile
1.436 + fs.Delete(outputFileName);
1.437 + User::LeaveIfError(outputFile.Create(fs,outputFileName, EFileShareAny | EFileStream | EFileWrite));
1.438 + result = import->ContinueWithNewOutputFile(outputFile,outputFileName);
1.439 + outputFile.Close();
1.440 + }
1.441 + User::LeaveIfError(result);
1.442 + }
1.443 + CleanupStack::PopAndDestroy(&file);
1.444 + result = import->WriteDataComplete();
1.445 + while(result == KErrCANewFileHandleRequired)
1.446 + {
1.447 + TFileName suggestedName;
1.448 + User::LeaveIfError(import->GetSuggestedOutputFileName(suggestedName));
1.449 + outputFileName.Copy(outputDirectory);
1.450 + outputFileName.Append(suggestedName);
1.451 +
1.452 + // create a new outputfile
1.453 + fs.Delete(outputFileName);
1.454 + User::LeaveIfError(outputFile.Create(fs,outputFileName, EFileShareAny | EFileStream | EFileWrite));
1.455 + result = import->ContinueWithNewOutputFile(outputFile,outputFileName);
1.456 + outputFile.Close();
1.457 + }
1.458 +
1.459 +
1.460 + TInt n = import->OutputFileCountL();
1.461 + for(TInt i = 0; i < n; i++)
1.462 + {
1.463 + // get output file name
1.464 + TPtrC OutputFileName = import->OutputFileL(i).FileName();
1.465 + INFO_PRINTF2(_L("Output File Created: %S"),&OutputFileName);
1.466 +
1.467 + // get output file type (content or receipt)
1.468 + TOutputType outputType = import->OutputFileL(i).OutputType();
1.469 +
1.470 + if(outputType == EReceipt)
1.471 + {
1.472 + INFO_PRINTF1(_L("Output File is a receipt"));
1.473 + }
1.474 + else
1.475 + {
1.476 + INFO_PRINTF1(_L("Output File is content"));
1.477 + }
1.478 +
1.479 + // get output file mime type
1.480 + TPtrC8 OutputMimeType = import->OutputFileL(i).MimeTypeL();
1.481 + HBufC *mime = ConvertDes8toHBufC16LC(OutputMimeType );
1.482 + INFO_PRINTF2(_L("Output File Mime Type: %S"),mime);
1.483 + CleanupStack::PopAndDestroy(mime);
1.484 + }
1.485 + CleanupStack::PopAndDestroy(&fs);
1.486 + CleanupStack::PopAndDestroy(import);
1.487 + }
1.488 + CleanupStack::PopAndDestroy(mySupplier);
1.489 + CleanupStack::PopAndDestroy(array);
1.490 + __UHEAP_MARKEND;
1.491 +
1.492 + if (TestStepResult() != EFail)
1.493 + {
1.494 + SetTestStepResult(EPass);
1.495 + }
1.496 +
1.497 + return TestStepResult();
1.498 + }
1.499 +
1.500 +
1.501 +/*
1.502 + * This step tests the ExternalizeL() and InternalizeL() functions for
1.503 + * CCafMimeHeader
1.504 + */
1.505 +CCAFSupplierSerializeStep::~CCAFSupplierSerializeStep()
1.506 + {
1.507 + }
1.508 +
1.509 +CCAFSupplierSerializeStep::CCAFSupplierSerializeStep(CCAFServer& aParent) : iParent(aParent)
1.510 + {
1.511 + SetTestStepName(KCAFSupplierSerializeStep);
1.512 + }
1.513 +
1.514 +
1.515 +TVerdict CCAFSupplierSerializeStep::doTestStepL()
1.516 + {
1.517 + _LIT8(KDrmMime,"application/testagent.drm");
1.518 + _LIT8(KBinaryEncoding,"Binary");
1.519 + _LIT8(KOmaRightsPending, "X-Oma-Drm-Separate-Delivery");
1.520 + _LIT8(KOmaRightsPendingValue, "12");
1.521 +
1.522 + SetTestStepResult(EInconclusive); // Default result to EInconclusive
1.523 +
1.524 + __UHEAP_MARK;
1.525 +
1.526 + // create a CafMimeHeader with "content type:" application/testagent.drm
1.527 + CCafMimeHeader *header = CCafMimeHeader::NewL(KDrmMime());
1.528 + CleanupStack::PushL(header);
1.529 +
1.530 + // Add some information to the header
1.531 + header->SetStandardMimeDataL(EContentTransferEncoding, KBinaryEncoding());
1.532 + header->AddNonStandardMimeL(KOmaRightsPending(), KOmaRightsPendingValue());
1.533 +
1.534 + // Create a buffer stream
1.535 + CBufFlat* buf = CBufFlat::NewL(50);
1.536 + CleanupStack::PushL(buf);
1.537 + RBufWriteStream stream(*buf);
1.538 + CleanupClosePushL(stream);
1.539 +
1.540 + // call the stream function
1.541 + stream << *header;
1.542 + CleanupStack::PopAndDestroy(&stream);
1.543 +
1.544 + // Now, create an HBufC8 from the stream buf's length, and copy
1.545 + // the stream buffer into this descriptor
1.546 + HBufC8* des = HBufC8::NewL(buf->Size());
1.547 + TPtr8 ptr(des->Des());
1.548 + buf->Read(0, ptr, buf->Size());
1.549 +
1.550 + // destroy the buffer
1.551 + CleanupStack::PopAndDestroy(buf);
1.552 + CleanupStack::PushL(des);
1.553 +
1.554 + // Now, stream a new CCafMimeHeader from the descriptor
1.555 + CCafMimeHeader* newHeader = CCafMimeHeader::NewL(KNullDesC8());
1.556 + CleanupStack::PushL(newHeader);
1.557 + RDesReadStream readstream(*des);
1.558 + CleanupClosePushL(readstream);
1.559 + readstream >> *newHeader;
1.560 + CleanupStack::PopAndDestroy(&readstream);
1.561 +
1.562 + // Now check that the new bitset equals the old one
1.563 + TInt result = newHeader->StandardMimeData(EContentType).Compare(KDrmMime());
1.564 + if (result != 0)
1.565 + {
1.566 + INFO_PRINTF1(_L("Content type was not copied properly during seriaization"));
1.567 + SetTestStepResult(EFail);
1.568 + }
1.569 + result = newHeader->StandardMimeData(EContentTransferEncoding).Compare(KBinaryEncoding());
1.570 + if (result != 0)
1.571 + {
1.572 + INFO_PRINTF1(_L("Content Length was not copied properly during seriaization"));
1.573 + SetTestStepResult(EFail);
1.574 + }
1.575 +
1.576 + if (newHeader->NonStandardMimeCount() != 1)
1.577 + {
1.578 + INFO_PRINTF1(_L("Non standard field array not copied properly during seriaization"));
1.579 + SetTestStepResult(EFail);
1.580 + }
1.581 +
1.582 + result = newHeader->NonStandardMimeField(0).Compare(KOmaRightsPending());
1.583 + if (result != 0)
1.584 + {
1.585 + INFO_PRINTF1(_L("Non standard field not copied properly during seriaization"));
1.586 + SetTestStepResult(EFail);
1.587 + }
1.588 +
1.589 + result = newHeader->NonStandardMimeData(0).Compare(KOmaRightsPendingValue());
1.590 + if (result != 0)
1.591 + {
1.592 + INFO_PRINTF1(_L("Non standard field data was not copied properly during seriaization"));
1.593 + SetTestStepResult(EFail);
1.594 + }
1.595 +
1.596 + CleanupStack::PopAndDestroy(3, header);
1.597 +
1.598 + __UHEAP_MARKEND;
1.599 +
1.600 + if (TestStepResult() != EFail)
1.601 + {
1.602 + SetTestStepResult(EPass);
1.603 + }
1.604 +
1.605 + return TestStepResult();
1.606 + }
1.607 +
1.608 +#ifdef INTERNALLY_ENABLE_UPWARD_DEPENDENCY
1.609 +
1.610 +/*
1.611 + * Check that applications can retrieve the HTTP request headers
1.612 + */
1.613 +CCAFHTTPRequestHeadersStep::~CCAFHTTPRequestHeadersStep()
1.614 + {
1.615 + }
1.616 +
1.617 +CCAFHTTPRequestHeadersStep::CCAFHTTPRequestHeadersStep(CCAFServer& aParent) : iParent(aParent)
1.618 + {
1.619 + SetTestStepName(KCAFHTTPRequestHeadersStep);
1.620 + }
1.621 +
1.622 +
1.623 +void CCAFHTTPRequestHeadersStep::MHFRunL(RHTTPTransaction, const THTTPEvent&)
1.624 + {
1.625 +
1.626 + }
1.627 +
1.628 +TInt CCAFHTTPRequestHeadersStep::MHFRunError(TInt, RHTTPTransaction, const THTTPEvent&)
1.629 + {
1.630 + return 0;
1.631 + }
1.632 +
1.633 +
1.634 +TVerdict CCAFHTTPRequestHeadersStep::doTestStepL()
1.635 + {
1.636 + _LIT8(Kuri, "http://www.symbian.com/");
1.637 + TPtrC8 acceptHeader;
1.638 + TInt i = 0;
1.639 + TInt result = 0;
1.640 +
1.641 + SetTestStepResult(EInconclusive); // Default result to EInconclusive
1.642 + THTTPHdrVal aValue;
1.643 +
1.644 + __UHEAP_MARK;
1.645 +
1.646 + CSupplier* supplier = CSupplier::NewLC();
1.647 +
1.648 + // Create an HTTP session
1.649 + RHTTPSession session;
1.650 + session.OpenL();
1.651 + RStringPool pool = session.StringPool();
1.652 +
1.653 +
1.654 + // Convert the URI string into a TUri8
1.655 + TUriParser8 parser;
1.656 + parser.Parse(Kuri());
1.657 +
1.658 + // create an HTTP transaction
1.659 + RHTTPTransaction transaction = session.OpenTransactionL(parser, *this, pool.StringF(HTTP::EGET,RHTTPSession::GetTable()));
1.660 + RHTTPHeaders hdr = transaction.Request().GetHeaderCollection();
1.661 +
1.662 + // Get the request headers from the agent
1.663 + supplier->PrepareHTTPRequestHeaders(pool, hdr);
1.664 +
1.665 + TInt fieldParts = hdr.FieldPartsL(pool.StringF(HTTP::EAccept, RHTTPSession::GetTable()));
1.666 + if(fieldParts == 3)
1.667 + {
1.668 + for(i = 0; i < fieldParts; i++)
1.669 + {
1.670 + // loop over all accept headers make sure we find the three we expect
1.671 + User::LeaveIfError(hdr.GetField(pool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), i, aValue));
1.672 +
1.673 + RStringF header = (RStringF) aValue;
1.674 + acceptHeader.Set(header.DesC());
1.675 +
1.676 + // Reference Test Agent - content MIME type
1.677 + if(acceptHeader.Compare(_L8("application/x-rta.drm.content")) == 0)
1.678 + {
1.679 + result |= 1;
1.680 + }
1.681 + // Reference Test Agent - content + rights MIME type
1.682 + else if(acceptHeader.Compare(_L8("application/x-rta.drm.contentrights")) == 0)
1.683 + {
1.684 + result |= 2;
1.685 + }
1.686 + // Test Agent - MIME type
1.687 + else if(acceptHeader.Compare(_L8("APPLICATION/TESTAGENT.DRM")) == 0)
1.688 + {
1.689 + result |= 4;
1.690 + }
1.691 + }
1.692 + if(result != 7)
1.693 + {
1.694 + // not all three headers were found
1.695 + INFO_PRINTF1(_L("Not all expected HTTP Accept headers were present"));
1.696 + SetTestStepResult(EFail);
1.697 + }
1.698 + }
1.699 + else
1.700 + {
1.701 + // We were expecting three accept headers to be set
1.702 + // two from the Reference Test Agent and one from Test Agent
1.703 + INFO_PRINTF2(_L("ERROR: Only %d HTTP Accept headers were returned, expected 3"), fieldParts);
1.704 + SetTestStepResult(EFail);
1.705 + }
1.706 +
1.707 + transaction.Close();
1.708 + session.Close();
1.709 + CleanupStack::PopAndDestroy(supplier);
1.710 + __UHEAP_MARKEND;
1.711 +
1.712 + if (TestStepResult() != EFail)
1.713 + {
1.714 + SetTestStepResult(EPass);
1.715 + }
1.716 +
1.717 + return TestStepResult();
1.718 + }
1.719 +
1.720 +#endif
1.721 +
1.722 +