1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // e32test/usb/t_usb_device/src/apitests.cpp |
14 // e32test/usb/t_usb_device/src/apitests.cpp |
15 // USB Test Program T_USB_DEVICE, functional part. |
15 // USB Test Program T_USB_DEVICE, functional part. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
17 // |
17 // |
18 // |
18 // |
19 |
19 |
20 #include "general.h" // CActiveControl, CActiveRW |
20 #include "general.h" // CActiveControl, CActiveRW |
21 #include "config.h" |
21 #include "config.h" |
22 #include "usblib.h" // Helpers |
22 #include "usblib.h" // Helpers |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "apitestsTraces.h" |
|
26 #endif |
|
27 |
23 |
28 |
24 extern RTest test; |
29 extern RTest test; |
25 extern TBool gVerbose; |
30 extern TBool gVerbose; |
26 extern TBool gSkip; |
31 extern TBool gSkip; |
27 extern TBool gTempTest; |
32 extern TBool gTempTest; |
63 // Change the device vendor ID (VID) |
68 // Change the device vendor ID (VID) |
64 deviceDescriptor[KUsbVendorIdOffset] = LoByte(aLddPtr->iVid); // little endian! |
69 deviceDescriptor[KUsbVendorIdOffset] = LoByte(aLddPtr->iVid); // little endian! |
65 deviceDescriptor[KUsbVendorIdOffset+1] = HiByte(aLddPtr->iVid); |
70 deviceDescriptor[KUsbVendorIdOffset+1] = HiByte(aLddPtr->iVid); |
66 // Change the device product ID (PID) |
71 // Change the device product ID (PID) |
67 if (aPid != 0) |
72 if (aPid != 0) |
68 { |
73 { |
69 deviceDescriptor[KUsbProductIdOffset] = LoByte(aPid); // little endian! |
74 deviceDescriptor[KUsbProductIdOffset] = LoByte(aPid); // little endian! |
70 deviceDescriptor[KUsbProductIdOffset+1] = HiByte(aPid); |
75 deviceDescriptor[KUsbProductIdOffset+1] = HiByte(aPid); |
71 } |
76 } |
72 else |
77 else |
73 { |
78 { |
74 deviceDescriptor[KUsbProductIdOffset] = LoByte(aLddPtr->iPid); // little endian! |
79 deviceDescriptor[KUsbProductIdOffset] = LoByte(aLddPtr->iPid); // little endian! |
75 deviceDescriptor[KUsbProductIdOffset+1] = HiByte(aLddPtr->iPid); |
80 deviceDescriptor[KUsbProductIdOffset+1] = HiByte(aLddPtr->iPid); |
76 } |
81 } |
77 // Change the device release number |
82 // Change the device release number |
78 deviceDescriptor[KUsbDevReleaseOffset] = LoByte(aLddPtr->iRelease); // little endian! |
83 deviceDescriptor[KUsbDevReleaseOffset] = LoByte(aLddPtr->iRelease); // little endian! |
79 deviceDescriptor[KUsbDevReleaseOffset+1] = HiByte(aLddPtr->iRelease); |
84 deviceDescriptor[KUsbDevReleaseOffset+1] = HiByte(aLddPtr->iRelease); |
80 r = aPort->SetDeviceDescriptor(deviceDescriptor); |
85 r = aPort->SetDeviceDescriptor(deviceDescriptor); |
87 r = aPort->GetDeviceDescriptor(descriptor2); |
92 r = aPort->GetDeviceDescriptor(descriptor2); |
88 test_KErrNone(r); |
93 test_KErrNone(r); |
89 |
94 |
90 test.Next(_L("Compare device descriptor with value set")); |
95 test.Next(_L("Compare device descriptor with value set")); |
91 r = descriptor2.Compare(deviceDescriptor); |
96 r = descriptor2.Compare(deviceDescriptor); |
92 test_KErrNone(r); |
97 test_KErrNone(r); |
93 } |
98 } |
94 |
99 |
95 // === Configuration Descriptor |
100 // === Configuration Descriptor |
96 |
101 |
97 test.Next(_L("GetConfigurationDescriptorSize")); |
102 test.Next(_L("GetConfigurationDescriptorSize")); |
108 // Change Self Power and Remote Wakeup |
113 // Change Self Power and Remote Wakeup |
109 const TInt KUsbAttributesOffset = 7; |
114 const TInt KUsbAttributesOffset = 7; |
110 const TUint8 KUsbAttributeDefault = 0x80; |
115 const TUint8 KUsbAttributeDefault = 0x80; |
111 const TUint8 KUsbAttributeSelfPower = 0x40; |
116 const TUint8 KUsbAttributeSelfPower = 0x40; |
112 const TUint8 KUsbAttributeRemoteWakeup = 0x20; |
117 const TUint8 KUsbAttributeRemoteWakeup = 0x20; |
113 configDescriptor[KUsbAttributesOffset] = KUsbAttributeDefault | (aLddPtr->iSelfPower ? KUsbAttributeSelfPower : 0) |
118 configDescriptor[KUsbAttributesOffset] = KUsbAttributeDefault | (aLddPtr->iSelfPower ? KUsbAttributeSelfPower : 0) |
114 | (aLddPtr->iRemoteWakeup ? KUsbAttributeRemoteWakeup : 0); |
119 | (aLddPtr->iRemoteWakeup ? KUsbAttributeRemoteWakeup : 0); |
115 // Change the reported max power |
120 // Change the reported max power |
116 // 100mA (= 2 * 0x32) is the highest value allowed for a bus-powered device. |
121 // 100mA (= 2 * 0x32) is the highest value allowed for a bus-powered device. |
117 const TInt KUsbMaxPowerOffset = 8; |
122 const TInt KUsbMaxPowerOffset = 8; |
118 configDescriptor[KUsbMaxPowerOffset] = aLddPtr->iMaxPower; |
123 configDescriptor[KUsbMaxPowerOffset] = aLddPtr->iMaxPower; |
128 |
133 |
129 test.Next(_L("Compare configuration desc with value set")); |
134 test.Next(_L("Compare configuration desc with value set")); |
130 r = descriptor2.Compare(configDescriptor); |
135 r = descriptor2.Compare(configDescriptor); |
131 test_KErrNone(r); |
136 test_KErrNone(r); |
132 } |
137 } |
133 |
138 |
134 // === String Descriptors |
139 // === String Descriptors |
135 |
140 |
136 test.Next(_L("SetStringDescriptor")); |
141 test.Next(_L("SetStringDescriptor")); |
137 |
142 |
138 // Set up any standard string descriptors that were defined in the xml config |
143 // Set up any standard string descriptors that were defined in the xml config |
139 if (aLddPtr->iManufacturer) |
144 if (aLddPtr->iManufacturer) |
140 { |
145 { |
141 r = aPort->SetManufacturerStringDescriptor(* aLddPtr->iManufacturer); |
146 r = aPort->SetManufacturerStringDescriptor(* aLddPtr->iManufacturer); |
142 test_KErrNone(r); |
147 test_KErrNone(r); |
143 } |
148 } |
144 |
149 |
145 if (aLddPtr->iProduct) |
150 if (aLddPtr->iProduct) |
146 { |
151 { |
147 r = aPort->SetProductStringDescriptor(* aLddPtr->iProduct); |
152 r = aPort->SetProductStringDescriptor(* aLddPtr->iProduct); |
148 test_KErrNone(r); |
153 test_KErrNone(r); |
149 } |
154 } |
154 test_KErrNone(r); |
159 test_KErrNone(r); |
155 } |
160 } |
156 |
161 |
157 // Set up two arbitrary string descriptors, which can be queried |
162 // Set up two arbitrary string descriptors, which can be queried |
158 // manually from the host side for testing purposes |
163 // manually from the host side for testing purposes |
159 |
164 |
160 TBuf16<KUsbStringDescStringMaxSize / 2> wr_str(KString_one); |
165 TBuf16<KUsbStringDescStringMaxSize / 2> wr_str(KString_one); |
161 r = aPort->SetStringDescriptor(stridx1, wr_str); |
166 r = aPort->SetStringDescriptor(stridx1, wr_str); |
162 test_KErrNone(r); |
167 test_KErrNone(r); |
163 |
168 |
164 wr_str.FillZ(wr_str.MaxLength()); |
169 wr_str.FillZ(wr_str.MaxLength()); |
165 wr_str = KString_two; |
170 wr_str = KString_two; |
166 r = aPort->SetStringDescriptor(stridx2, wr_str); |
171 r = aPort->SetStringDescriptor(stridx2, wr_str); |
167 test_KErrNone(r); |
172 test_KErrNone(r); |
168 |
173 |
169 test.End(); |
174 test.End(); |
170 |
175 |
171 } |
176 } |
172 |
177 |
173 static void TestDeviceQualifierDescriptor(RDEVCLIENT* aPort) |
178 static void TestDeviceQualifierDescriptor(RDEVCLIENT* aPort) |
174 { |
179 { |
175 test.Start(_L("Device_Qualifier Descriptor Manipulation")); |
180 test.Start(_L("Device_Qualifier Descriptor Manipulation")); |
244 TInt r = 0; |
249 TInt r = 0; |
245 TBuf8<KUsbDescSize_Interface> descriptor; |
250 TBuf8<KUsbDescSize_Interface> descriptor; |
246 TBuf8<KUsbDescSize_Interface> descriptor2; |
251 TBuf8<KUsbDescSize_Interface> descriptor2; |
247 for (TInt i =0; i < aNumSettings; i++) |
252 for (TInt i =0; i < aNumSettings; i++) |
248 { |
253 { |
249 |
254 |
250 test.Next(_L("GetInterfaceDescriptorSize()")); |
255 test.Next(_L("GetInterfaceDescriptorSize()")); |
251 r = aPort->GetInterfaceDescriptorSize(i, desc_size); |
256 r = aPort->GetInterfaceDescriptorSize(i, desc_size); |
252 if (r != KErrNone) |
257 if (r != KErrNone) |
253 { |
258 { |
254 RDebug::Printf ("Error %d in GetInterfaceDescriptorSize %d\n",r,i); |
259 OstTraceExt2(TRACE_NORMAL, TESTINTERFACEDESCRIPTOR_TESTINTERFACEDESCRIPTOR, "Error %d in GetInterfaceDescriptorSize %d\n",r,i); |
255 } |
260 } |
256 test_KErrNone(r); |
261 test_KErrNone(r); |
257 test_Equal(KUsbDescSize_Interface,static_cast<TUint>(desc_size)); |
262 test_Equal(KUsbDescSize_Interface,static_cast<TUint>(desc_size)); |
258 |
263 |
259 test.Next(_L("GetInterfaceDescriptor()")); |
264 test.Next(_L("GetInterfaceDescriptor()")); |
275 |
280 |
276 test.Next(_L("Compare interface descriptor with value set")); |
281 test.Next(_L("Compare interface descriptor with value set")); |
277 r = descriptor2.Compare(descriptor); |
282 r = descriptor2.Compare(descriptor); |
278 test_KErrNone(r); |
283 test_KErrNone(r); |
279 } |
284 } |
280 |
285 |
281 test.Next(_L("GetInterfaceDescriptor()")); |
286 test.Next(_L("GetInterfaceDescriptor()")); |
282 r = aPort->GetInterfaceDescriptor(aNumSettings, descriptor); |
287 r = aPort->GetInterfaceDescriptor(aNumSettings, descriptor); |
283 test_Equal(KErrNotFound,r); |
288 test_Equal(KErrNotFound,r); |
284 |
289 |
285 test.Next(_L("SetInterfaceDescriptor()")); |
290 test.Next(_L("SetInterfaceDescriptor()")); |
286 r = aPort->SetInterfaceDescriptor(aNumSettings, descriptor); |
291 r = aPort->SetInterfaceDescriptor(aNumSettings, descriptor); |
287 test_Equal(KErrNotFound,r); |
292 test_Equal(KErrNotFound,r); |
288 |
293 |
289 test.End(); |
294 test.End(); |
290 } |
295 } |
291 |
296 |
292 |
297 |
293 static void TestClassSpecificDescriptors(RDEVCLIENT* aPort) |
298 static void TestClassSpecificDescriptors(RDEVCLIENT* aPort) |
366 |
371 |
367 test(((aEpInfo.iDir & KUsbEpDirIn) && (epDescriptor[KEpDesc_AddressOffset] & 0x80) || |
372 test(((aEpInfo.iDir & KUsbEpDirIn) && (epDescriptor[KEpDesc_AddressOffset] & 0x80) || |
368 !(aEpInfo.iDir & KUsbEpDirIn) && !(epDescriptor[KEpDesc_AddressOffset] & 0x80)) && |
373 !(aEpInfo.iDir & KUsbEpDirIn) && !(epDescriptor[KEpDesc_AddressOffset] & 0x80)) && |
369 EpTypeMask2Value(aEpInfo.iType) == (TUint)(epDescriptor[KEpDesc_AttributesOffset] & 0x03) && |
374 EpTypeMask2Value(aEpInfo.iType) == (TUint)(epDescriptor[KEpDesc_AttributesOffset] & 0x03) && |
370 aEpInfo.iInterval == epDescriptor[KEpDesc_IntervalOffset]); |
375 aEpInfo.iInterval == epDescriptor[KEpDesc_IntervalOffset]); |
371 |
376 |
372 // Change the endpoint poll interval |
377 // Change the endpoint poll interval |
373 TUint8 ival = 0x66; |
378 TUint8 ival = 0x66; |
374 if (epDescriptor[KEpDesc_IntervalOffset] == ival) |
379 if (epDescriptor[KEpDesc_IntervalOffset] == ival) |
375 ival++; |
380 ival++; |
376 |
381 |
421 test.Next(_L("GetStringDescriptorLangId()")); |
426 test.Next(_L("GetStringDescriptorLangId()")); |
422 TUint16 rd_langid_orig; |
427 TUint16 rd_langid_orig; |
423 TInt r = aPort->GetStringDescriptorLangId(rd_langid_orig); |
428 TInt r = aPort->GetStringDescriptorLangId(rd_langid_orig); |
424 test_KErrNone(r); |
429 test_KErrNone(r); |
425 test.Printf(_L("Original LANGID code: 0x%04X\n"), rd_langid_orig); |
430 test.Printf(_L("Original LANGID code: 0x%04X\n"), rd_langid_orig); |
|
431 OstTrace1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS, "Original LANGID code: 0x%04X\n", rd_langid_orig); |
426 |
432 |
427 test.Next(_L("SetStringDescriptorLangId()")); |
433 test.Next(_L("SetStringDescriptorLangId()")); |
428 TUint16 wr_langid = 0x0809; // English (UK) Language ID |
434 TUint16 wr_langid = 0x0809; // English (UK) Language ID |
429 if (wr_langid == rd_langid_orig) |
435 if (wr_langid == rd_langid_orig) |
430 wr_langid = 0x0444; // Tatar Language ID |
436 wr_langid = 0x0444; // Tatar Language ID |
434 test.Next(_L("GetStringDescriptorLangId()")); |
440 test.Next(_L("GetStringDescriptorLangId()")); |
435 TUint16 rd_langid; |
441 TUint16 rd_langid; |
436 r = aPort->GetStringDescriptorLangId(rd_langid); |
442 r = aPort->GetStringDescriptorLangId(rd_langid); |
437 test_KErrNone(r); |
443 test_KErrNone(r); |
438 test.Printf(_L("New LANGID code: 0x%04X\n"), rd_langid); |
444 test.Printf(_L("New LANGID code: 0x%04X\n"), rd_langid); |
|
445 OstTrace1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP01, "New LANGID code: 0x%04X\n", rd_langid); |
439 |
446 |
440 test.Next(_L("Compare LANGID codes")); |
447 test.Next(_L("Compare LANGID codes")); |
441 test_Equal(wr_langid,rd_langid); |
448 test_Equal(wr_langid,rd_langid); |
442 |
449 |
443 test.Next(_L("Restore original LANGID code")); |
450 test.Next(_L("Restore original LANGID code")); |
457 test(r == KErrNone || r == KErrNotFound); |
464 test(r == KErrNone || r == KErrNotFound); |
458 TBool restore_string; |
465 TBool restore_string; |
459 if (r == KErrNone) |
466 if (r == KErrNone) |
460 { |
467 { |
461 test.Printf(_L("Original Manufacturer string: \"%lS\"\n"), &rd_str_orig); |
468 test.Printf(_L("Original Manufacturer string: \"%lS\"\n"), &rd_str_orig); |
|
469 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP02, "Original Manufacturer string: \"%lS\"\n", rd_str_orig); |
462 restore_string = ETrue; |
470 restore_string = ETrue; |
463 } |
471 } |
464 else |
472 else |
465 { |
473 { |
466 test.Printf(_L("No Manufacturer string set\n")); |
474 test.Printf(_L("No Manufacturer string set\n")); |
|
475 OstTrace0(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP03, "No Manufacturer string set\n"); |
467 restore_string = EFalse; |
476 restore_string = EFalse; |
468 } |
477 } |
469 |
478 |
470 test.Next(_L("SetManufacturerStringDescriptor()")); |
479 test.Next(_L("SetManufacturerStringDescriptor()")); |
471 _LIT16(manufacturer, "Manufacturer Which Manufactures Devices"); |
480 _LIT16(manufacturer, "Manufacturer Which Manufactures Devices"); |
476 test.Next(_L("GetManufacturerStringDescriptor()")); |
485 test.Next(_L("GetManufacturerStringDescriptor()")); |
477 TBuf16<KUsbStringDescStringMaxSize / 2> rd_str; |
486 TBuf16<KUsbStringDescStringMaxSize / 2> rd_str; |
478 r = aPort->GetManufacturerStringDescriptor(rd_str); |
487 r = aPort->GetManufacturerStringDescriptor(rd_str); |
479 test_KErrNone(r); |
488 test_KErrNone(r); |
480 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
489 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
|
490 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP04, "New Manufacturer string: \"%lS\"\n", rd_str); |
481 |
491 |
482 test.Next(_L("Compare Manufacturer strings")); |
492 test.Next(_L("Compare Manufacturer strings")); |
483 r = rd_str.Compare(wr_str); |
493 r = rd_str.Compare(wr_str); |
484 test_KErrNone(r); |
494 test_KErrNone(r); |
485 |
495 |
493 test.Next(_L("GetManufacturerStringDescriptor()")); |
503 test.Next(_L("GetManufacturerStringDescriptor()")); |
494 rd_str.FillZ(rd_str.MaxLength()); |
504 rd_str.FillZ(rd_str.MaxLength()); |
495 r = aPort->GetManufacturerStringDescriptor(rd_str); |
505 r = aPort->GetManufacturerStringDescriptor(rd_str); |
496 test_KErrNone(r); |
506 test_KErrNone(r); |
497 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
507 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
|
508 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP05, "New Manufacturer string: \"%lS\"\n", rd_str); |
498 |
509 |
499 test.Next(_L("Compare Manufacturer strings")); |
510 test.Next(_L("Compare Manufacturer strings")); |
500 r = rd_str.Compare(wr_str); |
511 r = rd_str.Compare(wr_str); |
501 test_KErrNone(r); |
512 test_KErrNone(r); |
502 |
513 |
526 r = aPort->GetProductStringDescriptor(rd_str_orig); |
537 r = aPort->GetProductStringDescriptor(rd_str_orig); |
527 test(r == KErrNone || r == KErrNotFound); |
538 test(r == KErrNone || r == KErrNotFound); |
528 if (r == KErrNone) |
539 if (r == KErrNone) |
529 { |
540 { |
530 test.Printf(_L("Old Product string: \"%lS\"\n"), &rd_str_orig); |
541 test.Printf(_L("Old Product string: \"%lS\"\n"), &rd_str_orig); |
|
542 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP06, "Old Product string: \"%lS\"\n", rd_str_orig); |
531 restore_string = ETrue; |
543 restore_string = ETrue; |
532 } |
544 } |
533 else |
545 else |
534 restore_string = EFalse; |
546 restore_string = EFalse; |
535 |
547 |
543 test.Next(_L("GetProductStringDescriptor()")); |
555 test.Next(_L("GetProductStringDescriptor()")); |
544 rd_str.FillZ(rd_str.MaxLength()); |
556 rd_str.FillZ(rd_str.MaxLength()); |
545 r = aPort->GetProductStringDescriptor(rd_str); |
557 r = aPort->GetProductStringDescriptor(rd_str); |
546 test_KErrNone(r); |
558 test_KErrNone(r); |
547 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
559 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
|
560 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP07, "New Product string: \"%lS\"\n", rd_str); |
548 |
561 |
549 test.Next(_L("Compare Product strings")); |
562 test.Next(_L("Compare Product strings")); |
550 r = rd_str.Compare(wr_str); |
563 r = rd_str.Compare(wr_str); |
551 test_KErrNone(r); |
564 test_KErrNone(r); |
552 |
565 |
560 test.Next(_L("GetProductStringDescriptor()")); |
573 test.Next(_L("GetProductStringDescriptor()")); |
561 rd_str.FillZ(rd_str.MaxLength()); |
574 rd_str.FillZ(rd_str.MaxLength()); |
562 r = aPort->GetProductStringDescriptor(rd_str); |
575 r = aPort->GetProductStringDescriptor(rd_str); |
563 test_KErrNone(r); |
576 test_KErrNone(r); |
564 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
577 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
|
578 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP08, "New Product string: \"%lS\"\n", rd_str); |
565 |
579 |
566 test.Next(_L("Compare Product strings")); |
580 test.Next(_L("Compare Product strings")); |
567 r = rd_str.Compare(wr_str); |
581 r = rd_str.Compare(wr_str); |
568 test_KErrNone(r); |
582 test_KErrNone(r); |
569 |
583 |
593 r = aPort->GetSerialNumberStringDescriptor(rd_str_orig); |
607 r = aPort->GetSerialNumberStringDescriptor(rd_str_orig); |
594 test(r == KErrNone || r == KErrNotFound); |
608 test(r == KErrNone || r == KErrNotFound); |
595 if (r == KErrNone) |
609 if (r == KErrNone) |
596 { |
610 { |
597 test.Printf(_L("Old Serial Number: \"%lS\"\n"), &rd_str_orig); |
611 test.Printf(_L("Old Serial Number: \"%lS\"\n"), &rd_str_orig); |
|
612 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP09, "Old Serial Number: \"%lS\"\n", rd_str_orig); |
598 restore_string = ETrue; |
613 restore_string = ETrue; |
599 } |
614 } |
600 else |
615 else |
601 restore_string = EFalse; |
616 restore_string = EFalse; |
602 |
617 |
610 test.Next(_L("GetSerialNumberStringDescriptor()")); |
625 test.Next(_L("GetSerialNumberStringDescriptor()")); |
611 rd_str.FillZ(rd_str.MaxLength()); |
626 rd_str.FillZ(rd_str.MaxLength()); |
612 r = aPort->GetSerialNumberStringDescriptor(rd_str); |
627 r = aPort->GetSerialNumberStringDescriptor(rd_str); |
613 test_KErrNone(r); |
628 test_KErrNone(r); |
614 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
629 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
|
630 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP10, "New Serial Number: \"%lS\"\n", rd_str); |
615 |
631 |
616 test.Next(_L("Compare Serial Number strings")); |
632 test.Next(_L("Compare Serial Number strings")); |
617 r = rd_str.Compare(wr_str); |
633 r = rd_str.Compare(wr_str); |
618 test_KErrNone(r); |
634 test_KErrNone(r); |
619 |
635 |
627 test.Next(_L("GetSerialNumberStringDescriptor()")); |
643 test.Next(_L("GetSerialNumberStringDescriptor()")); |
628 rd_str.FillZ(rd_str.MaxLength()); |
644 rd_str.FillZ(rd_str.MaxLength()); |
629 r = aPort->GetSerialNumberStringDescriptor(rd_str); |
645 r = aPort->GetSerialNumberStringDescriptor(rd_str); |
630 test_KErrNone(r); |
646 test_KErrNone(r); |
631 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
647 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
|
648 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP11, "New Serial Number: \"%lS\"\n", rd_str); |
632 |
649 |
633 test.Next(_L("Compare Serial Number strings")); |
650 test.Next(_L("Compare Serial Number strings")); |
634 r = rd_str.Compare(wr_str); |
651 r = rd_str.Compare(wr_str); |
635 test_KErrNone(r); |
652 test_KErrNone(r); |
636 |
653 |
660 r = aPort->GetConfigurationStringDescriptor(rd_str_orig); |
677 r = aPort->GetConfigurationStringDescriptor(rd_str_orig); |
661 test(r == KErrNone || r == KErrNotFound); |
678 test(r == KErrNone || r == KErrNotFound); |
662 if (r == KErrNone) |
679 if (r == KErrNone) |
663 { |
680 { |
664 test.Printf(_L("Old Configuration string: \"%lS\"\n"), &rd_str_orig); |
681 test.Printf(_L("Old Configuration string: \"%lS\"\n"), &rd_str_orig); |
|
682 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP12, "Old Configuration string: \"%lS\"\n", rd_str_orig); |
665 restore_string = ETrue; |
683 restore_string = ETrue; |
666 } |
684 } |
667 else |
685 else |
668 restore_string = EFalse; |
686 restore_string = EFalse; |
669 |
687 |
677 test.Next(_L("GetConfigurationStringDescriptor()")); |
695 test.Next(_L("GetConfigurationStringDescriptor()")); |
678 rd_str.FillZ(rd_str.MaxLength()); |
696 rd_str.FillZ(rd_str.MaxLength()); |
679 r = aPort->GetConfigurationStringDescriptor(rd_str); |
697 r = aPort->GetConfigurationStringDescriptor(rd_str); |
680 test_KErrNone(r); |
698 test_KErrNone(r); |
681 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
699 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
|
700 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP13, "New Configuration string: \"%lS\"\n", rd_str); |
682 |
701 |
683 test.Next(_L("Compare Configuration strings")); |
702 test.Next(_L("Compare Configuration strings")); |
684 r = rd_str.Compare(wr_str); |
703 r = rd_str.Compare(wr_str); |
685 test_KErrNone(r); |
704 test_KErrNone(r); |
686 |
705 |
694 test.Next(_L("GetConfigurationStringDescriptor()")); |
713 test.Next(_L("GetConfigurationStringDescriptor()")); |
695 rd_str.FillZ(rd_str.MaxLength()); |
714 rd_str.FillZ(rd_str.MaxLength()); |
696 r = aPort->GetConfigurationStringDescriptor(rd_str); |
715 r = aPort->GetConfigurationStringDescriptor(rd_str); |
697 test_KErrNone(r); |
716 test_KErrNone(r); |
698 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
717 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
|
718 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP14, "New Configuration string: \"%lS\"\n", rd_str); |
699 |
719 |
700 test.Next(_L("Compare Configuration strings")); |
720 test.Next(_L("Compare Configuration strings")); |
701 r = rd_str.Compare(wr_str); |
721 r = rd_str.Compare(wr_str); |
702 test_KErrNone(r); |
722 test_KErrNone(r); |
703 |
723 |
783 |
803 |
784 test.Next(_L("GetStringDescriptor() 3")); |
804 test.Next(_L("GetStringDescriptor() 3")); |
785 r = aPort->GetStringDescriptor(stridx3, rd_str); |
805 r = aPort->GetStringDescriptor(stridx3, rd_str); |
786 test_KErrNone(r); |
806 test_KErrNone(r); |
787 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx3, &rd_str); |
807 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx3, &rd_str); |
|
808 OstTraceExt2(TRACE_NORMAL, TESTARBITRARYSTRINGDESCRIPTORS_TESTARBITRARYSTRINGDESCRIPTORS, "New test string @ idx %d: \"%lS\"\n", stridx3, rd_str); |
788 |
809 |
789 test.Next(_L("Compare test strings 3")); |
810 test.Next(_L("Compare test strings 3")); |
790 r = rd_str.Compare(wr_str); |
811 r = rd_str.Compare(wr_str); |
791 test_KErrNone(r); |
812 test_KErrNone(r); |
792 |
813 |
826 test.Start(_L("Test Invalid Interface Setting")); |
847 test.Start(_L("Test Invalid Interface Setting")); |
827 |
848 |
828 if (SupportsAlternateInterfaces()) |
849 if (SupportsAlternateInterfaces()) |
829 { |
850 { |
830 TInt r = aPort->SetInterface(aNumSettings+1, ifc); |
851 TInt r = aPort->SetInterface(aNumSettings+1, ifc); |
831 test_Compare(r,!=,KErrNone); |
852 test_Compare(r,!=,KErrNone); |
832 } |
853 } |
833 |
854 |
834 if (aNumSettings > 1) |
855 if (aNumSettings > 1) |
835 { |
856 { |
836 TInt r = aPort->SetInterface(aNumSettings-1, ifc); |
857 TInt r = aPort->SetInterface(aNumSettings-1, ifc); |
837 test_Compare(r,!=,KErrNone); |
858 test_Compare(r,!=,KErrNone); |
838 } |
859 } |
839 |
860 |
840 TInt r = aPort->SetInterface(0, ifc); |
861 TInt r = aPort->SetInterface(0, ifc); |
841 test_Compare(r,!=,KErrNone); |
862 test_Compare(r,!=,KErrNone); |
842 |
863 |
843 test.End(); |
864 test.End(); |
844 } |
865 } |
845 |
866 |
846 void TestInvalidReleaseInterface (RDEVCLIENT* aPort,TInt aNumSettings) |
867 void TestInvalidReleaseInterface (RDEVCLIENT* aPort,TInt aNumSettings) |
848 test.Start(_L("Test Invalid Interface Release")); |
869 test.Start(_L("Test Invalid Interface Release")); |
849 |
870 |
850 if (aNumSettings > 2) |
871 if (aNumSettings > 2) |
851 { |
872 { |
852 TInt r = aPort->ReleaseInterface(aNumSettings-3); |
873 TInt r = aPort->ReleaseInterface(aNumSettings-3); |
853 test_Compare(r,!=,KErrNone); |
874 test_Compare(r,!=,KErrNone); |
854 } |
875 } |
855 |
876 |
856 if (aNumSettings > 1) |
877 if (aNumSettings > 1) |
857 { |
878 { |
858 TInt r = aPort->ReleaseInterface(aNumSettings-2); |
879 TInt r = aPort->ReleaseInterface(aNumSettings-2); |
859 test_Compare(r,!=,KErrNone); |
880 test_Compare(r,!=,KErrNone); |
860 } |
881 } |
861 |
882 |
862 test.End(); |
883 test.End(); |
863 } |
884 } |
864 |
885 |
868 |
889 |
869 if (aHighSpeed) |
890 if (aHighSpeed) |
870 { |
891 { |
871 TestDeviceQualifierDescriptor(aPort); |
892 TestDeviceQualifierDescriptor(aPort); |
872 |
893 |
873 TestOtherSpeedConfigurationDescriptor(aPort); |
894 TestOtherSpeedConfigurationDescriptor(aPort); |
874 } |
895 } |
875 |
896 |
876 TestInterfaceDescriptor(aPort,aNumSettings); |
897 TestInterfaceDescriptor(aPort,aNumSettings); |
877 |
898 |
878 TestClassSpecificDescriptors(aPort); |
899 TestClassSpecificDescriptors(aPort); |
879 |
900 |
880 TestStandardStringDescriptors(aPort); |
901 TestStandardStringDescriptors(aPort); |
881 |
902 |
882 TestArbitraryStringDescriptors(aPort,aNumSettings); |
903 TestArbitraryStringDescriptors(aPort,aNumSettings); |
|
904 test.Next(_L("Test USB Descriptor Manipulation1")); |
883 |
905 |
884 test.End(); |
906 test.End(); |
885 } |
907 } |
886 |
908 |
887 |
909 |
931 TBool b_HnpEnable = (features & KUsbOtgAttr_B_HnpEnable) ? ETrue : EFalse; |
953 TBool b_HnpEnable = (features & KUsbOtgAttr_B_HnpEnable) ? ETrue : EFalse; |
932 TBool a_HnpSupport = (features & KUsbOtgAttr_A_HnpSupport) ? ETrue : EFalse; |
954 TBool a_HnpSupport = (features & KUsbOtgAttr_A_HnpSupport) ? ETrue : EFalse; |
933 TBool a_AltHnpSupport = (features & KUsbOtgAttr_A_AltHnpSupport) ? ETrue : EFalse; |
955 TBool a_AltHnpSupport = (features & KUsbOtgAttr_A_AltHnpSupport) ? ETrue : EFalse; |
934 test.Printf(_L("### OTG Features:\nB_HnpEnable(%d)\nA_HnpSupport(%d)\nA_Alt_HnpSupport(%d)\n"), |
956 test.Printf(_L("### OTG Features:\nB_HnpEnable(%d)\nA_HnpSupport(%d)\nA_Alt_HnpSupport(%d)\n"), |
935 b_HnpEnable, a_HnpSupport, a_AltHnpSupport); |
957 b_HnpEnable, a_HnpSupport, a_AltHnpSupport); |
|
958 OstTraceExt3(TRACE_NORMAL, TESTOTGEXTENSIONS_TESTOTGEXTENSIONS, "### OTG Features:\nB_HnpEnable(%d)\nA_HnpSupport(%d)\nA_Alt_HnpSupport(%d)\n", |
|
959 b_HnpEnable, a_HnpSupport, a_AltHnpSupport); |
936 } |
960 } |
937 else |
961 else |
938 { |
962 { |
939 test_Equal(KErrNotSupported,r); |
963 test_Equal(KErrNotSupported,r); |
940 test.Printf(_L("GetOtgFeatures() not supported\n")); |
964 test.Printf(_L("GetOtgFeatures() not supported\n")); |
|
965 OstTrace0(TRACE_NORMAL, TESTOTGEXTENSIONS_TESTOTGEXTENSIONS_DUP01, "GetOtgFeatures(not supported\n"); |
941 } |
966 } |
942 |
967 |
943 test.End(); |
968 test.End(); |
944 } |
969 } |
945 |
970 |
987 break; |
1012 break; |
988 } |
1013 } |
989 if (good) |
1014 if (good) |
990 { |
1015 { |
991 test.Printf(_L("Ep0 supports %d bytes MaxPacketSize\n"), mpsize); |
1016 test.Printf(_L("Ep0 supports %d bytes MaxPacketSize\n"), mpsize); |
|
1017 OstTrace1(TRACE_NORMAL, TESTENDPOINT0MAXPACKETSIZES_TESTENDPOINT0MAXPACKETSIZES, "Ep0 supports %d bytes MaxPacketSize\n", mpsize); |
992 } |
1018 } |
993 else |
1019 else |
994 { |
1020 { |
995 test.Printf(_L("Bad Ep0 size: 0x%08x, failure will occur\n"), bit); |
1021 test.Printf(_L("Bad Ep0 size: 0x%08x, failure will occur\n"), bit); |
|
1022 OstTrace1(TRACE_NORMAL, TESTENDPOINT0MAXPACKETSIZES_TESTENDPOINT0MAXPACKETSIZES_DUP01, "Bad Ep0 size: 0x%08x, failure will occur\n", bit); |
996 r = KErrGeneral; |
1023 r = KErrGeneral; |
997 } |
1024 } |
998 } |
1025 } |
999 } |
1026 } |
1000 test_KErrNone(r); |
1027 test_KErrNone(r); |