|
1 // Copyright (c) 2005-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 "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 // This is a defect fix for the following defect |
|
15 // INC040672 - MMC Card door open causes wrong mime type instead of error code |
|
16 // This test is fully automated and performs the following task |
|
17 // Tests to access a file which is on MMC and the MMC card is removed at the time of access. |
|
18 // |
|
19 // |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include "testableapalssession.h" |
|
27 #include "T_AutoMMCReaderOpen.h" |
|
28 |
|
29 const TInt KDirLength = 5; // No need of length more than this , hence length is 5 |
|
30 |
|
31 CTestAutoMMCReaderStep::~CTestAutoMMCReaderStep() |
|
32 { |
|
33 } |
|
34 |
|
35 CTestAutoMMCReaderStep::CTestAutoMMCReaderStep() |
|
36 { |
|
37 SetTestStepName(KTestAutoMMCReaderOpenStep); |
|
38 } |
|
39 |
|
40 TVerdict CTestAutoMMCReaderStep::doTestStepPreambleL() |
|
41 /** |
|
42 @return - TVerdict code |
|
43 Override of base class virtual |
|
44 */ |
|
45 { |
|
46 SetTestStepResult(EPass); |
|
47 return TestStepResult(); |
|
48 } |
|
49 |
|
50 TVerdict CTestAutoMMCReaderStep::doTestStepPostambleL() |
|
51 /** |
|
52 @return - TVerdict code |
|
53 Override of base class virtual |
|
54 */ |
|
55 { |
|
56 return TestStepResult(); |
|
57 } |
|
58 |
|
59 TVerdict CTestAutoMMCReaderStep::doTestStepL() |
|
60 { |
|
61 INFO_PRINTF1(_L("Testing Apparch...T_AutoMMCReaderOpen")); |
|
62 |
|
63 OpenMMCCardReaderDrive(); |
|
64 INFO_PRINTF1(_L("\nT_AutoMMCReaderOpen Completed.")); |
|
65 return TestStepResult(); |
|
66 } |
|
67 |
|
68 void CTestAutoMMCReaderStep::OpenMMCCardReaderDrive() |
|
69 { |
|
70 INFO_PRINTF1(_L("Testing fix for INC040672 - MMC Card door open causes wrong mime type instead of error code")); |
|
71 |
|
72 _LIT(KValidFileName, "ValidFileName.jpg"); |
|
73 |
|
74 RFs fs; |
|
75 TInt ret = fs.Connect(); |
|
76 TEST(ret == KErrNone); |
|
77 RTestableApaLsSession ls; |
|
78 ret = ls.Connect(); |
|
79 TEST(ret == KErrNone); |
|
80 |
|
81 // The following steps are to reproduce the removal of MMC card |
|
82 // Loop through drive letters Y -> D to access a file on that drive (any filename) |
|
83 // Find a drive letter that returns KErrNotReady , |
|
84 // setup a valid filename with that drive. |
|
85 |
|
86 for (TInt drive = EDriveY; drive >= EDriveD ; drive--) |
|
87 { |
|
88 TDriveUnit driveUnit(drive); |
|
89 TDriveName driveName = driveUnit.Name(); |
|
90 |
|
91 TBuf<KDirLength> bufDirName(driveName); |
|
92 bufDirName.Append(_L("\\")); |
|
93 |
|
94 ret = fs.MkDirAll(bufDirName); |
|
95 if (ret == KErrNotReady) |
|
96 { |
|
97 TFileName bufValidFileName(bufDirName); |
|
98 bufValidFileName.Append(KValidFileName); |
|
99 TDataType dataType; |
|
100 TUid uid = KNullUid; |
|
101 |
|
102 HEAP_TEST_LS_SESSION(ls, 0, 0, ret = ls.AppForDocument(bufValidFileName, uid, dataType), NO_CLEANUP); |
|
103 TEST(ret == KErrNotReady); |
|
104 TEST(uid == KNullUid); |
|
105 TEST(dataType == TDataType()); |
|
106 break; |
|
107 } |
|
108 } |
|
109 TEST(ret == KErrNotReady); |
|
110 ls.Close(); |
|
111 fs.Close(); |
|
112 } |