| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 import PRESUBMIT | 10 import PRESUBMIT |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 return 'changed data' | 952 return 'changed data' |
| 953 | 953 |
| 954 self.mock_input_api.subprocess.check_output = mock_check_output | 954 self.mock_input_api.subprocess.check_output = mock_check_output |
| 955 | 955 |
| 956 results = self._RunCheck() | 956 results = self._RunCheck() |
| 957 self.assertEqual(2, len(results)) | 957 self.assertEqual(2, len(results)) |
| 958 self.assertTrue('File is stale' in str(results[0])) | 958 self.assertTrue('File is stale' in str(results[0])) |
| 959 self.assertTrue('File is stale' in str(results[1])) | 959 self.assertTrue('File is stale' in str(results[1])) |
| 960 | 960 |
| 961 | 961 |
| 962 class AndroidDeprecatedTestAnnotationTest(unittest.TestCase): |
| 963 def testCheckAndroidTestAnnotationUsage(self): |
| 964 mock_input_api = MockInputApi() |
| 965 mock_output_api = MockOutputApi() |
| 966 |
| 967 mock_input_api.files = [ |
| 968 MockAffectedFile('LalaLand.java', [ |
| 969 'random stuff' |
| 970 ]), |
| 971 MockAffectedFile('CorrectUsage.java', [ |
| 972 'import android.support.test.filters.LargeTest;', |
| 973 'import android.support.test.filters.MediumTest;', |
| 974 'import android.support.test.filters.SmallTest;', |
| 975 ]), |
| 976 MockAffectedFile('UsedDeprecatedLargeTestAnnotation.java', [ |
| 977 'import android.test.suitebuilder.annotation.LargeTest;', |
| 978 ]), |
| 979 MockAffectedFile('UsedDeprecatedMediumTestAnnotation.java', [ |
| 980 'import android.test.suitebuilder.annotation.MediumTest;', |
| 981 ]), |
| 982 MockAffectedFile('UsedDeprecatedSmallTestAnnotation.java', [ |
| 983 'import android.test.suitebuilder.annotation.SmallTest;', |
| 984 ]), |
| 985 MockAffectedFile('UsedDeprecatedSmokeAnnotation.java', [ |
| 986 'import android.test.suitebuilder.annotation.Smoke;', |
| 987 ]) |
| 988 ] |
| 989 msgs = PRESUBMIT._CheckAndroidTestAnnotationUsage( |
| 990 mock_input_api, mock_output_api) |
| 991 self.assertEqual(1, len(msgs), |
| 992 'Expected %d items, found %d: %s' |
| 993 % (1, len(msgs), msgs)) |
| 994 self.assertEqual(4, len(msgs[0].items), |
| 995 'Expected %d items, found %d: %s' |
| 996 % (4, len(msgs[0].items), msgs[0].items)) |
| 997 self.assertTrue('UsedDeprecatedLargeTestAnnotation.java:1' in msgs[0].items, |
| 998 'UsedDeprecatedLargeTestAnnotation not found in errors') |
| 999 self.assertTrue('UsedDeprecatedMediumTestAnnotation.java:1' |
| 1000 in msgs[0].items, |
| 1001 'UsedDeprecatedMediumTestAnnotation not found in errors') |
| 1002 self.assertTrue('UsedDeprecatedSmallTestAnnotation.java:1' in msgs[0].items, |
| 1003 'UsedDeprecatedSmallTestAnnotation not found in errors') |
| 1004 self.assertTrue('UsedDeprecatedSmokeAnnotation.java:1' in msgs[0].items, |
| 1005 'UsedDeprecatedSmokeAnnotation not found in errors') |
| 1006 |
| 1007 |
| 1008 |
| 962 class LogUsageTest(unittest.TestCase): | 1009 class LogUsageTest(unittest.TestCase): |
| 963 | 1010 |
| 964 def testCheckAndroidCrLogUsage(self): | 1011 def testCheckAndroidCrLogUsage(self): |
| 965 mock_input_api = MockInputApi() | 1012 mock_input_api = MockInputApi() |
| 966 mock_output_api = MockOutputApi() | 1013 mock_output_api = MockOutputApi() |
| 967 | 1014 |
| 968 mock_input_api.files = [ | 1015 mock_input_api.files = [ |
| 969 MockAffectedFile('RandomStuff.java', [ | 1016 MockAffectedFile('RandomStuff.java', [ |
| 970 'random stuff' | 1017 'random stuff' |
| 971 ]), | 1018 ]), |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 mock_input_api.files = [ | 1266 mock_input_api.files = [ |
| 1220 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), | 1267 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), |
| 1221 ] | 1268 ] |
| 1222 warnings = PRESUBMIT._CheckForRiskyJsFeatures( | 1269 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
| 1223 mock_input_api, MockOutputApi()) | 1270 mock_input_api, MockOutputApi()) |
| 1224 self.assertEqual(0, len(warnings)) | 1271 self.assertEqual(0, len(warnings)) |
| 1225 | 1272 |
| 1226 | 1273 |
| 1227 if __name__ == '__main__': | 1274 if __name__ == '__main__': |
| 1228 unittest.main() | 1275 unittest.main() |
| OLD | NEW |