fep/frontendprocessor/test/src/TFepBaseTestServer.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Non-secure versions will be xxxServer.Dll and require a thread to be started
       
    15 // in the process of the client. The client initialises the server by calling the
       
    16 // one and only ordinal.
       
    17 // Creates a FEP test server to test the FEP key concepts:\n
       
    18 // FEP base, control input-capabilities, FEP-aware text editors, foreground observer,\n
       
    19 // and focus observer.
       
    20 // 
       
    21 //
       
    22 
       
    23 /**
       
    24  @file 
       
    25  @test
       
    26  @internalComponent - Internal Symbian test code
       
    27 */
       
    28 
       
    29 #include <basched.h>
       
    30 #include <eikenv.h>
       
    31 #include <eikappui.h>
       
    32 #include <techview/eikon.hrh>
       
    33 #include <eikapp.h>
       
    34 #include <eikdoc.h>
       
    35 #include <techview/eiklabel.h>
       
    36 #include <eikfctry.h>
       
    37 #include <coecntrl.h>
       
    38 #include <barsread.h>
       
    39 #include <techview/eiktbar.h>
       
    40 #include <techview/eikmenub.h>
       
    41 #include <eikspane.h>
       
    42 #include <test/testexecutestepbase.h>
       
    43 #include <test/testexecuteserverbase.h>
       
    44 #include <ecom/ecom.h>
       
    45 #include <test/testexecutelog.h>
       
    46 
       
    47 #include "TFepGen.h"
       
    48 #include "TAppMorse.h"
       
    49 #include "TFEP1TESTTARGET.h"
       
    50 #include "KEYBOARDLOGGER.H"
       
    51 #include "DEFOCUSING_EDWIN.h"
       
    52 
       
    53 _LIT(KServerName,"TFepBaseTestServer");
       
    54 
       
    55 
       
    56 //!  A Test Server for FEP base tests. 
       
    57 class CTFepBaseTestServer : public CTestServer
       
    58 	{
       
    59 public:
       
    60 	static CTFepBaseTestServer* NewL();
       
    61 	virtual CTestStep* CreateTestStep(const TDesC& aStepName);
       
    62 	};
       
    63 	
       
    64 	
       
    65 CTFepBaseTestServer* CTFepBaseTestServer::NewL()
       
    66 /**
       
    67   @return - Instance of the test server
       
    68   Same code for Secure and non-secure variants
       
    69   Called inside the MainL() function to create and start the
       
    70   CTestServer derived server.
       
    71  */
       
    72 	{
       
    73 	CTFepBaseTestServer * server = new (ELeave) CTFepBaseTestServer();
       
    74 	CleanupStack::PushL(server);
       
    75 	// CServer base class call
       
    76 	server->StartL(KServerName);
       
    77 	CleanupStack::Pop(server);
       
    78 	return server;
       
    79 	}
       
    80 
       
    81 
       
    82 LOCAL_C void MainL()
       
    83 /**
       
    84   Secure variant
       
    85   Much simpler, uses the new Rendezvous() call to sync with the client
       
    86 */
       
    87 	{
       
    88 	CActiveScheduler* sched=NULL;
       
    89 	sched=new(ELeave) CActiveScheduler;
       
    90 	CActiveScheduler::Install(sched);
       
    91 	CTFepBaseTestServer* server = NULL;
       
    92 	// Create the CTestServer derived server
       
    93 	TRAPD(err,server = CTFepBaseTestServer::NewL());
       
    94 	if(!err)
       
    95 		{
       
    96 		// Sync with the client and enter the active scheduler
       
    97 		RProcess::Rendezvous(KErrNone);
       
    98 		sched->Start();
       
    99 		}
       
   100 	delete server;
       
   101 	delete sched;
       
   102 	}
       
   103 
       
   104 GLDEF_C TInt E32Main()
       
   105 /**
       
   106   @return - Standard Epoc error code on process exit
       
   107   Secure variant only
       
   108   Process entry point. Called by client using RProcess API
       
   109 */
       
   110 	{
       
   111 	__UHEAP_MARK;
       
   112 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   113 	if(cleanup == NULL)
       
   114 		{
       
   115 		return KErrNoMemory;
       
   116 		}
       
   117 	TRAP_IGNORE(MainL());
       
   118 	delete cleanup;
       
   119 	REComSession::FinalClose();
       
   120 	__UHEAP_MARKEND;
       
   121 	return KErrNone;
       
   122     }
       
   123 
       
   124 
       
   125 
       
   126 CTestStep* CTFepBaseTestServer::CreateTestStep(const TDesC& aStepName)
       
   127 /**
       
   128   @return - A CTestStep derived instance
       
   129   Secure and non-secure variants
       
   130   Implementation of CTestServer pure virtual
       
   131  */
       
   132 	{
       
   133 	CTestStep* testStep = NULL;
       
   134 	// This server creates just one step but create as many as you want
       
   135 	// They are created "just in time" when the worker thread is created
       
   136 	if(aStepName == KTAppMorse)
       
   137 		{
       
   138 		testStep = new CTAppMorse();
       
   139 		}
       
   140 	if(aStepName == KTFepGen)
       
   141 		{
       
   142 		testStep = new CTFepGenStep();
       
   143 		}
       
   144 	if(aStepName == KFep1TestTargetStep)
       
   145 		{
       
   146 		testStep = new CTestFep1TargetStep();
       
   147 		}
       
   148 	if(aStepName == KKeyboardLoggerStep)
       
   149 		{
       
   150 		testStep = new CTestKeyboardLoggerStep();
       
   151 		}
       
   152 	if(aStepName == KDefocusingEdwinStep)
       
   153 		{
       
   154 		testStep = new CTestDefocusingEdwinStep();
       
   155 		}
       
   156 	
       
   157 	return testStep;
       
   158 	}