kerneltest/e32test/domainmgr/t_domain_manual.cpp
changeset 279 957c583b417b
equal deleted inserted replaced
275:2b433474f2ba 279:957c583b417b
       
     1 // Copyright (c) 2010 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 "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 // e32test/domainmgr/t_domain_manual.cpp
       
    15 //
       
    16 // Overview:
       
    17 // Domain Manager Manual test cases
       
    18 //
       
    19 
       
    20 #define __E32TEST_EXTENSION__
       
    21 
       
    22 #include <e32test.h>
       
    23 #include <e32ldr_private.h>
       
    24 
       
    25 #include "t_domain.h"
       
    26 
       
    27 
       
    28 RTest test(_L(" T_DOMAIN_MANUAL "));
       
    29 
       
    30 
       
    31 class CDmShutdownTest : public MDmTest
       
    32 	{
       
    33 public:
       
    34 	virtual ~CDmShutdownTest()
       
    35 		{
       
    36 		iManager.Close();
       
    37 		}
       
    38 	void Perform();
       
    39 	void Release();
       
    40 	TInt TransitionNotification(MDmDomainMember&)
       
    41 		{
       
    42 		test(0);
       
    43 		return KErrNone;
       
    44 		}
       
    45 	void TransitionRequestComplete()
       
    46 		{}
       
    47 private:
       
    48 	RDmDomainManager iManager;
       
    49 	};
       
    50 
       
    51 
       
    52 void CDmShutdownTest::Perform()
       
    53 	{
       
    54 	test.Next(_L("CDmShutdownTest"));
       
    55 
       
    56 	// 1. Set up test hierarchy/domain & join it
       
    57 	const TInt r = iManager.Connect();
       
    58 	test_KErrNone(r);
       
    59 
       
    60 	// 2. Call the Shutdown API
       
    61 	iManager.SystemShutdown();
       
    62 
       
    63 	test(0);	// Never reaches here!
       
    64 	}
       
    65 
       
    66 
       
    67 void CDmShutdownTest::Release()
       
    68 	{
       
    69 	delete this;
       
    70 	}
       
    71 
       
    72 
       
    73 ///////////////////////////////////////////////////////////////////////////////
       
    74 // --- Main() ---
       
    75 
       
    76 GLDEF_C TInt E32Main()
       
    77 	{
       
    78 	CTrapCleanup* trapHandler = CTrapCleanup::New();
       
    79 	test(trapHandler != NULL);
       
    80 
       
    81 	CActiveScheduler* scheduler = new CActiveScheduler();
       
    82 	test(scheduler != NULL);
       
    83 	CActiveScheduler::Install(scheduler);
       
    84 
       
    85 	// Turn off evil lazy dll unloading
       
    86 	RLoader l;
       
    87 	test(l.Connect() == KErrNone);
       
    88 	test(l.CancelLazyDllUnload()== KErrNone);
       
    89 	l.Close();
       
    90 
       
    91 	test.Title();
       
    92 
       
    93 	test.Start(_L("Test starting..."));
       
    94 
       
    95 	// Remember the number of open handles. Just for a sanity check
       
    96 	TInt start_thc, start_phc;
       
    97 	RThread().HandleCount(start_phc, start_thc);
       
    98 
       
    99 	MDmTest* tests[] =
       
   100 		{
       
   101 		// Always the last manual test as it shuts down the board/emulator
       
   102 		new CDmShutdownTest(),
       
   103 		};
       
   104 
       
   105 	for (unsigned int i = 0; i < sizeof(tests)/sizeof(*tests); ++i)
       
   106 		{
       
   107 		test(tests[i] != NULL);
       
   108 		tests[i]->Perform();
       
   109 		tests[i]->Release();
       
   110 		}
       
   111 
       
   112 	test.End();
       
   113 
       
   114 	// Sanity check for open handles and for pending requests
       
   115 	TInt end_thc, end_phc;
       
   116 	RThread().HandleCount(end_phc, end_thc);
       
   117 	test(start_thc == end_thc);
       
   118 	test(start_phc == end_phc);
       
   119 	test(RThread().RequestCount() >= 0);
       
   120 
       
   121 	delete scheduler;
       
   122 	delete trapHandler;
       
   123 
       
   124 	return KErrNone;
       
   125 	}