os/textandloc/fontservices/fontstore/tfs/TFntStoreServer.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @test
    22  @internalComponent Internal Symbian test code
    23 */
    24 
    25 #include "TFntStoreServer.h"
    26 #include "T_FNTMEM.H"
    27 #include "T_FSOPEN.H"
    28 #include "T_FontBitmap.H"
    29 #include "T_MatchFonts.h"
    30 #include "T_GlyphTreeDel.h"
    31 #include "T_OpenFontTypes.h"
    32 #include "T_FontMetrics.h"
    33 #include "T_GetNearestFont.h"
    34 #include "T_GetNearestFontCapability.h"
    35 #include "T_SetDefaultTypefaceName.h"
    36 #include "t_corruptfonts.h"
    37 #include "T_FNT.H" 
    38 #include "T_SHAPERCACHE.H"
    39 #include "T_LinkedFonts.h"
    40 #include "t_cachedeletion.h"
    41 #include "T_LinkedFonts2.h"
    42 #include "t_linkedfontsmemory.h"
    43 #include "t_linkedfontscomparison.h"
    44 #include "t_linkedfontscapability.h"
    45 #include "T_LinkedFontUpdateTests.h"
    46 #include "T_CACHE.H" 
    47 #include "T_FontSessionCache.h"
    48 
    49 CTFntStoreServer* CTFntStoreServer::NewL()
    50 /**
    51    @return - Instance of the test server
    52    Same code for Secure and non-secure variants
    53    Called inside the MainL() function to create and start the
    54    CTestServer derived server.
    55  */
    56 	{
    57 	CTFntStoreServer * server = new (ELeave) CTFntStoreServer();
    58 	CleanupStack::PushL(server);
    59 	
    60 	// Get server name from process so we can use SetCap to change the capabilites and use this server with a different filename
    61 	RProcess handle = RProcess();
    62 	TParsePtrC serverName(handle.FileName());
    63 	
    64 	// CServer base class call
    65 	server->StartL(serverName.Name());
    66 		
    67 	CleanupStack::Pop(server);
    68 	return server;
    69 	}
    70 
    71 
    72 LOCAL_C void MainL()
    73 //
    74 // Secure variant
    75 // Much simpler, uses the new Rendezvous() call to sync with the client
    76 //
    77 	{
    78  	RProcess().DataCaging(RProcess::EDataCagingOn);
    79 	RProcess().SecureApi(RProcess::ESecureApiOn);
    80 	CActiveScheduler* sched=NULL;
    81 	sched=new(ELeave) CActiveScheduler;
    82 	CActiveScheduler::Install(sched);
    83 	CTFntStoreServer* server = NULL;
    84 	// Create the CTestServer derived server
    85 	TRAPD(err,server = CTFntStoreServer::NewL());
    86 	if(!err)
    87 		{
    88 		// Sync with the client and enter the active scheduler
    89 		RProcess::Rendezvous(KErrNone);
    90 		sched->Start();
    91 		}
    92 	delete server;
    93 	delete sched;
    94 	}
    95 
    96 /** @return - Standard Epoc error code on process exit
    97     Secure variant only
    98     Process entry point. Called by client using RProcess API
    99 */
   100 GLDEF_C TInt E32Main()
   101 	{
   102 	__UHEAP_MARK;
   103 	CTrapCleanup* cleanup = CTrapCleanup::New();
   104 	if(cleanup == NULL)
   105 		{
   106 		return KErrNoMemory;
   107 		}
   108 	TRAPD(err,MainL());
   109 	if (err)
   110 	    {
   111 		RDebug::Print(_L("CTFntStoreServer::MainL - Error: %d"), err);
   112 	   	User::Panic(_L("CTFntStoreServer"),err);
   113 	    }
   114 	delete cleanup;
   115 	__UHEAP_MARKEND;
   116 	return KErrNone;
   117     }
   118 
   119 CTestStep* CTFntStoreServer::CreateTestStep(const TDesC& aStepName)
   120 /**
   121    @return - A CTestStep derived instance
   122    Secure and non-secure variants
   123    Implementation of CTestServer pure virtual
   124  */
   125 	{
   126 	if (aStepName == KTFntStep)
   127         {
   128         return new CTFntStep();
   129         }
   130 	else if(aStepName == KTFntMemStep)
   131 		{
   132 		return new CTFntMemStep();
   133 		}
   134 	else if(aStepName == KTFsOpenStep)
   135 		{
   136 		return new CTFsOpenStep();
   137 		}
   138 	else if(aStepName == KTFontBitmapStep)
   139 		{
   140 		return new CTFontBitmapStep();
   141 		}
   142 	else if(aStepName == KTMatchFontsStep)
   143 		{
   144 		return new CTMatchFontsStep();
   145 		}
   146 	else if(aStepName == KTGlyphTreeDelStep)
   147 		{
   148 		return new CTGlyphTreeDelStep();
   149 		}
   150 	else if(aStepName == KTOpenFontTypesStep)
   151 		{
   152 		return new CTOpenFontTypesStep();
   153 		}
   154 	else if(aStepName == KTFontMetricsStep)
   155 		{
   156 		return new CTFontMetricsStep();
   157 		}
   158 	else if(aStepName == KTGetNearestFontStep)
   159 		{
   160 		return new CTGetNearestFontStep();
   161 		}
   162 	else if(aStepName == KTGetNearestFontCapabilityStep)	// These tests have no capabilities and are expected to cause panics i.e. they will show up pass in the log files
   163 		{
   164 		return new CTGetNearestFontCapabilityStep();
   165 		}
   166 	else if(aStepName == KTSetDefaultTypefaceNameStep)	// These tests have no capabilities and are expected to cause panics i.e. they will show up pass in the log files
   167 		{
   168 		return new CTSetDefaultTypefaceNameStep();
   169 		}
   170 	else if(aStepName == KTCorruptFontRejectionStep)
   171 		{
   172 		return new CTCorruptFontRejectionStep();
   173 		}
   174 	else if(aStepName == KTShaperCacheStep)
   175 		{
   176 		return new CTShaperCacheStep();
   177 		}
   178 	else if (aStepName == KTCacheDeletionStep)	
   179 		{
   180 		return new CTCacheDeletionStep();
   181 		}
   182 	else if (aStepName == KTLinkedFonts2Step)
   183 		{
   184 		return new CTLinkedFonts2Step();
   185 		}
   186 	else if (aStepName == KTLinkedFontsMemoryStep)
   187 		{
   188         return new CTLinkedFontsMemoryStep();
   189         }
   190     else if (aStepName == KTLinkedFontsComparisonStep)
   191         {
   192         return new CTLinkedFontsComparisonStep();
   193         }
   194     else if (aStepName == KTLinkedFontsCapabilityStep)
   195         {
   196         return new CTLinkedFontsCapabilityStep();
   197         }
   198     else if (aStepName == KTLinkedFontsUpdateStage1Step)
   199         {
   200         return new CTLinkedFontsUpdateStage1Step();
   201         }
   202     else if (aStepName == KTLinkedFontsUpdateStage2Step)
   203         {
   204         return new CTLinkedFontsUpdateStage2Step();
   205         }
   206     else if (aStepName == KTCacheStep)
   207         {
   208         return new CTCacheStep();
   209         }
   210     else if (aStepName == KTFontSessionCacheStep)
   211         {
   212         return new CTFontSessionCacheStep();
   213         }
   214 	RDebug::Printf("Test Step is either mis-spelt or doesn't exist - see CTFntStoreServer::CreateTestStep");
   215 	return NULL;
   216 	}
   217