|
1 // Copyright (c) 1998-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 the License "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 // e32test\window\t_mmcpw.cpp |
|
15 // Tests MMC card password notifier |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32svr.h> |
|
20 |
|
21 #include <e32test.h> |
|
22 #include <e32twin.h> |
|
23 #include <e32def.h> |
|
24 #include <e32def_private.h> |
|
25 #include <e32std.h> |
|
26 #include <e32std_private.h> |
|
27 |
|
28 static RTest test(_L("T_MMCPW")); |
|
29 |
|
30 GLDEF_C TInt E32Main() |
|
31 { |
|
32 test.Start(_L("E32Main")); |
|
33 |
|
34 test.Next(_L("Creating notifier.")); |
|
35 RNotifier n; |
|
36 |
|
37 test.Next(_L("Connected to notify server.")); |
|
38 TInt r; |
|
39 test((r = n.Connect()) == KErrNone); |
|
40 |
|
41 TPckgBuf<TMediaPswdSendNotifyInfoV1> send; |
|
42 send().iVersion = TVersion(1, 0, 0); |
|
43 TPckgBuf<TMediaPswdReplyNotifyInfoV1> reply; |
|
44 reply().iVersion = TVersion(1, 0, 0); |
|
45 |
|
46 test.Next(_L("Launching notify server.")); |
|
47 TRequestStatus rs; |
|
48 n.StartNotifierAndGetResponse(rs, TUid::Uid(KMediaPasswordNotifyUid), send, reply); |
|
49 |
|
50 test.Next(_L("Waiting for dialog to respond.")); |
|
51 User::WaitForRequest(rs); |
|
52 |
|
53 test.Next(_L("Reading exit mode and resultant password.")); |
|
54 test(reply().iEM == EMPEMUnlock || reply().iEM == EMPEMCancel || reply().iEM == EMPEMUnlockAndStore); |
|
55 test.Printf(_L("reply().iEM = %d(d).\n"), TInt(reply().iEM)); |
|
56 |
|
57 switch (reply().iEM) |
|
58 { |
|
59 case EMPEMUnlock: |
|
60 case EMPEMUnlockAndStore: |
|
61 { |
|
62 if (reply().iEM == EMPEMUnlock) |
|
63 test.Printf(_L("EMPEMUnlock selected.\n")); |
|
64 else |
|
65 test.Printf(_L("EMPEMUnlockAndStore selected.\n")); |
|
66 |
|
67 TMediaPassword pw; |
|
68 pw.Copy(reply().iPW, KMaxMediaPassword); |
|
69 |
|
70 TInt i; // bad for-scope under VC |
|
71 |
|
72 for (i = 0; i < KMaxMediaPassword; i++) |
|
73 test.Printf(_L("%02x "), pw[i]); |
|
74 test.Printf(_L("\n")); |
|
75 |
|
76 for (i = 0; i < KMaxMediaPassword; i++) |
|
77 test.Printf(_L("%02x "), i); |
|
78 test.Printf(_L("\n")); |
|
79 } |
|
80 break; |
|
81 |
|
82 case EMPEMCancel: |
|
83 test.Printf(_L("EMPEMCancel selected.\n")); |
|
84 break; |
|
85 } |
|
86 |
|
87 test.Next(_L("Closing notifier.")); |
|
88 n.Close(); |
|
89 |
|
90 test.Getch(); |
|
91 |
|
92 test.End(); |
|
93 |
|
94 return KErrNone; |
|
95 } |
|
96 |