|
1 /* |
|
2 * Copyright (c) 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 * T_casathandler.cpp |
|
19 * |
|
20 * Created on: 2009-09-16 |
|
21 * Author: |
|
22 */ |
|
23 |
|
24 |
|
25 #include "cadef.h" |
|
26 #include "ca2internalCRkeys.h" |
|
27 #include "T_casathandler.h" |
|
28 #include "casathandler.h" |
|
29 #include "e32property.h" |
|
30 |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 void T_CaSatHandler::testConstruction() |
|
37 { |
|
38 bool constructed(false); |
|
39 TRAPD(err, |
|
40 CCaSatHandler *satHandler = CCaSatHandler::NewL(); |
|
41 CleanupStack::PushL(satHandler); |
|
42 |
|
43 constructed = satHandler != NULL; |
|
44 |
|
45 CleanupStack::PopAndDestroy(satHandler); |
|
46 ); |
|
47 QCOMPARE(err, KErrNone); |
|
48 QVERIFY(constructed); |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void T_CaSatHandler::testGetName() |
|
56 { |
|
57 bool nameMatches(false); |
|
58 TRAPD(err, |
|
59 CCaSatHandler *satHandler = CCaSatHandler::NewL(); |
|
60 CleanupStack::PushL(satHandler); |
|
61 RBuf satName; |
|
62 satName.CleanupClosePushL(); |
|
63 satName.Create(KCenRepBufferSize); |
|
64 RProperty::Get(KCRUidCa, KCaSatUIName, satName); |
|
65 RBuf satHandlerName; |
|
66 satHandlerName.CleanupClosePushL(); |
|
67 satHandlerName.Create(KCenRepBufferSize); |
|
68 satHandler->GetName(satHandlerName); |
|
69 |
|
70 nameMatches = satHandlerName.Compare(satName) == 0; |
|
71 |
|
72 CleanupStack::PopAndDestroy(&satHandlerName); |
|
73 CleanupStack::PopAndDestroy(&satName); |
|
74 CleanupStack::PopAndDestroy(satHandler); |
|
75 ); |
|
76 QCOMPARE(err, KErrNone); |
|
77 QVERIFY(nameMatches); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void T_CaSatHandler::testCheckVisibility() |
|
85 { |
|
86 ; |
|
87 TInt visibility(KErrNone); |
|
88 RProperty::Get(KCRUidCa, KCaShowSatUI, visibility); |
|
89 TBool visibilityHandler = CCaSatHandler::CheckVisibility(); |
|
90 QCOMPARE(visibilityHandler, visibility); |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void T_CaSatHandler::testGetIcon() |
|
99 { |
|
100 // preconditions |
|
101 RProperty::Define( KCRUidCa, KCaSatUIIconId, RProperty::EInt ); |
|
102 |
|
103 bool loadIconResult(false); |
|
104 TInt setSizeResult(KErrNone); |
|
105 TRAPD(err, |
|
106 CCaSatHandler *satHandler = CCaSatHandler::NewL(); |
|
107 CleanupStack::PushL(satHandler); |
|
108 TInt iconId(KErrNone); |
|
109 User::LeaveIfError(RProperty::Get(KCRUidCa, KCaSatUIIconId, iconId)); |
|
110 if (iconId > 0) { |
|
111 CAknIcon *icon = NULL; |
|
112 icon = satHandler->LoadIconL(); |
|
113 CleanupStack::PushL(icon); |
|
114 loadIconResult = (icon != NULL); |
|
115 TSize size(1, 1); |
|
116 //TInt err = AknIconUtils::SetSize( icon->Bitmap(), size ) ; |
|
117 setSizeResult = AknIconUtils::SetSize(icon->Bitmap(), size); |
|
118 CleanupStack::PopAndDestroy(icon); |
|
119 } else { |
|
120 CAknIcon *icon = NULL; |
|
121 icon = satHandler->LoadIconL(); |
|
122 loadIconResult = (icon == NULL); |
|
123 } |
|
124 CleanupStack::PopAndDestroy(satHandler); |
|
125 ); |
|
126 |
|
127 QCOMPARE(err, KErrNone); |
|
128 QVERIFY(loadIconResult); |
|
129 QCOMPARE(setSizeResult, KErrNone); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void T_CaSatHandler::testGetBitmap() |
|
137 { |
|
138 CCaSatHandler *satHandler = CCaSatHandler::NewL(); |
|
139 CleanupStack::PushL(satHandler); |
|
140 RIconEf iIconEf; |
|
141 CleanupClosePushL(iIconEf); |
|
142 //CFbsBitmap* bitmap = satHandler->GetBitmapL( iIconEf ); |
|
143 //EUNIT_ASSERT( !bitmap ); |
|
144 CleanupStack::PopAndDestroy(&iIconEf); |
|
145 CleanupStack::PopAndDestroy(satHandler); |
|
146 } |
|
147 |
|
148 QTEST_MAIN(T_CaSatHandler); |