|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <eikstart.h> |
|
23 #include <fbs.h> |
|
24 |
|
25 #include "tbitmap.h" |
|
26 |
|
27 |
|
28 // |
|
29 // |
|
30 // CBitmapAppUi |
|
31 // |
|
32 // |
|
33 |
|
34 CBitmapAppUi::CBitmapAppUi() : CTestAppUi(NULL, KNullDesC) |
|
35 { |
|
36 } |
|
37 |
|
38 void CBitmapAppUi::ConstructL() |
|
39 { |
|
40 CTestAppUi::ConstructL(); |
|
41 AutoTestManager().StartAutoTest(); |
|
42 } |
|
43 |
|
44 CBitmapAppUi::~CBitmapAppUi() |
|
45 { |
|
46 } |
|
47 |
|
48 void CBitmapAppUi::HandleCommandL(TInt /*aCommand*/) |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 void CBitmapAppUi::TestCreateBitmapL() |
|
54 { |
|
55 _LIT(KApplicationDefaultBitmapPath,"z:\\resource\\apps\\tbitmap.mbm"); |
|
56 _LIT(KFileNameWildCharacterDoubleQuote,"*"); |
|
57 |
|
58 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
59 |
|
60 CFbsBitmap* appDefaultBitmap = eikonEnv->CreateBitmapL(KApplicationDefaultBitmapPath,0); |
|
61 CleanupStack::PushL(appDefaultBitmap); |
|
62 CFbsBitmap* WildCharacterBitmapDoubleQuote = eikonEnv->CreateBitmapL(KFileNameWildCharacterDoubleQuote, 0); |
|
63 CleanupStack::PushL(WildCharacterBitmapDoubleQuote); |
|
64 |
|
65 CompareBitmapsL(*appDefaultBitmap, *WildCharacterBitmapDoubleQuote, EColor16M); |
|
66 |
|
67 CleanupStack::PopAndDestroy(2, appDefaultBitmap); |
|
68 } |
|
69 |
|
70 |
|
71 void CBitmapAppUi::CompareBitmapsL(CFbsBitmap& aBmp1,CFbsBitmap& aBmp2,TDisplayMode aDispMode) const |
|
72 { |
|
73 const TSize bmpSize = aBmp1.SizeInPixels(); |
|
74 if (!(bmpSize == aBmp2.SizeInPixels())) |
|
75 { |
|
76 RProcess().Terminate(KErrBitMapDoesNotMatch); |
|
77 } |
|
78 |
|
79 RBuf8 buf1; |
|
80 CleanupClosePushL(buf1); |
|
81 buf1.CreateL(bmpSize.iWidth * 4); |
|
82 RBuf8 buf2; |
|
83 CleanupClosePushL(buf2); |
|
84 buf2.CreateL(bmpSize.iWidth * 4); |
|
85 |
|
86 for (TInt row = 0; row < bmpSize.iHeight; row++) |
|
87 { |
|
88 aBmp1.GetScanLine(buf1, TPoint(0,row), bmpSize.iWidth, aDispMode); |
|
89 aBmp2.GetScanLine(buf2, TPoint(0,row), bmpSize.iWidth, aDispMode); |
|
90 const TInt ret = buf1.Compare(buf2); |
|
91 if (ret != 0) |
|
92 { |
|
93 CleanupStack::PopAndDestroy(2, &buf1); |
|
94 RProcess().Terminate(KErrBitMapDoesNotMatch); |
|
95 } |
|
96 } |
|
97 CleanupStack::PopAndDestroy(2, &buf1); |
|
98 } |
|
99 |
|
100 void CBitmapAppUi::RunTestStepL(TInt aNumStep) |
|
101 { |
|
102 switch(aNumStep) |
|
103 { |
|
104 case 1: |
|
105 { |
|
106 TRAPD(err, TestCreateBitmapL()); |
|
107 if (err != KErrNone) |
|
108 { |
|
109 RProcess().Terminate(err); |
|
110 } |
|
111 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
112 break; |
|
113 } |
|
114 default: |
|
115 break; |
|
116 } |
|
117 |
|
118 } |
|
119 |
|
120 // |
|
121 // |
|
122 // CBitmapDocument |
|
123 // |
|
124 // |
|
125 CBitmapDocument::CBitmapDocument(CEikApplication& aApp) |
|
126 : CEikDocument(aApp) |
|
127 { |
|
128 } |
|
129 |
|
130 CEikAppUi* CBitmapDocument::CreateAppUiL() |
|
131 { |
|
132 return new (ELeave) CBitmapAppUi(); |
|
133 } |
|
134 |
|
135 |
|
136 // |
|
137 // |
|
138 // CBitmapApplication |
|
139 // |
|
140 // |
|
141 TUid CBitmapApplication::AppDllUid() const |
|
142 { |
|
143 return KUidBitmap; |
|
144 } |
|
145 |
|
146 CApaDocument* CBitmapApplication::CreateDocumentL() |
|
147 { |
|
148 return new (ELeave) CBitmapDocument(*this); |
|
149 } |
|
150 |
|
151 LOCAL_C CApaApplication* NewApplication() |
|
152 { |
|
153 return new CBitmapApplication; |
|
154 } |
|
155 |
|
156 GLDEF_C TInt E32Main() |
|
157 { |
|
158 return EikStart::RunApplication(NewApplication); |
|
159 } |
|
160 |