localisation/apparchitecture/tef/TStartDocApp.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2005-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Supporting application for use by T_StartDocStep.cpp
       
    15 // The implementation of CR PHAR-5NTCWY removes the 256 character limit
       
    16 // on the length of document names.
       
    17 // This application is designed to be started by test code calling
       
    18 // RApaLsSession::StartDocument(const TDesC& aFileName, TThreadId& aId,
       
    19 // TLaunchType aLaunchType=ELaunchNewApp)
       
    20 // passing a document name (first parameter) that is longer than
       
    21 // 256 characters.
       
    22 // The test passes if this application is started with a document name
       
    23 // that is longer than 256 characters.
       
    24 // 
       
    25 //
       
    26 
       
    27 
       
    28 
       
    29 /**
       
    30  @file
       
    31  @internalComponent - Internal Symbian test code
       
    32 */
       
    33 
       
    34 #include <eikenv.h>
       
    35 #include <eikappui.h>
       
    36 #include <eikapp.h>
       
    37 #include <eikdoc.h>
       
    38 
       
    39 #include <eikstart.h>
       
    40 
       
    41 #include "TStartDoc.h"
       
    42 
       
    43 const TUid KUidTStartDocApp = { 0x10004c4d };
       
    44 
       
    45 enum TStartDocAppPanic
       
    46 	{
       
    47 	EPanicDocNameCheck1Failed,
       
    48 	EPanicDocNameCheck1NotExecuted,
       
    49 	EPanicDocNameCheck2Failed,
       
    50 	};
       
    51 
       
    52 void Panic(TStartDocAppPanic aPanic)
       
    53 //
       
    54 // Panic the process with TESTFAILED as the category.
       
    55 //
       
    56 	{
       
    57 	_LIT(KPanicCategory,"TESTFAILED");
       
    58 	User::Panic(KPanicCategory, aPanic);
       
    59 	}
       
    60 
       
    61 
       
    62 ////////////////////////////////////////////////////////////////////////
       
    63 //
       
    64 // CStartDocAppUi
       
    65 //
       
    66 ////////////////////////////////////////////////////////////////////////
       
    67 class CStartDocAppUi : public CEikAppUi
       
    68     {
       
    69 public:
       
    70     void ConstructL();
       
    71 	~CStartDocAppUi();
       
    72 public:
       
    73 	TBool DocNameCheck1Executed() const;
       
    74 	// from CEikAppUi
       
    75 	TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail);
       
    76 private:
       
    77 	TBool iDocNameCheck1Executed;
       
    78 	};
       
    79 
       
    80 
       
    81 void CStartDocAppUi::ConstructL()
       
    82     {
       
    83     BaseConstructL(ENoAppResourceFile | ENoScreenFurniture);
       
    84 	}
       
    85 
       
    86 CStartDocAppUi::~CStartDocAppUi()
       
    87 	{
       
    88 	}
       
    89 
       
    90 TBool CStartDocAppUi::DocNameCheck1Executed() const
       
    91 	{
       
    92 	return iDocNameCheck1Executed;
       
    93 	}
       
    94 
       
    95 TBool CStartDocAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName& aDocumentName, const TDesC8& /*aTail*/)
       
    96 	{
       
    97 	if (aDocumentName != KLitLongURL)
       
    98 		{
       
    99 		Panic(EPanicDocNameCheck1Failed);
       
   100 		}
       
   101 	iDocNameCheck1Executed = ETrue;
       
   102 	return EFalse; // don't try to open the document
       
   103 	}
       
   104 
       
   105 
       
   106 ////////////////////////////////////////////////////////////////////////
       
   107 //
       
   108 // CStartDocDocument
       
   109 //
       
   110 ////////////////////////////////////////////////////////////////////////
       
   111 class CStartDocDocument : public CEikDocument
       
   112 	{
       
   113 public:
       
   114 	static CStartDocDocument* NewL(CEikApplication& aApp);
       
   115 	CStartDocDocument(CEikApplication& aApp);
       
   116 	void ConstructL();
       
   117 	CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
       
   118 private: 
       
   119 	// from CEikDocument
       
   120 	CEikAppUi* CreateAppUiL();
       
   121 	};
       
   122 
       
   123 CStartDocDocument::CStartDocDocument(CEikApplication& aApp)
       
   124 		: CEikDocument(aApp)
       
   125 	{
       
   126 	}
       
   127 
       
   128 CEikAppUi* CStartDocDocument::CreateAppUiL()
       
   129 	{
       
   130     return new(ELeave) CStartDocAppUi;
       
   131 	}
       
   132 
       
   133 CFileStore* CStartDocDocument::OpenFileL(TBool /*aDoOpen*/,const TDesC& /*aFilename*/,RFs& /*aFs*/)
       
   134 	{
       
   135 	if (!(static_cast<CStartDocAppUi*>(CEikonEnv::Static()->EikAppUi())->DocNameCheck1Executed()))
       
   136 		{
       
   137 		Panic(EPanicDocNameCheck1NotExecuted);
       
   138 		}
       
   139 	/** the process main doc filename should have been set by the framework by the time
       
   140 	    this function is called, so check it's been sucessfully set to a value that's
       
   141 	    longer than 256 characters
       
   142 	    (this tests the new CApaProcess::SetMainDocFileNameL API)
       
   143 	*/
       
   144 	  if (Process()->MainDocFileName() != KLitLongURL)
       
   145 		{
       
   146 		Panic(EPanicDocNameCheck2Failed);
       
   147 		}
       
   148 	// by exiting the app here with KTStartDocTestPassed, we ensure the test cannot pass
       
   149 	// in cases where something leaves during app startup
       
   150 	User::After(10000000); // ensure that the test harness gets a chance to logon to us
       
   151 	User::Exit(KTStartDocTestPassed);
       
   152 	return NULL; // just to keep the compiler happy
       
   153 	}
       
   154 
       
   155 
       
   156 ////////////////////////////////////////////////////////////////////////
       
   157 //
       
   158 // CStartDocApplication
       
   159 //
       
   160 ////////////////////////////////////////////////////////////////////////
       
   161 class CStartDocApplication : public CEikApplication
       
   162 	{
       
   163 private: 
       
   164 	// from CApaApplication
       
   165 	CApaDocument* CreateDocumentL();
       
   166 	TUid AppDllUid() const;
       
   167 private:
       
   168 	TFileName ResourceFileName() const;
       
   169 private:
       
   170 	CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); }
       
   171 	//
       
   172 	};
       
   173 
       
   174 CApaDocument* CStartDocApplication::CreateDocumentL()
       
   175 	{
       
   176 	return new (ELeave) CStartDocDocument(*this);
       
   177 	}
       
   178 
       
   179 TUid CStartDocApplication::AppDllUid() const
       
   180 	{
       
   181 	return KUidTStartDocApp;
       
   182 	}
       
   183 
       
   184 TFileName CStartDocApplication::ResourceFileName() const
       
   185 	{
       
   186 	return TFileName(); // this app doesn't have a resource file
       
   187 	}
       
   188 
       
   189 
       
   190 LOCAL_C CApaApplication* NewApplication()
       
   191 	{
       
   192 	return new CStartDocApplication;
       
   193 	}
       
   194 	
       
   195 GLDEF_C TInt E32Main()
       
   196 	{
       
   197 	return EikStart::RunApplication(NewApplication);
       
   198 	}
       
   199