|
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 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 "hcr_debug.h" |
|
19 #include "hcr_hai.h" |
|
20 #include "d_hcrsim.h" |
|
21 |
|
22 extern HCR::SRepositoryCompiled CompiledRepository; |
|
23 extern HCR::SRepositoryCompiled CompiledEmptyRepository; |
|
24 extern HCR::SRepositoryCompiled CompiledRepositoryCorrupt1; |
|
25 extern HCR::SRepositoryCompiled CompiledRepositoryCorrupt2; |
|
26 extern HCR::SRepositoryCompiled CompiledRepositoryNullOrderedList; |
|
27 TUint32 PslConfigurationFlags = 0; |
|
28 |
|
29 class HCRTest : public HCR::MVariant |
|
30 { |
|
31 public: |
|
32 HCRTest(); |
|
33 virtual ~HCRTest(); |
|
34 |
|
35 public: |
|
36 TInt Initialise(); |
|
37 TBool IgnoreCoreImgRepository(); |
|
38 TInt GetCompiledRepositoryAddress( TAny* & aAddr); |
|
39 TInt GetOverrideRepositoryAddress( TAny* & aAddr); |
|
40 }; |
|
41 |
|
42 HCRTest::HCRTest() |
|
43 { |
|
44 HCR_FUNC("HCRTest"); |
|
45 } |
|
46 |
|
47 HCRTest::~HCRTest() |
|
48 { |
|
49 HCR_FUNC("~HCRTest"); |
|
50 } |
|
51 |
|
52 TInt HCRTest::Initialise() |
|
53 { |
|
54 HCR_FUNC("HCRTest::Initialise"); |
|
55 if (PslConfigurationFlags & ETestInitialisationFail) |
|
56 { |
|
57 HCR_TRACE_RETURN(KErrBadPower); // random error code no.1 |
|
58 } |
|
59 HCR_TRACE_RETURN(KErrNone); |
|
60 } |
|
61 |
|
62 TInt HCRTest::GetCompiledRepositoryAddress(TAny*& aAddr) |
|
63 { |
|
64 HCR_FUNC("HCRTest::GetCompiledRepositoryAddress"); |
|
65 TInt r = KErrNone; |
|
66 if (PslConfigurationFlags & ETestNullRepository) |
|
67 { |
|
68 aAddr = NULL; |
|
69 r = KErrNotSupported; |
|
70 } |
|
71 else if (PslConfigurationFlags & ETestEmptyRepository) |
|
72 { |
|
73 aAddr = static_cast<TAny*>(&CompiledEmptyRepository); |
|
74 } |
|
75 else if (PslConfigurationFlags & ETestCorruptRepository1) |
|
76 { |
|
77 aAddr = static_cast<TAny*>(&CompiledRepositoryCorrupt1); |
|
78 } |
|
79 else if (PslConfigurationFlags & ETestCorruptRepository2) |
|
80 { |
|
81 aAddr = static_cast<TAny*>(&CompiledRepositoryCorrupt2); |
|
82 } |
|
83 else if (PslConfigurationFlags & ETestNullOrderedList) |
|
84 { |
|
85 aAddr = static_cast<TAny*>(&CompiledRepositoryNullOrderedList); |
|
86 } |
|
87 else if (PslConfigurationFlags & ETestNullRepositoryKErrNone) |
|
88 { |
|
89 aAddr = NULL; |
|
90 r = KErrNone; // Invalid error code: should be KErrNotSupported |
|
91 } |
|
92 else if (PslConfigurationFlags & ETestBadErrorCode) |
|
93 { |
|
94 aAddr = static_cast<TAny*>(&CompiledEmptyRepository); |
|
95 r = KErrCommsParity; // random error code no.2 |
|
96 } |
|
97 else |
|
98 { |
|
99 aAddr = static_cast<TAny*>(&CompiledRepository); |
|
100 } |
|
101 HCR_TRACE_RETURN(r); |
|
102 } |
|
103 |
|
104 TBool HCRTest::IgnoreCoreImgRepository() |
|
105 { |
|
106 HCR_FUNC("HCRTest::IgnoreCoreImgRepository"); |
|
107 HCR_TRACE_RETURN(PslConfigurationFlags & ETestIgnoreCoreImgRepository); |
|
108 } |
|
109 |
|
110 TInt HCRTest::GetOverrideRepositoryAddress(TAny*& aAddr) |
|
111 { |
|
112 HCR_FUNC("HCRTest::GetRAMRepositoryAddress"); |
|
113 TInt r = KErrNotSupported; |
|
114 if (PslConfigurationFlags & ETestEnableOverrideRepository) |
|
115 { |
|
116 aAddr = static_cast<TAny*>(&CompiledEmptyRepository); |
|
117 r = KErrNone; |
|
118 } |
|
119 HCR_TRACE_RETURN(r); |
|
120 } |
|
121 |
|
122 GLDEF_C HCR::MVariant* CreateHCRVariant() |
|
123 { |
|
124 HCR_FUNC("CreateHCRTest"); |
|
125 if (PslConfigurationFlags & ETestVariantObjectCreateFail) |
|
126 { |
|
127 return NULL; |
|
128 } |
|
129 return new HCRTest; |
|
130 } |