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

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_test_instance_test.py

Issue 2580943002: Fix negative gtest filters for instrumentation tests. (Closed)
Patch Set: Reenabled test for negative filters Created 4 years 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
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 unittest 10 import unittest
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ] 180 ]
181 181
182 o._test_filter = 'org.chromium.test.SampleTest2.*' 182 o._test_filter = 'org.chromium.test.SampleTest2.*'
183 o._test_jar = 'path/to/test.jar' 183 o._test_jar = 'path/to/test.jar'
184 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle', 184 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
185 return_value=raw_tests): 185 return_value=raw_tests):
186 actual_tests = o.GetTests() 186 actual_tests = o.GetTests()
187 187
188 self.assertEquals(actual_tests, expected_tests) 188 self.assertEquals(actual_tests, expected_tests)
189 189
190 @unittest.skip('crbug.com/623047')
191 def testGetTests_negativeGtestFilter(self): 190 def testGetTests_negativeGtestFilter(self):
192 o = self.createTestInstance() 191 o = self.createTestInstance()
193 raw_tests = [ 192 raw_tests = [
194 { 193 {
195 'annotations': {'Feature': {'value': ['Foo']}}, 194 'annotations': {'Feature': {'value': ['Foo']}},
196 'class': 'org.chromium.test.SampleTest', 195 'class': 'org.chromium.test.SampleTest',
197 'methods': [ 196 'methods': [
198 { 197 {
199 'annotations': {'SmallTest': None}, 198 'annotations': {'SmallTest': None},
200 'method': 'testMethod1', 199 'method': 'testMethod1',
201 }, 200 },
202 { 201 {
203 'annotations': {'MediumTest': None}, 202 'annotations': {'MediumTest': None},
204 'method': 'testMethod2', 203 'method': 'testMethod2',
205 }, 204 },
206 ], 205 ],
207 }, 206 },
208 { 207 {
209 'annotations': {'Feature': {'value': ['Bar']}}, 208 'annotations': {'Feature': {'value': ['Bar']}},
210 'class': 'org.chromium.test.SampleTest2', 209 'class': 'org.chromium.test.SampleTest2',
211 'methods': [ 210 'methods': [
212 { 211 {
213 'annotations': {'SmallTest': None}, 212 'annotations': {'SmallTest': None},
214 'method': 'testMethod1', 213 'method': 'testMethod1',
215 }, 214 },
216 ], 215 ],
217 } 216 }
218 ] 217 ]
219 218
220 o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
221 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1'
222 o._test_jar = 'path/to/test.jar'
223 expected_tests = [ 219 expected_tests = [
224 { 220 {
225 'annotations': { 221 'annotations': {
226 'Feature': {'value': ['Foo']}, 222 'Feature': {'value': ['Foo']},
227 'MediumTest': None, 223 'MediumTest': None,
228 }, 224 },
229 'class': 'org.chromium.test.SampleTest', 225 'class': 'org.chromium.test.SampleTest',
230 'method': 'testMethod2', 226 'method': 'testMethod2',
231 }, 227 },
232 { 228 {
233 'annotations': { 229 'annotations': {
234 'Feature': {'value': ['Bar']}, 230 'Feature': {'value': ['Bar']},
235 'SmallTest': None, 231 'SmallTest': None,
236 }, 232 },
237 'class': 'org.chromium.test.SampleTest2', 233 'class': 'org.chromium.test.SampleTest2',
238 'method': 'testMethod1', 234 'method': 'testMethod1',
239 }, 235 },
240 ] 236 ]
241 237
242 actual_tests = o.GetTests() 238 o._test_filter = '*-org.chromium.test.SampleTest.testMethod1'
239 o._test_jar = 'path/to/test.jar'
240 with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
241 return_value=raw_tests):
242 actual_tests = o.GetTests()
243
243 self.assertEquals(actual_tests, expected_tests) 244 self.assertEquals(actual_tests, expected_tests)
244 245
245 def testGetTests_annotationFilter(self): 246 def testGetTests_annotationFilter(self):
246 o = self.createTestInstance() 247 o = self.createTestInstance()
247 raw_tests = [ 248 raw_tests = [
248 { 249 {
249 'annotations': {'Feature': {'value': ['Foo']}}, 250 'annotations': {'Feature': {'value': ['Foo']}},
250 'class': 'org.chromium.test.SampleTest', 251 'class': 'org.chromium.test.SampleTest',
251 'methods': [ 252 'methods': [
252 { 253 {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 }), 620 }),
620 ] 621 ]
621 results = instrumentation_test_instance.GenerateTestResults( 622 results = instrumentation_test_instance.GenerateTestResults(
622 None, None, statuses, 0, 1000) 623 None, None, statuses, 0, 1000)
623 self.assertEqual(1, len(results)) 624 self.assertEqual(1, len(results))
624 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType()) 625 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType())
625 626
626 627
627 if __name__ == '__main__': 628 if __name__ == '__main__':
628 unittest.main(verbosity=2) 629 unittest.main(verbosity=2)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698