|
1 /* |
|
2 * Copyright (c) 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 // User includes |
|
19 #include "TestFSCreateFile.h" |
|
20 // Literal constants |
|
21 _LIT(KFileName, "filename"); |
|
22 |
|
23 CTestFSCreateFile::CTestFSCreateFile() |
|
24 /** |
|
25 Constructor. |
|
26 |
|
27 Sets the test step name. |
|
28 */ |
|
29 { |
|
30 // Call base class method to set up the human readable name for logging |
|
31 SetTestStepName(KCreateFile); |
|
32 } |
|
33 |
|
34 CTestFSCreateFile::~CTestFSCreateFile() |
|
35 /** |
|
36 Destructor |
|
37 */ |
|
38 { |
|
39 } |
|
40 |
|
41 TVerdict CTestFSCreateFile::doTestStepL() |
|
42 /** |
|
43 This is implementation of the pure virtual function of CTestStep. |
|
44 It creates files or directories |
|
45 @return TVerdict - the test result |
|
46 */ |
|
47 { |
|
48 INFO_PRINTF1(_L("In test step CreateFile")); |
|
49 |
|
50 if (TestStepResult() == EPass) |
|
51 { |
|
52 |
|
53 // Get file or directory name |
|
54 TPtrC file; |
|
55 if (GetStringFromConfig(ConfigSection(), KFileName, file)) |
|
56 { |
|
57 INFO_PRINTF2(_L("File name %S"), &file); |
|
58 } |
|
59 else |
|
60 { |
|
61 ERR_PRINTF1(_L("No File Name")); |
|
62 SetTestStepResult(EFail); |
|
63 } |
|
64 |
|
65 RFile rf; |
|
66 RFs fileSession; |
|
67 CleanupClosePushL(rf); |
|
68 TRAPD(error, fileSession.Connect()) |
|
69 if ( error != KErrNone) |
|
70 { |
|
71 ERR_PRINTF2(_L("File Session connect error, %d"), error); |
|
72 SetTestStepResult(EFail); |
|
73 } |
|
74 CleanupClosePushL(fileSession); |
|
75 TInt errCode = rf.Create(fileSession, file, EFileWrite); |
|
76 CleanupStack::PopAndDestroy(&fileSession); |
|
77 CleanupStack::PopAndDestroy(&rf); |
|
78 |
|
79 |
|
80 if (KErrNone != errCode) |
|
81 { |
|
82 SetTestStepError(errCode); |
|
83 ERR_PRINTF2(_L("--->Error in Creating file, get result %D"), errCode); |
|
84 SetTestStepResult(EFail); |
|
85 } |
|
86 |
|
87 } |
|
88 return TestStepResult(); |
|
89 } |
|
90 |