|
1 package com.nokia.testfw.launch.processor; |
|
2 |
|
3 import java.io.File; |
|
4 |
|
5 import junit.framework.TestCase; |
|
6 |
|
7 import org.eclipse.core.resources.IProject; |
|
8 import org.eclipse.core.resources.ResourcesPlugin; |
|
9 import org.eclipse.debug.core.DebugPlugin; |
|
10 import org.eclipse.debug.core.ILaunchConfigurationType; |
|
11 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
|
12 import org.eclipse.debug.core.ILaunchManager; |
|
13 import org.junit.Before; |
|
14 import org.junit.Test; |
|
15 |
|
16 import com.nokia.cdt.debug.cw.symbian.SettingsData; |
|
17 import com.nokia.testfw.core.model.result.TestCaseResult; |
|
18 import com.nokia.testfw.core.model.result.TestResultListener; |
|
19 import com.nokia.testfw.core.model.result.TestRunResult; |
|
20 import com.nokia.testfw.core.model.result.TestResult.TestStatus; |
|
21 import com.nokia.testfw.launch.LaunchConfigurationConstants; |
|
22 import com.nokia.testfw.test.utils.ProjectUtils; |
|
23 |
|
24 @SuppressWarnings("restriction") |
|
25 public class STFProcessorTest extends TestCase { |
|
26 |
|
27 ILaunchConfigurationWorkingCopy iLaunchConfigurationWorkingCopy; |
|
28 boolean isStarted = false; |
|
29 boolean isFinished = false; |
|
30 boolean isAddTestCase = false; |
|
31 boolean isTestCaseStateChange = false; |
|
32 IProject targetProject; |
|
33 |
|
34 @Before |
|
35 public void setUp() throws Exception { |
|
36 targetProject = ProjectUtils.getTargetProject("TestModule"); |
|
37 if (targetProject == null) { |
|
38 String projectPath = (new File("resource/TestModule")) |
|
39 .getCanonicalPath(); |
|
40 String bldInfPath = "group/bld.inf"; |
|
41 targetProject = ProjectUtils.createTargetProject("TestModule", |
|
42 projectPath, bldInfPath); |
|
43 } |
|
44 ProjectUtils.selectProject(targetProject); |
|
45 |
|
46 ILaunchManager lLaunchManager = DebugPlugin.getDefault() |
|
47 .getLaunchManager(); |
|
48 ILaunchConfigurationType type = lLaunchManager |
|
49 .getLaunchConfigurationType("com.nokia.testfw.launch.STFEmulationLaunch"); |
|
50 iLaunchConfigurationWorkingCopy = type.newInstance(null, |
|
51 "STFProcessorTest"); |
|
52 |
|
53 SettingsData |
|
54 .setDefaults( |
|
55 iLaunchConfigurationWorkingCopy, |
|
56 "com.nokia.cdt.debug.cw.symbian.SettingsData.LaunchConfig_Emulator", |
|
57 targetProject); |
|
58 iLaunchConfigurationWorkingCopy.setAttribute( |
|
59 "org.eclipse.cdt.launch.PROGRAM_ARGUMENTS", |
|
60 "-m TestScripter -s C:\\TestFramework\\TestModuleTests.cfg"); |
|
61 String host_path = ResourcesPlugin.getWorkspace().getRoot() |
|
62 .getLocation().append("TestModule\\group\\TestModuleTests.cfg") |
|
63 .toString(); |
|
64 iLaunchConfigurationWorkingCopy.setAttribute( |
|
65 LaunchConfigurationConstants.SCRIPT_HOST_PATH, host_path); |
|
66 } |
|
67 |
|
68 @Test |
|
69 public void testProcess() { |
|
70 |
|
71 TestRunResult lTestRunResult = new TestRunResult(); |
|
72 lTestRunResult.addResultListener(new TestResultListener() { |
|
73 |
|
74 public void addTestCase(TestCaseResult result) { |
|
75 isAddTestCase = true; |
|
76 } |
|
77 |
|
78 public void testCaseStateChange(TestCaseResult result, |
|
79 TestStatus status) { |
|
80 isTestCaseStateChange = true; |
|
81 } |
|
82 |
|
83 public void testFinished() { |
|
84 isFinished = true; |
|
85 } |
|
86 |
|
87 public void testStarted() { |
|
88 isStarted = true; |
|
89 } |
|
90 }); |
|
91 String info = "19.Jan.2010 09:01:29.596....############################################################\n" |
|
92 + "19.Jan.2010 09:01:29.606....CTestEngine::AddTestModuleL, Adding Module:[testscripter]\n" |
|
93 + "19.Jan.2010 09:01:29.606....NOTE: Test module is TestScripter and each test case(config) file(s) will have own server(s)\n" |
|
94 + "19.Jan.2010 09:01:29.606....CTestEngine::AddTestModuleL, module added correctly\n" |
|
95 + "19.Jan.2010 09:01:29.606....Adding config file [c:\testframework\testmoduletests.cfg] to [testscripter] module\n" |
|
96 + "19.Jan.2010 09:01:29.606....CTestScripterController::AddConfigFileL aConfigFile=[c:\testframework\testmoduletests.cfg]\n" |
|
97 + "19.Jan.2010 09:01:29.606....Creating CTestModuleController [testscripter_testmoduletests]\n" |
|
98 + "19.Jan.2010 09:01:29.611....Initialising test module [testscripter_testmoduletests] with initialization file []\n" |
|
99 + "19.Jan.2010 09:01:29.656....Initialising test module [testscripter_testmoduletests] with initialization file [] done\n" |
|
100 + "19.Jan.2010 09:01:29.656....CTestModuleController::AddConfigFileL [testscripter_testmoduletests] aConfigFile=[c:\testframework\testmoduletests.cfg]\n" |
|
101 + "19.Jan.2010 09:01:29.718....CTestEngine::EnumerateTestCasesL\n" |
|
102 + "19.Jan.2010 09:01:29.718....Getting testcases from module [testscripter_testmoduletests], test case file[c:\testframework\testmoduletests.cfg]\n" |
|
103 + "19.Jan.2010 09:01:29.801....RunL()'s GetTestCases method returns: 0\n" |
|
104 + "19.Jan.2010 09:01:29.801....Test case enumeration completed, testcase count 11\n" |
|
105 + "19.Jan.2010 09:01:29.801....Module controllers handling mode: normal\n" |
|
106 + "19.Jan.2010 09:01:29.801....Find test module controller for [testscripter_testmoduletests]\n" |
|
107 + "19.Jan.2010 09:01:29.801....Found test module controller for [testscripter_testmoduletests]\n" |
|
108 + "19.Jan.2010 09:01:29.806.... Starting testcase [Passing case]\n" |
|
109 + "19.Jan.2010 09:01:30.140.... TestCase [Passing case] finished with verdict[-2]\n" |
|
110 + "19.Jan.2010 09:01:31.958....Module controllers handling mode: normal\n" |
|
111 + "19.Jan.2010 09:01:31.958....Find test module controller for [testscripter_testmoduletests]\n" |
|
112 + "19.Jan.2010 09:01:31.958....Found test module controller for [testscripter_testmoduletests]\n" |
|
113 + "19.Jan.2010 09:01:31.958.... Starting testcase [Printing with too long text]\n" |
|
114 + "19.Jan.2010 09:01:32.296.... TestCase [Printing with too long text] finished with verdict[-2]\n" |
|
115 + "19.Jan.2010 09:01:32.301....Module controllers handling mode: normal\n" |
|
116 + "19.Jan.2010 09:01:32.301....Find test module controller for [testscripter_testmoduletests]\n" |
|
117 + "19.Jan.2010 09:01:32.301....Found test module controller for [testscripter_testmoduletests]\n" |
|
118 + "19.Jan.2010 09:01:32.301.... Starting testcase [Printing with too long desc&text]\n" |
|
119 + "19.Jan.2010 09:01:32.625.... TestCase [Printing with too long desc&text] finished with verdict[-2]\n" |
|
120 + "19.Jan.2010 09:01:33.301....Module controllers handling mode: normal\n" |
|
121 + "19.Jan.2010 09:01:33.301....Find test module controller for [testscripter_testmoduletests]\n" |
|
122 + "19.Jan.2010 09:01:33.301....Found test module controller for [testscripter_testmoduletests]\n" |
|
123 + "19.Jan.2010 09:01:33.301.... Starting testcase [Printing with empty desc twice]\n" |
|
124 + "19.Jan.2010 09:01:33.640.... TestCase [Printing with empty desc twice] finished with verdict[-2]\n" |
|
125 + "19.Jan.2010 09:01:33.645....CTestEngine::RemoveTestModuleL\n" |
|
126 + "19.Jan.2010 09:01:33.645....Going to remove module controller [testscripter]\n" |
|
127 + "19.Jan.2010 09:01:33.645....Removing module controller [testscripter]\n" |
|
128 + "19.Jan.2010 09:01:33.650....CTestEngine::CloseTestEngineL\n" |
|
129 + "19.Jan.2010 09:01:33.660....CTestEngine::CloseSession\n" |
|
130 + "19.Jan.2010 09:01:33.660....---------------- Log Ended ----------------\n"; |
|
131 STFProcessor processor = new STFProcessor(); |
|
132 processor.initTestResult(lTestRunResult, |
|
133 iLaunchConfigurationWorkingCopy); |
|
134 processor.process(lTestRunResult, info); |
|
135 assertTrue(isStarted); |
|
136 assertTrue(isFinished); |
|
137 assertTrue(isTestCaseStateChange); |
|
138 } |
|
139 |
|
140 @Test |
|
141 public void testGetInputStream() { |
|
142 assertNotNull(new STFProcessor() |
|
143 .getInputStream(iLaunchConfigurationWorkingCopy)); |
|
144 } |
|
145 |
|
146 @Test |
|
147 public void testIsDealType() { |
|
148 assertTrue(new STFProcessor() |
|
149 .isDealType(iLaunchConfigurationWorkingCopy)); |
|
150 } |
|
151 |
|
152 @Test |
|
153 public void testCreateRetestLaunchConfiguration() { |
|
154 return; |
|
155 } |
|
156 |
|
157 @Test |
|
158 public void testInitTestResult() { |
|
159 TestRunResult lTestRunResult = new TestRunResult(); |
|
160 lTestRunResult.addResultListener(new TestResultListener() { |
|
161 |
|
162 public void addTestCase(TestCaseResult result) { |
|
163 isAddTestCase = true; |
|
164 } |
|
165 |
|
166 public void testCaseStateChange(TestCaseResult result, |
|
167 TestStatus status) { |
|
168 isTestCaseStateChange = true; |
|
169 } |
|
170 |
|
171 public void testFinished() { |
|
172 isFinished = true; |
|
173 } |
|
174 |
|
175 public void testStarted() { |
|
176 isStarted = true; |
|
177 } |
|
178 }); |
|
179 new STFProcessor().initTestResult(lTestRunResult, |
|
180 iLaunchConfigurationWorkingCopy); |
|
181 assertTrue(isAddTestCase); |
|
182 } |
|
183 } |