Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: build/android/pylib/results/json_results_test.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import unittest
7
8 from pylib.base import base_test_result
9 from pylib.results import json_results
10
11
12 class JsonResultsTest(unittest.TestCase):
13
14 def testGenerateResultsDict_passedResult(self):
15 result = base_test_result.BaseTestResult(
16 'test.package.TestName', base_test_result.ResultType.PASS)
17
18 all_results = base_test_result.TestRunResults()
19 all_results.AddResult(result)
20
21 results_dict = json_results.GenerateResultsDict(all_results)
22 self.assertEquals(
23 ['test.package.TestName'],
24 results_dict['all_tests'])
25 self.assertEquals(1, len(results_dict['per_iteration_data']))
26
27 iteration_result = results_dict['per_iteration_data'][0]
28 self.assertTrue('test.package.TestName' in iteration_result)
29 self.assertEquals(1, len(iteration_result['test.package.TestName']))
30
31 test_iteration_result = iteration_result['test.package.TestName'][0]
32 self.assertTrue('status' in test_iteration_result)
33 self.assertEquals('SUCCESS', test_iteration_result['status'])
34
35 def testGenerateResultsDict_skippedResult(self):
36 result = base_test_result.BaseTestResult(
37 'test.package.TestName', base_test_result.ResultType.SKIP)
38
39 all_results = base_test_result.TestRunResults()
40 all_results.AddResult(result)
41
42 results_dict = json_results.GenerateResultsDict(all_results)
43 self.assertEquals(
44 ['test.package.TestName'],
45 results_dict['all_tests'])
46 self.assertEquals(1, len(results_dict['per_iteration_data']))
47
48 iteration_result = results_dict['per_iteration_data'][0]
49 self.assertTrue('test.package.TestName' in iteration_result)
50 self.assertEquals(1, len(iteration_result['test.package.TestName']))
51
52 test_iteration_result = iteration_result['test.package.TestName'][0]
53 self.assertTrue('status' in test_iteration_result)
54 self.assertEquals('SKIPPED', test_iteration_result['status'])
55
56 def testGenerateResultsDict_failedResult(self):
57 result = base_test_result.BaseTestResult(
58 'test.package.TestName', base_test_result.ResultType.FAIL)
59
60 all_results = base_test_result.TestRunResults()
61 all_results.AddResult(result)
62
63 results_dict = json_results.GenerateResultsDict(all_results)
64 self.assertEquals(
65 ['test.package.TestName'],
66 results_dict['all_tests'])
67 self.assertEquals(1, len(results_dict['per_iteration_data']))
68
69 iteration_result = results_dict['per_iteration_data'][0]
70 self.assertTrue('test.package.TestName' in iteration_result)
71 self.assertEquals(1, len(iteration_result['test.package.TestName']))
72
73 test_iteration_result = iteration_result['test.package.TestName'][0]
74 self.assertTrue('status' in test_iteration_result)
75 self.assertEquals('FAILURE', test_iteration_result['status'])
76
77 def testGenerateResultsDict_duration(self):
78 result = base_test_result.BaseTestResult(
79 'test.package.TestName', base_test_result.ResultType.PASS, duration=123)
80
81 all_results = base_test_result.TestRunResults()
82 all_results.AddResult(result)
83
84 results_dict = json_results.GenerateResultsDict(all_results)
85 self.assertEquals(
86 ['test.package.TestName'],
87 results_dict['all_tests'])
88 self.assertEquals(1, len(results_dict['per_iteration_data']))
89
90 iteration_result = results_dict['per_iteration_data'][0]
91 self.assertTrue('test.package.TestName' in iteration_result)
92 self.assertEquals(1, len(iteration_result['test.package.TestName']))
93
94 test_iteration_result = iteration_result['test.package.TestName'][0]
95 self.assertTrue('elapsed_time_ms' in test_iteration_result)
96 self.assertEquals(123, test_iteration_result['elapsed_time_ms'])
97
98 def testGenerateResultsDict_multipleResults(self):
99 result1 = base_test_result.BaseTestResult(
100 'test.package.TestName1', base_test_result.ResultType.PASS)
101 result2 = base_test_result.BaseTestResult(
102 'test.package.TestName2', base_test_result.ResultType.PASS)
103
104 all_results = base_test_result.TestRunResults()
105 all_results.AddResult(result1)
106 all_results.AddResult(result2)
107
108 results_dict = json_results.GenerateResultsDict(all_results)
109 self.assertEquals(
110 ['test.package.TestName1', 'test.package.TestName2'],
111 results_dict['all_tests'])
112 self.assertEquals(2, len(results_dict['per_iteration_data']))
113
114 expected_tests = set([
115 'test.package.TestName1',
116 'test.package.TestName2',
117 ])
118
119 for iteration_result in results_dict['per_iteration_data']:
120 self.assertEquals(1, len(iteration_result))
121 name = iteration_result.keys()[0]
122 self.assertTrue(name in expected_tests)
123 expected_tests.remove(name)
124 self.assertEquals(1, len(iteration_result[name]))
125
126 test_iteration_result = iteration_result[name][0]
127 self.assertTrue('status' in test_iteration_result)
128 self.assertEquals('SUCCESS', test_iteration_result['status'])
129
130
131 if __name__ == '__main__':
132 unittest.main(verbosity=2)
133
OLDNEW
« no previous file with comments | « build/android/pylib/results/json_results.py ('k') | build/android/pylib/results/report_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698