1 /* |
|
2 * Copyright (c) 2008-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 the License "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 #include "deletescrdbstep.h" |
|
20 |
|
21 // -----------CScrDeleteDbFileStep----------------- |
|
22 |
|
23 CScrDeleteDbFileStep::CScrDeleteDbFileStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
24 { |
|
25 } |
|
26 |
|
27 void CScrDeleteDbFileStep::ImplTestStepPreambleL() |
|
28 { |
|
29 User::LeaveIfError(iScrAccessor.Connect()); |
|
30 } |
|
31 |
|
32 void CScrDeleteDbFileStep::DeleteFileL(const TDesC& aFilePath) |
|
33 { |
|
34 TInt err = iScrAccessor.DeleteFile(aFilePath); |
|
35 TInt tries = 0; |
|
36 |
|
37 while((KErrNone != err && KErrNotFound != err && KErrPathNotFound != err) && tries++ < 60) |
|
38 { |
|
39 User::After(500000); |
|
40 err = iScrAccessor.DeleteFile(aFilePath); |
|
41 } |
|
42 if(KErrNone != err && KErrNotFound != err && KErrPathNotFound != err) |
|
43 { |
|
44 ERR_PRINTF3(_L("%S file couldn't be deleted! Error=%d"), &aFilePath, err); |
|
45 SetTestStepResult(EFail); |
|
46 } |
|
47 } |
|
48 |
|
49 void CScrDeleteDbFileStep::ImplTestStepL() |
|
50 { |
|
51 TPtrC dbFilePath; |
|
52 if (!GetStringFromConfig(ConfigSection(), _L("DbFilePath"), dbFilePath)) |
|
53 PrintErrorL(_L("Database File Path was not found!"), KErrNotFound); |
|
54 |
|
55 TPtrC journalFilePath; |
|
56 if (!GetStringFromConfig(ConfigSection(), _L("JournalFilePath"), journalFilePath)) |
|
57 PrintErrorL(_L("Journal File Path was not found!"), KErrNotFound); |
|
58 |
|
59 DeleteFileL(dbFilePath); |
|
60 DeleteFileL(journalFilePath); |
|
61 User::After(500000); |
|
62 } |
|
63 |
|
64 void CScrDeleteDbFileStep::ImplTestStepPostambleL() |
|
65 { |
|
66 iScrAccessor.Close(); |
|
67 } |
|
68 |
|
69 // -----------CScrCopyDbFileStep----------------- |
|
70 |
|
71 CScrCopyDbFileStep::CScrCopyDbFileStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
72 { |
|
73 } |
|
74 |
|
75 void CScrCopyDbFileStep::ImplTestStepPreambleL() |
|
76 { |
|
77 User::LeaveIfError(iScrAccessor.Connect()); |
|
78 } |
|
79 |
|
80 |
|
81 void CScrCopyDbFileStep::ImplTestStepL() |
|
82 { |
|
83 TPtrC sourceFilePath; |
|
84 if (!GetStringFromConfig(ConfigSection(), _L("SourceFilePath"), sourceFilePath)) |
|
85 PrintErrorL(_L("Source File Path was not found!"), KErrNotFound); |
|
86 |
|
87 TPtrC targetFilePath; |
|
88 if (!GetStringFromConfig(ConfigSection(), _L("TargetFilePath"), targetFilePath)) |
|
89 PrintErrorL(_L("Target File Path was not found!"), KErrNotFound); |
|
90 |
|
91 User::LeaveIfError(iScrAccessor.CopyFile(sourceFilePath, targetFilePath)); |
|
92 } |
|
93 |
|
94 void CScrCopyDbFileStep::ImplTestStepPostambleL() |
|
95 { |
|
96 iScrAccessor.Close(); |
|
97 } |
|