|
1 /* |
|
2 * Copyright (c) 2010- 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 the License "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 #include "ut_swhandlerplugin.h" |
|
19 #include <digia/eunit/eunitmacros.h> |
|
20 #include <digia/eunit/eunitdecorators.h> |
|
21 |
|
22 #include "swhandlerplugin.h" |
|
23 #include <AknServerApp.h> |
|
24 #include <e32def.h> |
|
25 |
|
26 NONSHARABLE_CLASS( UT_CSwHandlerPluginTestObserver ) : public MAknServerAppExitObserver |
|
27 { |
|
28 public: |
|
29 inline UT_CSwHandlerPluginTestObserver() { iObserverCalled = EFalse; iReason = 0; } |
|
30 virtual void HandleServerAppExit(TInt aReason); |
|
31 |
|
32 inline TBool WasObserverCalled() const { return iObserverCalled; } |
|
33 inline TInt Reason() const { return iReason; } |
|
34 private: |
|
35 TBool iObserverCalled; |
|
36 TInt iReason; |
|
37 }; |
|
38 |
|
39 void UT_CSwHandlerPluginTestObserver::HandleServerAppExit(TInt aReason) |
|
40 { |
|
41 iObserverCalled = ETrue; |
|
42 iReason = aReason; |
|
43 } |
|
44 |
|
45 // - Construction ----------------------------------------------------------- |
|
46 |
|
47 UT_CSwHandlerPlugin* UT_CSwHandlerPlugin::NewL() |
|
48 { |
|
49 UT_CSwHandlerPlugin* self = UT_CSwHandlerPlugin::NewLC(); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 UT_CSwHandlerPlugin* UT_CSwHandlerPlugin::NewLC() |
|
55 { |
|
56 UT_CSwHandlerPlugin* self = new( ELeave ) UT_CSwHandlerPlugin(); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 UT_CSwHandlerPlugin::~UT_CSwHandlerPlugin() |
|
63 { |
|
64 } |
|
65 |
|
66 UT_CSwHandlerPlugin::UT_CSwHandlerPlugin() |
|
67 { |
|
68 } |
|
69 |
|
70 void UT_CSwHandlerPlugin::ConstructL() |
|
71 { |
|
72 CEUnitTestSuiteClass::ConstructL(); |
|
73 } |
|
74 |
|
75 // - Test methods ----------------------------------------------------------- |
|
76 |
|
77 |
|
78 |
|
79 void UT_CSwHandlerPlugin::SetupL( ) |
|
80 { |
|
81 iCSwHandlerPlugin = CSwHandlerPlugin::NewL(); |
|
82 } |
|
83 |
|
84 |
|
85 void UT_CSwHandlerPlugin::Teardown( ) |
|
86 { |
|
87 delete iCSwHandlerPlugin; |
|
88 iCSwHandlerPlugin = NULL; |
|
89 } |
|
90 |
|
91 |
|
92 void UT_CSwHandlerPlugin::T_Global_HandleUrlEmbeddedLL( ) |
|
93 { |
|
94 EUNIT_ASSERT_NO_LEAVE(iCSwHandlerPlugin->HandleUrlEmbeddedL( )); |
|
95 } |
|
96 |
|
97 void UT_CSwHandlerPlugin::T_Global_HandleUrlStandaloneLL( ) |
|
98 { |
|
99 EUNIT_ASSERT_NO_LEAVE(iCSwHandlerPlugin->HandleUrlStandaloneL( )); |
|
100 } |
|
101 |
|
102 void UT_CSwHandlerPlugin::T_Global_ObserverL( ) |
|
103 { |
|
104 UT_CSwHandlerPluginTestObserver testObserver; |
|
105 |
|
106 iCSwHandlerPlugin->Observer(&testObserver); |
|
107 |
|
108 EUNIT_ASSERT_NO_LEAVE(iCSwHandlerPlugin->HandleUrlEmbeddedL()); |
|
109 |
|
110 EUNIT_ASSERT( testObserver.WasObserverCalled()); |
|
111 |
|
112 EUNIT_ASSERT_EQUALS( KErrNone, testObserver.Reason() ); |
|
113 } |
|
114 |
|
115 |
|
116 // - EUnit test table ------------------------------------------------------- |
|
117 |
|
118 EUNIT_BEGIN_TEST_TABLE( |
|
119 UT_CSwHandlerPlugin, |
|
120 "Tests the Sw Handler Plugin which launches IAD client based on a URL scheme.", |
|
121 "UNIT" ) |
|
122 |
|
123 EUNIT_TEST( |
|
124 "HandleUrlEmbeddedL - test0", |
|
125 "CSwHandlerPlugin", |
|
126 "HandleUrlEmbeddedL - test0", |
|
127 "FUNCTIONALITY", |
|
128 SetupL, T_Global_HandleUrlEmbeddedLL, Teardown) |
|
129 |
|
130 EUNIT_TEST( |
|
131 "HandleUrlStandaloneL - test1", |
|
132 "CSwHandlerPlugin", |
|
133 "HandleUrlStandaloneL - test1", |
|
134 "FUNCTIONALITY", |
|
135 SetupL, T_Global_HandleUrlStandaloneLL, Teardown) |
|
136 |
|
137 EUNIT_TEST( |
|
138 "Observer - test2", |
|
139 "CSwHandlerPlugin", |
|
140 "Observer - test2", |
|
141 "FUNCTIONALITY", |
|
142 SetupL, T_Global_ObserverL, Teardown) |
|
143 |
|
144 |
|
145 EUNIT_END_TEST_TABLE |