common/tools/ats/smoketest/localisation/apparchitecture/tef/TSTAPP.H
changeset 793 0c32c669a39d
child 872 17498133d9ad
equal deleted inserted replaced
792:893b85cda81b 793:0c32c669a39d
       
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code 
       
    22 */
       
    23 
       
    24 #ifndef __TSTAPP_H__
       
    25 #define __TSTAPP_H__
       
    26 
       
    27 #if !defined(__APPARC_H__)
       
    28 #include <apparc.h>
       
    29 #endif
       
    30 
       
    31 #include <eikapp.h>
       
    32 #include <eikdoc.h>
       
    33 #include <apgdoor.h>
       
    34 #include <eikappui.h>
       
    35 
       
    36 // classes defined:
       
    37 class CTestApp;
       
    38 class CTestAppDoc;
       
    39 //
       
    40 
       
    41 #define KTestAppDefaultFileName _L("TestApp.doc")
       
    42 const TInt KTestAppUidValue=10;
       
    43 const TUid KUidTestApp={KTestAppUidValue};
       
    44 const TUid KUidTestAppHeadStream={200};
       
    45 const TInt KNarrowRelUidValue=268435578;
       
    46 const TUid KUidNarrowRel={KNarrowRelUidValue}; // so it'll run under arm...
       
    47 #define KTestAppUidType TUidType(KUidNarrowRel,KUidApp,KUidTestApp)
       
    48 
       
    49 
       
    50 class CTestApp : public CEikApplication
       
    51 	{
       
    52 public:
       
    53 	static CTestApp* NewL(); // the gated function
       
    54 	// from CApaApplication
       
    55 	void PreDocConstructL();
       
    56 	CEikDocument* CreateDocumentL();
       
    57 	TDesC& Caption(); // return the app title in current system language
       
    58 	TUid AppDllUid()const;
       
    59 	
       
    60 	CDictionaryStore* OpenIniFileLC(RFs& aFs)const;
       
    61 	void Capability(TDes8& aInfo)const;
       
    62 	~CTestApp();
       
    63 
       
    64 private:
       
    65 	CTestApp();
       
    66 	void ConstructL();
       
    67 	
       
    68 private:
       
    69 	TBuf<8> iCaption;
       
    70 	RFs iFs;
       
    71 	};
       
    72 
       
    73 class CBasicAppUi : public CEikAppUi
       
    74 	{
       
    75 public:
       
    76 	inline CBasicAppUi() {}
       
    77 private:
       
    78 	virtual void ConstructL();
       
    79 	};
       
    80 
       
    81 class CTestAppDoc : public CEikDocument, public MApaEmbeddedDocObserver
       
    82 	{
       
    83 public:
       
    84 	static CTestAppDoc* NewL(CEikApplication& aApp);
       
    85 	~CTestAppDoc();
       
    86 
       
    87 	inline void EmbedNewDocL(const TApaApplicationFactory& aTestFac); // exported so I can call it from testcode
       
    88 	inline void EditEmbeddedDocL(TInt aDocNum) {EmbeddedDoor(aDocNum)->DocumentL()->EditL(this);}
       
    89 	inline CApaDoor* EmbeddedDoor(TInt aDocNum)const {return (CApaDoor*)((*iEmbedList)[aDocNum].iPicture.AsPtr());}
       
    90 	virtual CEikAppUi* CreateAppUiL();
       
    91 	
       
    92 // from MApaEmbeddedDocObserver
       
    93 	void NotifyExit(MApaEmbeddedDocObserver::TExitMode aMode);
       
    94 // from CApaDocument
       
    95 	void NewDocumentL(); 
       
    96 	CFileStore* CreateFileStoreLC(RFs& aFs,const TDesC& aFileName);
       
    97 	void SaveL();
       
    98 	//
       
    99 	void PrintL(const CStreamStore& aSourceStore);
       
   100 	void EditL(MApaEmbeddedDocObserver* aContainer,TBool aReadOnly); 
       
   101 	TBool IsEmpty()const; // return ETrue if the document is empty
       
   102 	TBool HasChanged()const;
       
   103 	//
       
   104 	// storage functions
       
   105 	void StoreL(CStreamStore& aStore,CStreamDictionary& aStreamDic)const;
       
   106 	void RestoreL(const CStreamStore& aStore,const CStreamDictionary& aStreamDic);
       
   107 	void DetachFromStoreL(CPicture::TDetach aDegree);
       
   108 
       
   109 protected:
       
   110 	CTestAppDoc(CEikApplication& aApp);
       
   111 	void ConstructL();
       
   112 
       
   113 	void InternalizeL(RReadStream& aStream);
       
   114 	void ExternalizeL(RWriteStream& aStream)const;
       
   115 	void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const;
       
   116 	void RestoreComponentsL(const CStreamStore& aStore);
       
   117 
       
   118 	// utility functions
       
   119 public:
       
   120 	TInt iValue; // the "contents" of this test document
       
   121 	CArrayFixFlat<TPictureHeader>* iEmbedList;
       
   122 	CStreamStore* iStore;
       
   123 	TBool iHasChanged;
       
   124 	};
       
   125 
       
   126 inline void CTestAppDoc::EmbedNewDocL(const TApaApplicationFactory& aTestFac)
       
   127 	{
       
   128 	TPictureHeader header;
       
   129 	header.iPictureType = KUidPictureTypeDoor;
       
   130 
       
   131 	CApaDocument* doc=Process()->AddNewDocumentL(aTestFac);
       
   132 
       
   133 	RFs& fs=Process()->FsSession();
       
   134 	header.iPicture = CApaDoor::NewLC(fs,*doc,TSize(500,500));
       
   135 
       
   136 	iEmbedList->AppendL(header);
       
   137 	CleanupStack::Pop(); // iPicture
       
   138 	}
       
   139 
       
   140 
       
   141 #endif