|
1 // Copyright (c) 2004-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 // |
|
15 |
|
16 #include "TestPlayerUtils.h" |
|
17 #include "OpenFileByHandle7803.h" |
|
18 |
|
19 #include <caf/caf.h> |
|
20 |
|
21 CTestMmfAclntOpenFile7803::CTestMmfAclntOpenFile7803(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName) |
|
22 : CTestMmfAclntAudioPlayerUtil(aTestName, aSectName), iKeyName(aKeyName) |
|
23 {} |
|
24 |
|
25 CTestMmfAclntOpenFile7803* CTestMmfAclntOpenFile7803::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName) |
|
26 { |
|
27 CTestMmfAclntOpenFile7803* self = new (ELeave) CTestMmfAclntOpenFile7803(aTestName, aSectName, aKeyName); |
|
28 return self; |
|
29 } |
|
30 |
|
31 /** |
|
32 * Open new file. |
|
33 */ |
|
34 TVerdict CTestMmfAclntOpenFile7803::DoTestL(CMdaAudioPlayerUtility* aPlayer) |
|
35 { |
|
36 return( PerformTestL( aPlayer ) ); |
|
37 } |
|
38 |
|
39 TVerdict CTestMmfAclntOpenFile7803::PerformTestL(CMdaAudioPlayerUtility* aPlayer) |
|
40 { |
|
41 TVerdict ret = EPass; |
|
42 aPlayer->Close(); |
|
43 |
|
44 RFs fs; |
|
45 |
|
46 // read optional test specific parameters |
|
47 iSkipShareProtected = iExpectToFail = EFalse; |
|
48 iExpectedError = KErrNone; |
|
49 // read the parameters, if any missing just ignore |
|
50 GetBoolFromConfig(iDefaultParamSet, _L("SkipShareProtected"), iSkipShareProtected); |
|
51 GetBoolFromConfig(iDefaultParamSet, _L("ExpectToFail"), iExpectToFail); |
|
52 GetIntFromConfig(iDefaultParamSet, _L("ExpectedError"), iExpectedError); |
|
53 |
|
54 User::LeaveIfError(fs.Connect()); |
|
55 CleanupClosePushL(fs); |
|
56 if (!iSkipShareProtected) |
|
57 { |
|
58 User::LeaveIfError(fs.ShareProtected()); |
|
59 } |
|
60 |
|
61 // get second file name |
|
62 TBuf<KSizeBuf> filename2; |
|
63 TPtrC filename; |
|
64 |
|
65 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
66 { |
|
67 return EInconclusive; |
|
68 } |
|
69 |
|
70 GetDriveName(filename2); |
|
71 filename2.Append(filename); |
|
72 |
|
73 RFile file; |
|
74 User::LeaveIfError( file.Open( fs, filename2, EFileRead ) ); |
|
75 CleanupClosePushL(file); |
|
76 |
|
77 // Open second file |
|
78 aPlayer->OpenFileL(file); |
|
79 // wait for open to complete |
|
80 CActiveScheduler::Start(); |
|
81 |
|
82 INFO_PRINTF2( _L("OpenFileL completed with error %d"), iError); |
|
83 |
|
84 if( iError != KErrNone ) |
|
85 { |
|
86 if (iExpectToFail && iError == iExpectedError) |
|
87 { |
|
88 INFO_PRINTF2( _L("Error matches expected %d"), iExpectedError); |
|
89 ret = EPass; |
|
90 } |
|
91 else if (iExpectToFail) |
|
92 { |
|
93 INFO_PRINTF2( _L("Error does not match %d"), iExpectedError); |
|
94 ret = EFail; |
|
95 } |
|
96 else |
|
97 { |
|
98 INFO_PRINTF1( _L("No error was expected")); |
|
99 ret = EFail; |
|
100 } |
|
101 } |
|
102 else |
|
103 { |
|
104 aPlayer->Play(); |
|
105 CActiveScheduler::Start(); |
|
106 |
|
107 if( iError != KErrNone ) |
|
108 { |
|
109 ret = EFail; |
|
110 } |
|
111 |
|
112 User::After(1000000); |
|
113 aPlayer->Stop(); |
|
114 aPlayer->Close(); |
|
115 } |
|
116 |
|
117 CleanupStack::PopAndDestroy(2, &fs); |
|
118 return ret; |
|
119 } |