os/security/contentmgmt/referencedrmagent/tsmoke/smoke.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/referencedrmagent/tsmoke/smoke.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,180 @@
     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 <ecom/ecom.h>
    1.23 +#include <caf/content.h>
    1.24 +#include <caf/data.h>
    1.25 +
    1.26 +#include "smoke.h"
    1.27 +#include <ecom/implementationinformation.h>
    1.28 +
    1.29 +using namespace ContentAccess;
    1.30 +
    1.31 +CTestConsole* CTestConsole::NewL(CConsoleBase* aCon)
    1.32 +{
    1.33 +  CTestConsole* self;
    1.34 +  self=new (ELeave) CTestConsole;
    1.35 +  self->iCon=aCon;
    1.36 +  self->iFile=NULL;
    1.37 +  return self;
    1.38 +}
    1.39 +
    1.40 +CTestConsole::CTestConsole(void):CConsoleBase()
    1.41 +{}
    1.42 +
    1.43 +CTestConsole::~CTestConsole(void)
    1.44 +{
    1.45 +  delete iCon;
    1.46 +  if (iFile)
    1.47 +    {
    1.48 +      iFile->Close();
    1.49 +    }
    1.50 +}
    1.51 +
    1.52 +void CTestConsole::Write(const TDesC16& aString)
    1.53 +{
    1.54 +  iCon->Write(aString);
    1.55 +  if (iFile)
    1.56 +    {
    1.57 +      TUint8 space[200];
    1.58 +      TPtr8 ptr(space,200);
    1.59 +      ptr.Copy(aString);
    1.60 +      iFile->Write(ptr);
    1.61 +    }
    1.62 +}
    1.63 +
    1.64 +void CTestConsole::SetLogFile(RFile* aFile)
    1.65 +{
    1.66 +  iFile=aFile;
    1.67 +}
    1.68 +
    1.69 +RTest test(_L("CAF Build Test"));
    1.70 +
    1.71 +void RunTest1(void)
    1.72 +{
    1.73 +  test.Start(_L(" @SYMTestCaseID:SEC-CAF-SMOKE-0001 CAF Test "));		 
    1.74 +
    1.75 +  CTestConsole* con=NULL;
    1.76 +  TRAPD(ret, con=CTestConsole::NewL(test.Console()));
    1.77 +  RFs fs;
    1.78 +  
    1.79 +  fs.Connect();
    1.80 +  RFile* file;
    1.81 +  file=new (ELeave) RFile;
    1.82 +  
    1.83 +  file->Replace(fs,_L("c:\\DRMLog.txt"),EFileShareAny|EFileWrite);
    1.84 +  con->SetLogFile(file);
    1.85 +  test.SetConsole(con);
    1.86 +  
    1.87 +  const TUid KInterfaceUID = {0x101FC2CE};
    1.88 +
    1.89 +  RImplInfoPtrArray aImplInfoArray;
    1.90 +
    1.91 +  // do here
    1.92 +  test.Printf(_L("\nCAF Test Starting\n"));
    1.93 +  test.Getch();
    1.94 +
    1.95 +  test.Printf(_L("Ready to get implementations of %08X\n"),KInterfaceUID);
    1.96 +  //test.Getch();
    1.97 +
    1.98 +  __UHEAP_MARK; // start heap debug
    1.99 +  
   1.100 +  REComSession::ListImplementationsL(KInterfaceUID , aImplInfoArray);
   1.101 +
   1.102 +  TUint count = aImplInfoArray.Count();
   1.103 +  CImplementationInformation *infoptr = aImplInfoArray[0];
   1.104 +
   1.105 +  TBufC<30> temp = infoptr->DisplayName();
   1.106 +  test.Printf(_L("Found %d agent implementation(s).\n"),count);
   1.107 +  test.Printf(_L("Name: %S\n"),&temp);
   1.108 +  test.Getch();
   1.109 +
   1.110 +  // Need to delete implementation array
   1.111 +  aImplInfoArray.ResetAndDestroy();
   1.112 +
   1.113 +  /*
   1.114 +  TUid key;
   1.115 +  TAgentCreationParams params;
   1.116 +  params.iURIPtr    = &temp;
   1.117 +  params.iIntentPtr = &temp;
   1.118 +
   1.119 +  // Note that we have no idea about the real type of CAgent...
   1.120 +    CAgent *agent = 
   1.121 +	reinterpret_cast<CAgent *>(REComSession::CreateImplementationL(KF32ImplementationUID, 
   1.122 +																   key,
   1.123 +																   (TAny*)&params));
   1.124 +  TUint major=0, minor=0;
   1.125 +  agent->Version(major, minor);
   1.126 +  test.Printf(_L("\nVersion (key %d) returned %d:%d\n"),key,major,minor);
   1.127 +  delete agent;
   1.128 +  REComSession::DestroyedImplementation(key);
   1.129 +  */
   1.130 +
   1.131 +  _LIT(KDummyContent,"c:\\dummy.txt");
   1.132 +  test.Printf(_L("Hit enter to create content object (accessing %S)...\n"),&KDummyContent);
   1.133 +  test.Getch();
   1.134 +
   1.135 +  CContent *myContent = 0; ret = 0;
   1.136 +
   1.137 +  TRAP(ret, myContent = CContent::NewL(KDummyContent));
   1.138 +  if (ret)
   1.139 +	  {
   1.140 +	  test.Printf(_L("Content create failed (%d)..."),ret);
   1.141 +	  test.Getch();
   1.142 +	  }
   1.143 +  
   1.144 +  test.Printf(_L("Hit enter to create data object..."),ret);
   1.145 +  test.Getch();
   1.146 +
   1.147 +  CData *myData = NULL;
   1.148 +
   1.149 +  TRAP(ret, myData = myContent->OpenContentL(EPeek));
   1.150 +
   1.151 +  if (ret)
   1.152 +	  {
   1.153 +	  test.Printf(_L("Data create failed (%d)..."),ret);
   1.154 +	  test.Getch();
   1.155 +	  }
   1.156 +
   1.157 +  TInt mySize;
   1.158 +  myData->DataSizeL(mySize);
   1.159 +  test.Printf(_L("\nAgent reports data size as %d bytes\n"),mySize);
   1.160 +  test.Getch();
   1.161 +
   1.162 +  test.Printf(_L("\nTest Ending\n"));
   1.163 +  test.Getch();
   1.164 +  __UHEAP_MARKEND; // end heap debug
   1.165 +  
   1.166 +  test.End();
   1.167 +  test.Close();
   1.168 +}
   1.169 +
   1.170 +
   1.171 +GLDEF_C TInt E32Main(void)
   1.172 +{
   1.173 +  CTrapCleanup* cleanup;
   1.174 +  cleanup = CTrapCleanup::New();
   1.175 +  // CActiveScheduler* s = new CActiveScheduler;
   1.176 +  // s->Install(s);
   1.177 +  
   1.178 +  TRAP_IGNORE(RunTest1());
   1.179 +  
   1.180 +  
   1.181 +  delete cleanup;
   1.182 +  return(KErrNone);
   1.183 +}