|
1 /* |
|
2 * Copyright (c) 2004-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 /** |
|
19 @file |
|
20 */ |
|
21 #include <test/testexecutelog.h> |
|
22 #include "CUsbTestStepBase.h" |
|
23 #include "CStartNewPersonality.h" |
|
24 |
|
25 CStartNewPersonality::CStartNewPersonality() |
|
26 |
|
27 { |
|
28 // Call base class method to set up the human readable name for logging |
|
29 SetTestStepName(KStartNewPersonality); |
|
30 //We need the service to continue running after the test so that usbcheck |
|
31 //can find the device connected to the PC. |
|
32 iStopService = EFalse; |
|
33 } |
|
34 |
|
35 TVerdict CStartNewPersonality::doTestStepL() |
|
36 { |
|
37 SetTestStepResult(EFail); |
|
38 //Read personality from ini file |
|
39 TInt personality; |
|
40 _LIT(KPersonality, "personality"); |
|
41 if (!GetIntFromConfig(ConfigSection(), KPersonality, personality)) |
|
42 { |
|
43 INFO_PRINTF1(_L("Can't get personality id from config file")); |
|
44 return TestStepResult(); |
|
45 } |
|
46 |
|
47 TInt err; |
|
48 err = SetIdle(iUsb); |
|
49 if (err != KErrNone) |
|
50 { |
|
51 INFO_PRINTF2(_L("Unable to stop USB service: %d"), err); |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 //TryStart with new personality |
|
56 TUsbServiceState state; |
|
57 TRequestStatus status; |
|
58 iUsb.TryStart(personality, status); |
|
59 User::WaitForRequest(status); |
|
60 if (status != KErrNone) |
|
61 { |
|
62 INFO_PRINTF2(_L("Unable to start USB service: %d"), status.Int()); |
|
63 return TestStepResult(); |
|
64 } |
|
65 err = iUsb.GetServiceState(state); |
|
66 if (err != KErrNone) |
|
67 { |
|
68 INFO_PRINTF2(_L("GetServiceState returned error code %d"), err); |
|
69 return TestStepResult(); |
|
70 } |
|
71 if (state != EUsbServiceStarted) |
|
72 { |
|
73 INFO_PRINTF2(_L("USB service is in the wrong state: %d"), state); |
|
74 return TestStepResult(); |
|
75 } |
|
76 |
|
77 SetTestStepResult(EPass); |
|
78 return TestStepResult(); |
|
79 } |
|
80 |