OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for instrumentation_test_instance.""" | 6 """Unit tests for instrumentation_test_instance.""" |
7 | 7 |
8 # pylint: disable=protected-access | 8 # pylint: disable=protected-access |
9 | 9 |
10 import collections | 10 import collections |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 'Feature': {'value': ['Bar']}, | 137 'Feature': {'value': ['Bar']}, |
138 'SmallTest': None, | 138 'SmallTest': None, |
139 }, | 139 }, |
140 'class': 'org.chromium.test.SampleTest2', | 140 'class': 'org.chromium.test.SampleTest2', |
141 'method': 'testMethod1', | 141 'method': 'testMethod1', |
142 'is_junit4': True, | 142 'is_junit4': True, |
143 }, | 143 }, |
144 ] | 144 ] |
145 | 145 |
146 o._test_jar = 'path/to/test.jar' | 146 o._test_jar = 'path/to/test.jar' |
147 o._junit4_runner_class = 'J4Runner' | 147 o._test_runner_junit4 = 'J4Runner' |
148 actual_tests = o.ProcessRawTests(raw_tests) | 148 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 149 return_value=raw_tests): |
| 150 actual_tests = o.GetTests() |
149 | 151 |
150 self.assertEquals(actual_tests, expected_tests) | 152 self.assertEquals(actual_tests, expected_tests) |
151 | 153 |
152 def testGetTests_simpleGtestFilter(self): | 154 def testGetTests_simpleGtestFilter(self): |
153 o = self.createTestInstance() | 155 o = self.createTestInstance() |
154 raw_tests = [ | 156 raw_tests = [ |
155 { | 157 { |
156 'annotations': {'Feature': {'value': ['Foo']}}, | 158 'annotations': {'Feature': {'value': ['Foo']}}, |
157 'class': 'org.chromium.test.SampleTest', | 159 'class': 'org.chromium.test.SampleTest', |
158 'superclass': 'java.lang.Object', | 160 'superclass': 'java.lang.Object', |
(...skipping 17 matching lines...) Expand all Loading... |
176 'SmallTest': None, | 178 'SmallTest': None, |
177 }, | 179 }, |
178 'class': 'org.chromium.test.SampleTest', | 180 'class': 'org.chromium.test.SampleTest', |
179 'is_junit4': True, | 181 'is_junit4': True, |
180 'method': 'testMethod1', | 182 'method': 'testMethod1', |
181 }, | 183 }, |
182 ] | 184 ] |
183 | 185 |
184 o._test_filter = 'org.chromium.test.SampleTest.testMethod1' | 186 o._test_filter = 'org.chromium.test.SampleTest.testMethod1' |
185 o._test_jar = 'path/to/test.jar' | 187 o._test_jar = 'path/to/test.jar' |
186 o._junit4_runner_class = 'J4Runner' | 188 o._test_runner_junit4 = 'J4Runner' |
187 actual_tests = o.ProcessRawTests(raw_tests) | 189 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 190 return_value=raw_tests): |
| 191 actual_tests = o.GetTests() |
188 | 192 |
189 self.assertEquals(actual_tests, expected_tests) | 193 self.assertEquals(actual_tests, expected_tests) |
190 | 194 |
191 def testGetTests_simpleGtestUnqualifiedNameFilter(self): | 195 def testGetTests_wildcardGtestFilter(self): |
192 o = self.createTestInstance() | 196 o = self.createTestInstance() |
193 raw_tests = [ | 197 raw_tests = [ |
194 { | 198 { |
195 'annotations': {'Feature': {'value': ['Foo']}}, | 199 'annotations': {'Feature': {'value': ['Foo']}}, |
196 'class': 'org.chromium.test.SampleTest', | 200 'class': 'org.chromium.test.SampleTest', |
197 'superclass': 'java.lang.Object', | 201 'superclass': 'java.lang.Object', |
198 'methods': [ | 202 'methods': [ |
199 { | 203 { |
200 'annotations': {'SmallTest': None}, | 204 'annotations': {'SmallTest': None}, |
201 'method': 'testMethod1', | 205 'method': 'testMethod1', |
202 }, | 206 }, |
203 { | 207 { |
204 'annotations': {'MediumTest': None}, | 208 'annotations': {'MediumTest': None}, |
205 'method': 'testMethod2', | 209 'method': 'testMethod2', |
206 }, | 210 }, |
207 ], | 211 ], |
208 } | |
209 ] | |
210 | |
211 expected_tests = [ | |
212 { | |
213 'annotations': { | |
214 'Feature': {'value': ['Foo']}, | |
215 'SmallTest': None, | |
216 }, | |
217 'class': 'org.chromium.test.SampleTest', | |
218 'is_junit4': True, | |
219 'method': 'testMethod1', | |
220 }, | |
221 ] | |
222 | |
223 o._test_filter = 'SampleTest.testMethod1' | |
224 o._test_jar = 'path/to/test.jar' | |
225 o._junit4_runner_class = 'J4Runner' | |
226 actual_tests = o.ProcessRawTests(raw_tests) | |
227 | |
228 self.assertEquals(actual_tests, expected_tests) | |
229 | |
230 def testGetTests_parameterizedTestGtestFilter(self): | |
231 o = self.createTestInstance() | |
232 raw_tests = [ | |
233 { | |
234 'annotations': {'Feature': {'value': ['Foo']}}, | |
235 'class': 'org.chromium.test.SampleTest', | |
236 'superclass': 'java.lang.Object', | |
237 'methods': [ | |
238 { | |
239 'annotations': {'SmallTest': None}, | |
240 'method': 'testMethod1', | |
241 }, | |
242 { | |
243 'annotations': {'SmallTest': None}, | |
244 'method': 'testMethod1__sandboxed_mode', | |
245 }, | |
246 ], | |
247 }, | 212 }, |
248 { | 213 { |
249 'annotations': {'Feature': {'value': ['Bar']}}, | 214 'annotations': {'Feature': {'value': ['Bar']}}, |
250 'class': 'org.chromium.test.SampleTest2', | 215 'class': 'org.chromium.test.SampleTest2', |
251 'superclass': 'java.lang.Object', | 216 'superclass': 'java.lang.Object', |
252 'methods': [ | 217 'methods': [ |
253 { | 218 { |
254 'annotations': {'SmallTest': None}, | 219 'annotations': {'SmallTest': None}, |
255 'method': 'testMethod1', | 220 'method': 'testMethod1', |
256 }, | 221 }, |
257 ], | 222 ], |
258 } | 223 } |
259 ] | 224 ] |
260 | 225 |
261 expected_tests = [ | 226 expected_tests = [ |
262 { | 227 { |
263 'annotations': { | 228 'annotations': { |
264 'Feature': {'value': ['Foo']}, | |
265 'SmallTest': None, | |
266 }, | |
267 'class': 'org.chromium.test.SampleTest', | |
268 'method': 'testMethod1', | |
269 'is_junit4': True, | |
270 }, | |
271 { | |
272 'annotations': { | |
273 'Feature': {'value': ['Foo']}, | |
274 'SmallTest': None, | |
275 }, | |
276 'class': 'org.chromium.test.SampleTest', | |
277 'method': 'testMethod1__sandboxed_mode', | |
278 'is_junit4': True, | |
279 }, | |
280 ] | |
281 | |
282 o._test_jar = 'path/to/test.jar' | |
283 o._junit4_runner_class = 'J4Runner' | |
284 o._test_filter = 'org.chromium.test.SampleTest.testMethod1' | |
285 actual_tests = o.ProcessRawTests(raw_tests) | |
286 | |
287 self.assertEquals(actual_tests, expected_tests) | |
288 | |
289 def testGetTests_wildcardGtestFilter(self): | |
290 o = self.createTestInstance() | |
291 raw_tests = [ | |
292 { | |
293 'annotations': {'Feature': {'value': ['Foo']}}, | |
294 'class': 'org.chromium.test.SampleTest', | |
295 'superclass': 'java.lang.Object', | |
296 'methods': [ | |
297 { | |
298 'annotations': {'SmallTest': None}, | |
299 'method': 'testMethod1', | |
300 }, | |
301 { | |
302 'annotations': {'MediumTest': None}, | |
303 'method': 'testMethod2', | |
304 }, | |
305 ], | |
306 }, | |
307 { | |
308 'annotations': {'Feature': {'value': ['Bar']}}, | |
309 'class': 'org.chromium.test.SampleTest2', | |
310 'superclass': 'java.lang.Object', | |
311 'methods': [ | |
312 { | |
313 'annotations': {'SmallTest': None}, | |
314 'method': 'testMethod1', | |
315 }, | |
316 ], | |
317 } | |
318 ] | |
319 | |
320 expected_tests = [ | |
321 { | |
322 'annotations': { | |
323 'Feature': {'value': ['Bar']}, | 229 'Feature': {'value': ['Bar']}, |
324 'SmallTest': None, | 230 'SmallTest': None, |
325 }, | 231 }, |
326 'class': 'org.chromium.test.SampleTest2', | 232 'class': 'org.chromium.test.SampleTest2', |
327 'is_junit4': True, | 233 'is_junit4': True, |
328 'method': 'testMethod1', | 234 'method': 'testMethod1', |
329 }, | 235 }, |
330 ] | 236 ] |
331 | 237 |
332 o._test_filter = 'org.chromium.test.SampleTest2.*' | 238 o._test_filter = 'org.chromium.test.SampleTest2.*' |
333 o._test_jar = 'path/to/test.jar' | 239 o._test_jar = 'path/to/test.jar' |
334 o._junit4_runner_class = 'J4Runner' | 240 o._test_runner_junit4 = 'J4Runner' |
335 actual_tests = o.ProcessRawTests(raw_tests) | 241 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 242 return_value=raw_tests): |
| 243 actual_tests = o.GetTests() |
336 | 244 |
337 self.assertEquals(actual_tests, expected_tests) | 245 self.assertEquals(actual_tests, expected_tests) |
338 | 246 |
339 def testGetTests_negativeGtestFilter(self): | 247 def testGetTests_negativeGtestFilter(self): |
340 o = self.createTestInstance() | 248 o = self.createTestInstance() |
341 raw_tests = [ | 249 raw_tests = [ |
342 { | 250 { |
343 'annotations': {'Feature': {'value': ['Foo']}}, | 251 'annotations': {'Feature': {'value': ['Foo']}}, |
344 'class': 'org.chromium.test.SampleTest', | 252 'class': 'org.chromium.test.SampleTest', |
345 'superclass': 'java.lang.Object', | 253 'superclass': 'java.lang.Object', |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 'SmallTest': None, | 291 'SmallTest': None, |
384 }, | 292 }, |
385 'class': 'org.chromium.test.SampleTest2', | 293 'class': 'org.chromium.test.SampleTest2', |
386 'is_junit4': True, | 294 'is_junit4': True, |
387 'method': 'testMethod1', | 295 'method': 'testMethod1', |
388 }, | 296 }, |
389 ] | 297 ] |
390 | 298 |
391 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1' | 299 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1' |
392 o._test_jar = 'path/to/test.jar' | 300 o._test_jar = 'path/to/test.jar' |
393 o._junit4_runner_class = 'J4Runner' | 301 o._test_runner_junit4 = 'J4Runner' |
394 actual_tests = o.ProcessRawTests(raw_tests) | 302 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 303 return_value=raw_tests): |
| 304 actual_tests = o.GetTests() |
395 | 305 |
396 self.assertEquals(actual_tests, expected_tests) | 306 self.assertEquals(actual_tests, expected_tests) |
397 | 307 |
398 def testGetTests_annotationFilter(self): | 308 def testGetTests_annotationFilter(self): |
399 o = self.createTestInstance() | 309 o = self.createTestInstance() |
400 raw_tests = [ | 310 raw_tests = [ |
401 { | 311 { |
402 'annotations': {'Feature': {'value': ['Foo']}}, | 312 'annotations': {'Feature': {'value': ['Foo']}}, |
403 'class': 'org.chromium.test.SampleTest', | 313 'class': 'org.chromium.test.SampleTest', |
404 'superclass': 'java.lang.Object', | 314 'superclass': 'java.lang.Object', |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 'SmallTest': None, | 352 'SmallTest': None, |
443 }, | 353 }, |
444 'class': 'org.chromium.test.SampleTest2', | 354 'class': 'org.chromium.test.SampleTest2', |
445 'is_junit4': True, | 355 'is_junit4': True, |
446 'method': 'testMethod1', | 356 'method': 'testMethod1', |
447 }, | 357 }, |
448 ] | 358 ] |
449 | 359 |
450 o._annotations = [('SmallTest', None)] | 360 o._annotations = [('SmallTest', None)] |
451 o._test_jar = 'path/to/test.jar' | 361 o._test_jar = 'path/to/test.jar' |
452 o._junit4_runner_class = 'J4Runner' | 362 o._test_runner_junit4 = 'J4Runner' |
453 actual_tests = o.ProcessRawTests(raw_tests) | 363 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 364 return_value=raw_tests): |
| 365 actual_tests = o.GetTests() |
454 | 366 |
455 self.assertEquals(actual_tests, expected_tests) | 367 self.assertEquals(actual_tests, expected_tests) |
456 | 368 |
457 def testGetTests_excludedAnnotationFilter(self): | 369 def testGetTests_excludedAnnotationFilter(self): |
458 o = self.createTestInstance() | 370 o = self.createTestInstance() |
459 raw_tests = [ | 371 raw_tests = [ |
460 { | 372 { |
461 'annotations': {'Feature': {'value': ['Foo']}}, | 373 'annotations': {'Feature': {'value': ['Foo']}}, |
462 'class': 'org.chromium.test.SampleTest', | 374 'class': 'org.chromium.test.SampleTest', |
463 'superclass': 'junit.framework.TestCase', | 375 'superclass': 'junit.framework.TestCase', |
(...skipping 28 matching lines...) Expand all Loading... |
492 'MediumTest': None, | 404 'MediumTest': None, |
493 }, | 405 }, |
494 'class': 'org.chromium.test.SampleTest', | 406 'class': 'org.chromium.test.SampleTest', |
495 'is_junit4': False, | 407 'is_junit4': False, |
496 'method': 'testMethod2', | 408 'method': 'testMethod2', |
497 }, | 409 }, |
498 ] | 410 ] |
499 | 411 |
500 o._excluded_annotations = [('SmallTest', None)] | 412 o._excluded_annotations = [('SmallTest', None)] |
501 o._test_jar = 'path/to/test.jar' | 413 o._test_jar = 'path/to/test.jar' |
502 o._junit4_runner_class = 'J4Runner' | 414 o._test_runner_junit4 = 'J4Runner' |
503 actual_tests = o.ProcessRawTests(raw_tests) | 415 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 416 return_value=raw_tests): |
| 417 actual_tests = o.GetTests() |
504 | 418 |
505 self.assertEquals(actual_tests, expected_tests) | 419 self.assertEquals(actual_tests, expected_tests) |
506 | 420 |
507 def testGetTests_annotationSimpleValueFilter(self): | 421 def testGetTests_annotationSimpleValueFilter(self): |
508 o = self.createTestInstance() | 422 o = self.createTestInstance() |
509 raw_tests = [ | 423 raw_tests = [ |
510 { | 424 { |
511 'annotations': {'Feature': {'value': ['Foo']}}, | 425 'annotations': {'Feature': {'value': ['Foo']}}, |
512 'class': 'org.chromium.test.SampleTest', | 426 'class': 'org.chromium.test.SampleTest', |
513 'superclass': 'junit.framework.TestCase', | 427 'superclass': 'junit.framework.TestCase', |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 'TestValue': '1', | 466 'TestValue': '1', |
553 }, | 467 }, |
554 'class': 'org.chromium.test.SampleTest', | 468 'class': 'org.chromium.test.SampleTest', |
555 'is_junit4': False, | 469 'is_junit4': False, |
556 'method': 'testMethod1', | 470 'method': 'testMethod1', |
557 }, | 471 }, |
558 ] | 472 ] |
559 | 473 |
560 o._annotations = [('TestValue', '1')] | 474 o._annotations = [('TestValue', '1')] |
561 o._test_jar = 'path/to/test.jar' | 475 o._test_jar = 'path/to/test.jar' |
562 o._junit4_runner_class = 'J4Runner' | 476 o._test_runner_junit4 = 'J4Runner' |
563 actual_tests = o.ProcessRawTests(raw_tests) | 477 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 478 return_value=raw_tests): |
| 479 actual_tests = o.GetTests() |
564 | 480 |
565 self.assertEquals(actual_tests, expected_tests) | 481 self.assertEquals(actual_tests, expected_tests) |
566 | 482 |
567 def testGetTests_annotationDictValueFilter(self): | 483 def testGetTests_annotationDictValueFilter(self): |
568 o = self.createTestInstance() | 484 o = self.createTestInstance() |
569 raw_tests = [ | 485 raw_tests = [ |
570 { | 486 { |
571 'annotations': {'Feature': {'value': ['Foo']}}, | 487 'annotations': {'Feature': {'value': ['Foo']}}, |
572 'class': 'org.chromium.test.SampleTest', | 488 'class': 'org.chromium.test.SampleTest', |
573 'superclass': 'java.lang.Object', | 489 'superclass': 'java.lang.Object', |
(...skipping 28 matching lines...) Expand all Loading... |
602 'SmallTest': None, | 518 'SmallTest': None, |
603 }, | 519 }, |
604 'class': 'org.chromium.test.SampleTest2', | 520 'class': 'org.chromium.test.SampleTest2', |
605 'is_junit4': True, | 521 'is_junit4': True, |
606 'method': 'testMethod1', | 522 'method': 'testMethod1', |
607 }, | 523 }, |
608 ] | 524 ] |
609 | 525 |
610 o._annotations = [('Feature', 'Bar')] | 526 o._annotations = [('Feature', 'Bar')] |
611 o._test_jar = 'path/to/test.jar' | 527 o._test_jar = 'path/to/test.jar' |
612 o._junit4_runner_class = 'J4Runner' | 528 o._test_runner_junit4 = 'J4Runner' |
613 actual_tests = o.ProcessRawTests(raw_tests) | 529 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 530 return_value=raw_tests): |
| 531 actual_tests = o.GetTests() |
614 | 532 |
615 self.assertEquals(actual_tests, expected_tests) | 533 self.assertEquals(actual_tests, expected_tests) |
616 | 534 |
617 def testGetTestName(self): | |
618 test = { | |
619 'annotations': { | |
620 'RunWith': {'value': 'class J4Runner'}, | |
621 'SmallTest': {}, | |
622 'Test': {'expected': 'class org.junit.Test$None', | |
623 'timeout': '0'}, | |
624 'UiThreadTest': {}}, | |
625 'class': 'org.chromium.TestA', | |
626 'is_junit4': True, | |
627 'method': 'testSimple'} | |
628 unqualified_class_test = { | |
629 'class': test['class'].split('.')[-1], | |
630 'method': test['method'] | |
631 } | |
632 | |
633 self.assertEquals( | |
634 instrumentation_test_instance.GetTestName(test, sep='.'), | |
635 'org.chromium.TestA.testSimple') | |
636 self.assertEquals( | |
637 instrumentation_test_instance.GetTestName( | |
638 unqualified_class_test, sep='.'), | |
639 'TestA.testSimple') | |
640 | |
641 def testGetUniqueTestName(self): | |
642 test = { | |
643 'annotations': { | |
644 'RunWith': {'value': 'class J4Runner'}, | |
645 'SmallTest': {}, | |
646 'Test': {'expected': 'class org.junit.Test$None', 'timeout': '0'}, | |
647 'UiThreadTest': {}}, | |
648 'class': 'org.chromium.TestA', | |
649 'flags': ['enable_features=abc'], | |
650 'is_junit4': True, | |
651 'method': 'testSimple'} | |
652 self.assertEquals( | |
653 instrumentation_test_instance.GetUniqueTestName( | |
654 test, sep='.'), | |
655 'org.chromium.TestA.testSimple with enable_features=abc') | |
656 | |
657 def testGetTestNameWithoutParameterPostfix(self): | |
658 test = { | |
659 'annotations': { | |
660 'RunWith': {'value': 'class J4Runner'}, | |
661 'SmallTest': {}, | |
662 'Test': {'expected': 'class org.junit.Test$None', 'timeout': '0'}, | |
663 'UiThreadTest': {}}, | |
664 'class': 'org.chromium.TestA__sandbox_mode', | |
665 'flags': 'enable_features=abc', | |
666 'is_junit4': True, | |
667 'method': 'testSimple'} | |
668 unqualified_class_test = { | |
669 'class': test['class'].split('.')[-1], | |
670 'method': test['method'] | |
671 } | |
672 self.assertEquals( | |
673 instrumentation_test_instance.GetTestNameWithoutParameterPostfix( | |
674 test, sep='.'), | |
675 'org.chromium.TestA') | |
676 self.assertEquals( | |
677 instrumentation_test_instance.GetTestNameWithoutParameterPostfix( | |
678 unqualified_class_test, sep='.'), | |
679 'TestA') | |
680 | |
681 def testGetTests_multipleAnnotationValuesRequested(self): | 535 def testGetTests_multipleAnnotationValuesRequested(self): |
682 o = self.createTestInstance() | 536 o = self.createTestInstance() |
683 raw_tests = [ | 537 raw_tests = [ |
684 { | 538 { |
685 'annotations': {'Feature': {'value': ['Foo']}}, | 539 'annotations': {'Feature': {'value': ['Foo']}}, |
686 'class': 'org.chromium.test.SampleTest', | 540 'class': 'org.chromium.test.SampleTest', |
687 'superclass': 'junit.framework.TestCase', | 541 'superclass': 'junit.framework.TestCase', |
688 'methods': [ | 542 'methods': [ |
689 { | 543 { |
690 'annotations': {'SmallTest': None}, | 544 'annotations': {'SmallTest': None}, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 'SmallTest': None, | 582 'SmallTest': None, |
729 }, | 583 }, |
730 'class': 'org.chromium.test.SampleTest2', | 584 'class': 'org.chromium.test.SampleTest2', |
731 'is_junit4': False, | 585 'is_junit4': False, |
732 'method': 'testMethod1', | 586 'method': 'testMethod1', |
733 }, | 587 }, |
734 ] | 588 ] |
735 | 589 |
736 o._annotations = [('Feature', 'Bar'), ('Feature', 'Baz')] | 590 o._annotations = [('Feature', 'Bar'), ('Feature', 'Baz')] |
737 o._test_jar = 'path/to/test.jar' | 591 o._test_jar = 'path/to/test.jar' |
738 o._junit4_runner_class = 'J4Runner' | 592 o._test_runner_junit4 = 'J4Runner' |
739 actual_tests = o.ProcessRawTests(raw_tests) | 593 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 594 return_value=raw_tests): |
| 595 actual_tests = o.GetTests() |
740 | 596 |
741 self.assertEquals(actual_tests, expected_tests) | 597 self.assertEquals(actual_tests, expected_tests) |
742 | 598 |
743 def testGenerateTestResults_noStatus(self): | 599 def testGenerateTestResults_noStatus(self): |
744 results = instrumentation_test_instance.GenerateTestResults( | 600 results = instrumentation_test_instance.GenerateTestResults( |
745 None, None, [], 0, 1000) | 601 None, None, [], 0, 1000) |
746 self.assertEqual([], results) | 602 self.assertEqual([], results) |
747 | 603 |
748 def testGenerateTestResults_testPassed(self): | 604 def testGenerateTestResults_testPassed(self): |
749 statuses = [ | 605 statuses = [ |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 { | 757 { |
902 'annotations': { | 758 'annotations': { |
903 'CommandLineParameter': {'value': ['', 'enable-features=abc']}, | 759 'CommandLineParameter': {'value': ['', 'enable-features=abc']}, |
904 'MediumTest': None}, | 760 'MediumTest': None}, |
905 'class': 'org.chromium.test.SampleTest', | 761 'class': 'org.chromium.test.SampleTest', |
906 'flags': ['--enable-features=abc'], | 762 'flags': ['--enable-features=abc'], |
907 'is_junit4': True, | 763 'is_junit4': True, |
908 'method': 'testMethod2'}] | 764 'method': 'testMethod2'}] |
909 | 765 |
910 o._test_jar = 'path/to/test.jar' | 766 o._test_jar = 'path/to/test.jar' |
911 o._junit4_runner_class = 'J4Runner' | 767 o._test_runner_junit4 = 'J4Runner' |
912 actual_tests = o.ProcessRawTests(raw_tests) | 768 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 769 return_value=raw_tests): |
| 770 actual_tests = o.GetTests() |
913 self.assertEquals(actual_tests, expected_tests) | 771 self.assertEquals(actual_tests, expected_tests) |
914 | 772 |
915 def testCommandLineParameterization_skipped(self): | 773 def testCommandLineParameterization_skipped(self): |
916 o = self.createTestInstance() | 774 o = self.createTestInstance() |
917 raw_tests = [ | 775 raw_tests = [ |
918 { | 776 { |
919 'annotations': {'CommandLineParameter': { | 777 'annotations': {'CommandLineParameter': { |
920 'value': ['', 'enable-features=abc']}}, | 778 'value': ['', 'enable-features=abc']}}, |
921 'class': 'org.chromium.test.SampleTest', | 779 'class': 'org.chromium.test.SampleTest', |
922 'superclass': 'java.lang.Object', | 780 'superclass': 'java.lang.Object', |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 { | 813 { |
956 'annotations': { | 814 'annotations': { |
957 'CommandLineParameter': {'value': ['', 'enable-features=abc']}, | 815 'CommandLineParameter': {'value': ['', 'enable-features=abc']}, |
958 'MediumTest': None}, | 816 'MediumTest': None}, |
959 'class': 'org.chromium.test.SampleTest', | 817 'class': 'org.chromium.test.SampleTest', |
960 'flags': ['--enable-features=abc'], | 818 'flags': ['--enable-features=abc'], |
961 'is_junit4': True, | 819 'is_junit4': True, |
962 'method': 'testMethod2'}] | 820 'method': 'testMethod2'}] |
963 | 821 |
964 o._test_jar = 'path/to/test.jar' | 822 o._test_jar = 'path/to/test.jar' |
965 o._junit4_runner_class = 'J4Runner' | 823 o._test_runner_junit4 = 'J4Runner' |
966 actual_tests = o.ProcessRawTests(raw_tests) | 824 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', |
| 825 return_value=raw_tests): |
| 826 actual_tests = o.GetTests() |
967 self.assertEquals(actual_tests, expected_tests) | 827 self.assertEquals(actual_tests, expected_tests) |
968 | 828 |
969 if __name__ == '__main__': | 829 if __name__ == '__main__': |
970 unittest.main(verbosity=2) | 830 unittest.main(verbosity=2) |
OLD | NEW |