|
1 // Copyright (c) 2005-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 #include "cteststepbtromconfigSdpAgent001.h" |
|
17 #include <btsdp.h> |
|
18 |
|
19 /** |
|
20 Unnamed namespaces are a superior replacement for the static |
|
21 declaration of variables. They allow variables and functions to be |
|
22 visible within an entire translation unit, yet not visible |
|
23 externally. Although entities in an unnamed namespace might have |
|
24 external linkage, they are effectively qualified by a name unique |
|
25 to their translation unit and therefore can never be seen from any |
|
26 other translation unit. |
|
27 */ |
|
28 namespace |
|
29 { |
|
30 /** |
|
31 Panic string if an invalid test subcase is specified Panic |
|
32 number is the invalid subcase |
|
33 */ |
|
34 _LIT(KInvalidTestPanicString, "Invalid Test subcase specified"); |
|
35 } |
|
36 |
|
37 CTestStepBtRomConfigSdpAgent001:: |
|
38 CTestStepBtRomConfigSdpAgent001(CTestServer& aParent) |
|
39 : CTestStepBtRomConfigBase(aParent) |
|
40 { |
|
41 SetTestStepName(KTestNameSdpAgent001); |
|
42 } |
|
43 |
|
44 /** |
|
45 Static Constructor |
|
46 Note the lack of ELeave. This means that having insufficient memory |
|
47 will return NULL; |
|
48 */ |
|
49 CTestStepBtRomConfigSdpAgent001* |
|
50 CTestStepBtRomConfigSdpAgent001::New(CTestServer& aParent) |
|
51 { |
|
52 return new CTestStepBtRomConfigSdpAgent001(aParent); |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 See BT_ROMCONFIG_SDPAGENT_001.script |
|
58 */ |
|
59 TVerdict CTestStepBtRomConfigSdpAgent001::doTestStepL() |
|
60 { |
|
61 INFO_PRINTF1(_L(">>CTestStepBtRomConfigSdpAgent001::doTestStepL()")); |
|
62 |
|
63 CActiveScheduler* sched(new (ELeave)CActiveScheduler); |
|
64 CActiveScheduler::Install(sched); |
|
65 CleanupStack::PushL(sched); |
|
66 |
|
67 const TInt expectedError(iBtExcluded ? KErrBadName : KErrNone); |
|
68 // this is only used for logging readability purposes |
|
69 const TDesC* expectedErrorDesPtr(iBtExcluded ? |
|
70 &KErrBadNameLit : &KErrNoneLit); |
|
71 TRAPD(err1, TestSdpAgentL(1)); |
|
72 |
|
73 if (expectedError != err1) |
|
74 { |
|
75 INFO_PRINTF4(\ |
|
76 _L("Failed: Expected %S(%d) and got %d calling CSdpAgent::NextRecordRequestL"), |
|
77 expectedErrorDesPtr, expectedError, err1); |
|
78 SetTestStepResult(EFail); |
|
79 } |
|
80 |
|
81 TRAPD(err2, TestSdpAgentL(2)); |
|
82 if (expectedError != err2) |
|
83 { |
|
84 INFO_PRINTF4(\ |
|
85 _L("Failed: Expected %S(%d) and got %d calling CSdpAgent::NextRecordRequestL"), |
|
86 expectedErrorDesPtr, expectedError, err2); |
|
87 SetTestStepResult(EFail); |
|
88 } |
|
89 |
|
90 CleanupStack::PopAndDestroy(sched); |
|
91 |
|
92 INFO_PRINTF1(_L("<<CTestStepBtRomConfigSdpAgent001::doTestStepL()")); |
|
93 |
|
94 CheckAndSetTestResult(); |
|
95 return TestStepResult(); |
|
96 } |
|
97 |
|
98 void CTestStepBtRomConfigSdpAgent001::TestSdpAgentL(TInt aTestSubCase) |
|
99 { |
|
100 |
|
101 const TBTDevAddr Kaddr(0x000e07966a4); |
|
102 const TUUID KdummyUUID(1); |
|
103 |
|
104 //Create a search pattern so we only see SDP records for our application |
|
105 CSdpSearchPattern *pattern(CSdpSearchPattern::NewL()); |
|
106 CleanupStack::PushL(pattern); |
|
107 User::LeaveIfError(pattern->AddL(KdummyUUID)); |
|
108 |
|
109 switch (aTestSubCase) |
|
110 { |
|
111 case 1: |
|
112 { |
|
113 CSdpAgent* agent(CSdpAgent::NewL(*this, Kaddr)); |
|
114 CleanupStack::PushL(agent); |
|
115 |
|
116 agent->SetRecordFilterL(*pattern); |
|
117 agent->NextRecordRequestL(); |
|
118 |
|
119 CleanupStack::PopAndDestroy(agent); |
|
120 CleanupStack::PopAndDestroy(pattern); |
|
121 } |
|
122 break; |
|
123 |
|
124 case 2: |
|
125 { |
|
126 CSdpAgent* agent(CSdpAgent::NewLC(*this, Kaddr)); |
|
127 |
|
128 agent->SetRecordFilterL(*pattern); |
|
129 agent->NextRecordRequestL(); |
|
130 |
|
131 CleanupStack::PopAndDestroy(agent); |
|
132 CleanupStack::PopAndDestroy(pattern); |
|
133 } |
|
134 break; |
|
135 |
|
136 default: |
|
137 SetTestStepResult(EFail); |
|
138 User::Panic(KInvalidTestPanicString, aTestSubCase); |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
|
143 // stubs |
|
144 void CTestStepBtRomConfigSdpAgent001::NextRecordRequestComplete(TInt, |
|
145 TSdpServRecordHandle, |
|
146 TInt) |
|
147 {} |
|
148 |
|
149 void CTestStepBtRomConfigSdpAgent001::AttributeRequestResult(TSdpServRecordHandle, |
|
150 TSdpAttributeID, |
|
151 CSdpAttrValue *) |
|
152 {} |
|
153 |
|
154 void CTestStepBtRomConfigSdpAgent001::AttributeRequestComplete(TSdpServRecordHandle, |
|
155 TInt) |
|
156 {} |
|
157 // EOF |