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 * order value will be saved here in correct cases |
|
41 */ |
|
42 TBuf<255> gSettedTDesValue = TBuf<255>(); |
|
43 |
|
44 |
|
45 QMap<uint, int> CRepository::mSortValues = QMap<uint, int>(); |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // setNewLLeave |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CRepository::setNewLLeave(bool leave) |
|
53 { |
|
54 gCRNewLLeave = leave; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // setSetFail |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CRepository::setSetFail(int amount) |
|
62 { |
|
63 gCRSetFail = amount; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // setGetFail |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CRepository::setGetFail(int amount) |
|
71 { |
|
72 gCRGetFail = amount; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // getTDesValue |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TDesC& CRepository::getTDesValue() |
|
80 { |
|
81 return gSettedTDesValue; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // setOrderValue |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CRepository::setTDesValue(const TDesC& value) |
|
89 { |
|
90 gSettedTDesValue = value; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // NewL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CRepository* CRepository::NewL(TUid /*aRepositoryUid*/) |
|
98 { |
|
99 if(gCRNewLLeave) |
|
100 { |
|
101 User::Leave(KErrGeneral); |
|
102 } |
|
103 return new CRepository(); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CRepository |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 CRepository::CRepository() |
|
111 { |
|
112 |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // ~CRepository |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CRepository::~CRepository() |
|
120 { |
|
121 |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // Get |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt CRepository::Get(TUint32 aKey, TInt& aValue) |
|
129 { |
|
130 if(gCRGetFail == 0) |
|
131 { |
|
132 return KErrGeneral; |
|
133 } else { |
|
134 gCRGetFail--; |
|
135 } |
|
136 |
|
137 aValue = mSortValues.value(aKey); |
|
138 |
|
139 return KErrNone; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // Set |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CRepository::Set(TUint32 aKey, TInt aValue) |
|
147 { |
|
148 if(gCRSetFail == 0) |
|
149 { |
|
150 return KErrGeneral; |
|
151 } else { |
|
152 gCRSetFail--; |
|
153 } |
|
154 |
|
155 mSortValues[aKey] = aValue; |
|
156 |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // Get |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 TInt CRepository::Get(TUint32 /*aKey*/, TDes& aValue) |
|
165 { |
|
166 if(gCRGetFail == 0) |
|
167 { |
|
168 return KErrGeneral; |
|
169 } else { |
|
170 gCRGetFail--; |
|
171 } |
|
172 |
|
173 aValue = gSettedTDesValue; |
|
174 |
|
175 return KErrNone; |
|
176 } |
|