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: stub central repository -class for testing CVideoCollectionClient |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "centralrepository.h" |
|
20 |
|
21 const int KVideoCollectionViewCenrepSortingRoleKey(0x5); |
|
22 const int KVideoCollectionViewCenrepSortingOrderKey(0x6); |
|
23 |
|
24 /** |
|
25 * if true, Newl will leave |
|
26 */ |
|
27 bool gCRNewLLeave = false; |
|
28 |
|
29 /** |
|
30 * if zero, Set will fail. Every Set call decreases this value by one. |
|
31 */ |
|
32 int gCRSetFail = 255; |
|
33 |
|
34 /** |
|
35 * if zero, Get will fail. Every Get call decreases this value by one. |
|
36 */ |
|
37 int gCRGetFail = 255; |
|
38 |
|
39 /** |
|
40 * role value will be saved here in correct cases |
|
41 */ |
|
42 int gSettedRoleValue = -1; |
|
43 |
|
44 /** |
|
45 * order value will be saved here in correct cases |
|
46 */ |
|
47 int gSettedOrderValue = -1; |
|
48 |
|
49 /** |
|
50 * order value will be saved here in correct cases |
|
51 */ |
|
52 TBuf<255> gSettedTDesValue = TBuf<255>(); |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // setNewLLeave |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CRepository::setNewLLeave(bool leave) |
|
59 { |
|
60 gCRNewLLeave = leave; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // setSetFail |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CRepository::setSetFail(int amount) |
|
68 { |
|
69 gCRSetFail = amount; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // setGetFail |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CRepository::setGetFail(int amount) |
|
77 { |
|
78 gCRGetFail = amount; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // getRoleValue |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 int CRepository::getRoleValue() |
|
86 { |
|
87 return gSettedRoleValue; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // getOrderValue |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 int CRepository::getOrderValue() |
|
95 { |
|
96 return gSettedOrderValue; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // getTDesValue |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TDesC& CRepository::getTDesValue() |
|
104 { |
|
105 return gSettedTDesValue; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // setRoleValue |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CRepository::setRoleValue(int value) |
|
113 { |
|
114 gSettedRoleValue = value; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // setOrderValue |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CRepository::setOrderValue(int value) |
|
122 { |
|
123 gSettedOrderValue = value; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // setOrderValue |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CRepository::setTDesValue(const TDesC& value) |
|
131 { |
|
132 gSettedTDesValue = value; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // NewL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CRepository* CRepository::NewL(TUid /*aRepositoryUid*/) |
|
140 { |
|
141 if(gCRNewLLeave) |
|
142 { |
|
143 User::Leave(KErrGeneral); |
|
144 } |
|
145 return new CRepository(); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CRepository |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 CRepository::CRepository() |
|
153 { |
|
154 |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // ~CRepository |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 CRepository::~CRepository() |
|
162 { |
|
163 |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // Get |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 TInt CRepository::Get(TUint32 aKey, TInt& aValue) |
|
171 { |
|
172 if(gCRGetFail == 0) |
|
173 { |
|
174 return KErrGeneral; |
|
175 } else { |
|
176 gCRGetFail--; |
|
177 } |
|
178 |
|
179 if(aKey == KVideoCollectionViewCenrepSortingRoleKey) { |
|
180 aValue = gSettedRoleValue; |
|
181 } else { |
|
182 aValue = gSettedOrderValue; |
|
183 } |
|
184 |
|
185 return KErrNone; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // Set |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 TInt CRepository::Set(TUint32 aKey, TInt aValue) |
|
193 { |
|
194 if(gCRSetFail == 0) |
|
195 { |
|
196 return KErrGeneral; |
|
197 } else { |
|
198 gCRSetFail--; |
|
199 } |
|
200 |
|
201 if(aKey == KVideoCollectionViewCenrepSortingRoleKey) { |
|
202 gSettedRoleValue = aValue; |
|
203 } else { |
|
204 gSettedOrderValue = aValue; |
|
205 } |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // Get |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CRepository::Get(TUint32 /*aKey*/, TDes& aValue) |
|
214 { |
|
215 if(gCRGetFail == 0) |
|
216 { |
|
217 return KErrGeneral; |
|
218 } else { |
|
219 gCRGetFail--; |
|
220 } |
|
221 |
|
222 aValue = gSettedTDesValue; |
|
223 |
|
224 return KErrNone; |
|
225 } |
|