|
1 // Copyright (c) 2001-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 // The unit test class implementations for the CBackupNotifier class. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "BackupNotifierUnitTest.h" |
|
19 |
|
20 // ______________________________________________________________________________ |
|
21 // |
|
22 _LIT(KBackupNotifierCreateAndDestroyUnitTest,"CBackupNotifier_CreateAndDestroy_UnitTest"); |
|
23 |
|
24 CBackupNotifier_CreateAndDestroy_UnitTest* CBackupNotifier_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, |
|
25 MUnitTestObserver& aObserver) |
|
26 { |
|
27 CBackupNotifier_CreateAndDestroy_UnitTest* self = |
|
28 new(ELeave) CBackupNotifier_CreateAndDestroy_UnitTest(aDataLogger, |
|
29 aObserver); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 inline TInt CBackupNotifier_CreateAndDestroy_UnitTest::RunError(TInt aError) |
|
37 { |
|
38 // The RunL left so chain to the base first and then cleanup |
|
39 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
40 delete iUTContext; |
|
41 iUTContext = NULL; |
|
42 delete iStateAccessor; |
|
43 iStateAccessor = NULL; |
|
44 /* delete any validators used */ |
|
45 delete iCtorValidator; |
|
46 iCtorValidator = NULL; |
|
47 delete iDtorValidator; |
|
48 iDtorValidator = NULL; |
|
49 return error; |
|
50 } |
|
51 |
|
52 inline CBackupNotifier_CreateAndDestroy_UnitTest::~CBackupNotifier_CreateAndDestroy_UnitTest() |
|
53 { |
|
54 // Simply delete our test class instance |
|
55 delete iUTContext; |
|
56 delete iStateAccessor; |
|
57 /* delete any validators used */ |
|
58 delete iCtorValidator; |
|
59 delete iDtorValidator; |
|
60 } |
|
61 |
|
62 inline CBackupNotifier_CreateAndDestroy_UnitTest::CBackupNotifier_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, |
|
63 MUnitTestObserver& aObserver) |
|
64 : CUnitTest(KBackupNotifierCreateAndDestroyUnitTest, aDataLogger, aObserver) |
|
65 { |
|
66 //Do nothing |
|
67 } |
|
68 |
|
69 // Now the Individual transitions need to be added. |
|
70 inline void CBackupNotifier_CreateAndDestroy_UnitTest::ConstructL() |
|
71 { |
|
72 // Perform the base class initialization |
|
73 UnitTestConstructL(); |
|
74 |
|
75 // Create the Unit test state accessor |
|
76 iStateAccessor = new(ELeave) TBackupNotifier_StateAccessor; |
|
77 // Construct the Unit test context. |
|
78 iUTContext = new(ELeave) CBackupNotifier_UnitTestContext(iDataLogger, *iStateAccessor, *this); |
|
79 iUTContext->iStub = new(ELeave) CNotificationStub(iDataLogger); |
|
80 // Add the Transitions in the order they are to run |
|
81 // C'tor first, D'tor last... |
|
82 iCtorValidator = new(ELeave) TBackupNotifier_Ctor_TransitionValidator(*iUTContext); |
|
83 AddTransitionL(new(ELeave)CBackupNotifier_NewL_Transition(*iUTContext,*iCtorValidator)); |
|
84 iDtorValidator = new(ELeave) TBackupNotifier_Dtor_TransitionValidator(*iUTContext); |
|
85 AddTransitionL(new(ELeave)CBackupNotifier_Dtor_Transition(*iUTContext,*iDtorValidator)); |
|
86 } |
|
87 |