|
1 /* |
|
2 * Copyright (c) 2007-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: |
|
15 * This contains CTestStepUsb which is the base class for all the Usb Test Steps |
|
16 * |
|
17 */ |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 #include <c32comm.h> |
|
22 |
|
23 // Test system includes |
|
24 #include <networking/log.h> |
|
25 #include "UsbStep.h" |
|
26 #include "UsbSuite.h" |
|
27 |
|
28 _LIT(KUsbLddName, "eusbc"); |
|
29 |
|
30 /** |
|
31 * The CTestStepUsb::CTestStepUsb method |
|
32 * |
|
33 * |
|
34 * |
|
35 * @internalComponent |
|
36 * |
|
37 * @return |
|
38 */ |
|
39 CTestStepUsb::CTestStepUsb() |
|
40 : iUsbSuite(0) |
|
41 { |
|
42 } |
|
43 |
|
44 |
|
45 /** |
|
46 * The CTestStepUsb::~CTestStepUsb method |
|
47 * |
|
48 * |
|
49 * |
|
50 * @internalComponent |
|
51 * |
|
52 * @return |
|
53 */ |
|
54 CTestStepUsb::~CTestStepUsb() |
|
55 { |
|
56 } |
|
57 |
|
58 void CTestStepUsb::OpenCommServerL() |
|
59 { |
|
60 if (!iUsbSuite->iCommServerOpen) |
|
61 { |
|
62 TInt err = iUsbSuite->iCommServer.Connect(); |
|
63 TESTL(err == KErrNone || err == KErrAlreadyExists); |
|
64 iUsbSuite->iCommServerOpen = ETrue; |
|
65 |
|
66 Log(_L("CTestStepUsb::doTestStepL() - Connected to C32")); |
|
67 |
|
68 err = iUsbSuite->iCommServer.LoadCommModule(CSY_NAME); |
|
69 TESTL(err == KErrNone || err == KErrAlreadyExists); |
|
70 |
|
71 Log(_L("CTestStepUsb::doTestStepL() = Loaded ACM CSY")); |
|
72 } |
|
73 else |
|
74 { |
|
75 TEST(ETrue); |
|
76 } |
|
77 } |
|
78 |
|
79 TInt CTestStepUsb::OpenLdd() |
|
80 { |
|
81 if (iUsbSuite->iLddOpen) |
|
82 { |
|
83 return KErrNone; |
|
84 } |
|
85 |
|
86 TInt err = User::LoadLogicalDevice(KUsbLddName); |
|
87 |
|
88 if (err != KErrNone && err != KErrAlreadyExists) |
|
89 { |
|
90 Log(_L("CTestStepUsb::OpenLdd() - Unable to load LDD! Error = %d"), err); |
|
91 return err; |
|
92 } |
|
93 |
|
94 err = iUsbSuite->iLdd.Open(0); |
|
95 if (err != KErrNone) |
|
96 { |
|
97 Log(_L("CTestStepUsb::OpenLdd() - Unable to Open LDD! Error = %d"), err); |
|
98 return err; |
|
99 } |
|
100 |
|
101 iUsbSuite->iLddOpen = ETrue; |
|
102 iUsbSuite->iLdd.SetDeviceControl(); |
|
103 iUsbSuite->iLdd.ReleaseDeviceControl(); |
|
104 return KErrNone; |
|
105 } |