|
1 // Copyright (c) 2008-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 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tgsa_step_fleximergemanyfiles.h" |
|
23 #include "gsatestappgood.h" |
|
24 #include <f32file.h> |
|
25 #include <s32file.h> |
|
26 _LIT(KTestProcess, "gsatestprocgood.exe"); |
|
27 |
|
28 |
|
29 /** |
|
30 Old Test CaseID AFSS-GSA-0040 |
|
31 New Test CaseID DEVSRVS-SSPLUGINS-GSA-0040 |
|
32 */ |
|
33 void CGsaFlexiMergeManyFilesTest::DoTestFlexiMergeManyFilesL() |
|
34 { |
|
35 INFO_PRINTF1(_L("DoTestFlexiMergeManyFilesL test started....")); |
|
36 TInt num = FindAndKill(KTestProcess); |
|
37 // All fifty command lists are merged and fifty processes are expected |
|
38 INFO_PRINTF2(_L("The number of processes found were: %d"),num); |
|
39 TEST (num == 50); |
|
40 INFO_PRINTF1(_L("DoTestFlexiMergeManyFilesL case completed\n")); |
|
41 } |
|
42 |
|
43 //---------------- CGsaFlexiMergeManyFilesTest step --------------------------------------- |
|
44 |
|
45 |
|
46 CGsaFlexiMergeManyFilesTest::~CGsaFlexiMergeManyFilesTest() |
|
47 { |
|
48 } |
|
49 |
|
50 CGsaFlexiMergeManyFilesTest::CGsaFlexiMergeManyFilesTest() |
|
51 { |
|
52 SetTestStepName(KTGsaFlexiMergeManyFilesStep); |
|
53 } |
|
54 |
|
55 TVerdict CGsaFlexiMergeManyFilesTest::doTestStepPreambleL() |
|
56 { |
|
57 return CTestStep::doTestStepPreambleL(); |
|
58 } |
|
59 |
|
60 TVerdict CGsaFlexiMergeManyFilesTest::doTestStepPostambleL() |
|
61 { |
|
62 return CTestStep::doTestStepPostambleL(); |
|
63 } |
|
64 |
|
65 TVerdict CGsaFlexiMergeManyFilesTest::doTestStepL() |
|
66 { |
|
67 INFO_PRINTF1(_L("CGsaFlexiMergeManyFilesTest started....")); |
|
68 |
|
69 __UHEAP_MARK; |
|
70 // Run the tests |
|
71 TRAPD(err, DoTestFlexiMergeManyFilesL()); |
|
72 INFO_PRINTF2(_L("DoTestFlexiMergeManyFilesL test completed with %d...."),err); |
|
73 TEST(err == KErrNone); |
|
74 __UHEAP_MARKEND; |
|
75 |
|
76 INFO_PRINTF1(_L("....CGsaFlexiMergeManyFilesTest completed!!")); |
|
77 return TestStepResult(); |
|
78 } |
|
79 |
|
80 /** |
|
81 Helper function to find and kill the specified process |
|
82 */ |
|
83 TInt CGsaFlexiMergeManyFilesTest::FindAndKill(const TDesC& aProcessName) |
|
84 { |
|
85 TFullName searchTerm(aProcessName); |
|
86 StripExtension(searchTerm); |
|
87 searchTerm += _L("*"); |
|
88 TFindProcess find(searchTerm); |
|
89 TFullName name; |
|
90 TInt instancesFound = 0; |
|
91 while(find.Next(name) == KErrNone) |
|
92 { |
|
93 RProcess process; |
|
94 const TInt err = process.Open(find); |
|
95 |
|
96 if (KErrNone == err) |
|
97 { |
|
98 if (process.ExitType() == EExitPending) |
|
99 { |
|
100 instancesFound++; |
|
101 process.Kill(KErrCancel); |
|
102 process.Close(); |
|
103 INFO_PRINTF2(_L("Process %S found and killed"), &aProcessName); |
|
104 } |
|
105 process.Close(); |
|
106 } |
|
107 } |
|
108 return instancesFound; |
|
109 } |
|
110 |
|
111 /** |
|
112 Helper function to strip extension |
|
113 */ |
|
114 void CGsaFlexiMergeManyFilesTest::StripExtension(TDes& aFilename) |
|
115 { |
|
116 TInt dot = aFilename.Find(_L(".")); |
|
117 |
|
118 if(KErrNotFound != dot) |
|
119 { |
|
120 aFilename.SetLength(dot); |
|
121 } |
|
122 } |
|
123 |