|
1 /* |
|
2 * Copyright (c) 2006-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 * |
|
16 */ |
|
17 |
|
18 #include "usbchargingarmtest.h" |
|
19 #include <usb/usblogger.h> |
|
20 #include <e32cmn.h> |
|
21 #include "usbbatterycharging.h" |
|
22 #include "testmanager.h" |
|
23 |
|
24 CUsbChargingArmTest::CUsbChargingArmTest(MTestManager& aManager) |
|
25 : CTestBase(aManager) |
|
26 { |
|
27 } |
|
28 |
|
29 CTestBase* CUsbChargingArmTest::NewL(MTestManager& aManager) |
|
30 { |
|
31 CUsbChargingArmTest* self = new(ELeave) CUsbChargingArmTest(aManager); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 void CUsbChargingArmTest::ConstructL() |
|
39 { |
|
40 |
|
41 // -- Insert initialization code here |
|
42 iRepository = CRepository::NewL(KUsbBatteryChargingCentralRepositoryUid); |
|
43 iId = KUsbBatteryChargingKeyEnabledUserSetting; |
|
44 |
|
45 } |
|
46 |
|
47 CUsbChargingArmTest::~CUsbChargingArmTest() |
|
48 { |
|
49 iManager.Write(_L8("CUsbChargingArmTest::~CUsbChargingArmTest")); |
|
50 |
|
51 // -- Insert cleanup code here |
|
52 delete iRepository; |
|
53 } |
|
54 |
|
55 void CUsbChargingArmTest::ProcessKeyL(TKeyCode aKeyCode) |
|
56 { |
|
57 iManager.Write(_L8("CUsbChargingArmTest::ProcessKeyL")); |
|
58 |
|
59 switch ( aKeyCode ) |
|
60 { |
|
61 case '0': |
|
62 { |
|
63 iManager.Write(_L8("About to connect to USBMan")); |
|
64 TInt res = iUsbMan.Connect(); |
|
65 if(res != KErrNone) |
|
66 { |
|
67 iManager.Write(_L8("Connection to USBMan failed")); |
|
68 } |
|
69 else |
|
70 { |
|
71 iManager.Write(_L8("Now connected to USBMan")); |
|
72 } |
|
73 } |
|
74 break; |
|
75 |
|
76 case '1': |
|
77 { |
|
78 iManager.Write(_L8("About to start USBMan")); |
|
79 TRequestStatus requestStatus; |
|
80 iUsbMan.Start(requestStatus); |
|
81 User::WaitForRequest(requestStatus); |
|
82 if(requestStatus.Int() == KErrNone) |
|
83 { |
|
84 iManager.Write(_L8("USBMan Started OK")); |
|
85 } |
|
86 else |
|
87 { |
|
88 iManager.Write(_L8("Failed to start USBMan")); |
|
89 } |
|
90 } |
|
91 break; |
|
92 case '2': |
|
93 { |
|
94 iManager.Write(_L8("About to stop USBMan")); |
|
95 TRequestStatus requestStatus; |
|
96 iUsbMan.Stop(requestStatus); |
|
97 User::WaitForRequest(requestStatus); |
|
98 if(requestStatus.Int() == KErrNone) |
|
99 { |
|
100 iManager.Write(_L8("USBMan Stopped OK")); |
|
101 } |
|
102 else |
|
103 { |
|
104 iManager.Write(_L8("Failed to stop USBMan")); |
|
105 } |
|
106 } |
|
107 break; |
|
108 case '3': |
|
109 { |
|
110 TInt state = KErrUnknown; |
|
111 iRepository->Get(iId, state); |
|
112 iManager.Write(_L8("CenRep Enable setting is: <%d>"), state); |
|
113 } |
|
114 break; |
|
115 case '4': |
|
116 { |
|
117 TInt state = KErrUnknown; |
|
118 iRepository->Get(iId, state); |
|
119 iManager.Write(_L8("CenRep Enable setting is: <%d>"), state); |
|
120 if(state == EUsbBatteryChargingUserSettingDisabled) |
|
121 { |
|
122 iRepository->Set(iId, EUsbBatteryChargingUserSettingEnabled); |
|
123 } |
|
124 else |
|
125 { |
|
126 iRepository->Set(iId, EUsbBatteryChargingUserSettingDisabled); |
|
127 } |
|
128 |
|
129 iRepository->Get(iId, state); |
|
130 iManager.Write(_L8("CenRep Enable setting is now: <%d>"), state); |
|
131 } |
|
132 break; |
|
133 |
|
134 |
|
135 default: |
|
136 iManager.Write(_L8("Unknown selection")); |
|
137 break; |
|
138 } |
|
139 } |
|
140 |
|
141 void CUsbChargingArmTest::DisplayTestSpecificMenu() |
|
142 { |
|
143 iManager.Write(_L8("0 - RUsb::Connect")); |
|
144 iManager.Write(_L8("1 - RUsb::Start")); |
|
145 iManager.Write(_L8("2 - RUsb::Stop")); |
|
146 iManager.Write(_L8("3 - CenRep Enable setting read")); |
|
147 iManager.Write(_L8("4 - CenRep Enable setting toggle")); |
|
148 |
|
149 // -- Add test titles here |
|
150 } |
|
151 |