| 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 """Tests for jni_generator.py. | 6 """Tests for jni_generator.py. |
| 7 | 7 |
| 8 This test suite contains various tests for the JNI generator. | 8 This test suite contains various tests for the JNI generator. |
| 9 It exercises the low-level parser all the way up to the | 9 It exercises the low-level parser all the way up to the |
| 10 code generator and ensures the output matches a golden | 10 code generator and ensures the output matches a golden |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 """ | 826 """ |
| 827 self.assertRaises(SyntaxError, | 827 self.assertRaises(SyntaxError, |
| 828 jni_generator.JNIFromJavaSource, | 828 jni_generator.JNIFromJavaSource, |
| 829 test_data, 'foo/bar', TestOptions()) | 829 test_data, 'foo/bar', TestOptions()) |
| 830 | 830 |
| 831 def testJniSelfDocumentingExample(self): | 831 def testJniSelfDocumentingExample(self): |
| 832 script_dir = os.path.dirname(sys.argv[0]) | 832 script_dir = os.path.dirname(sys.argv[0]) |
| 833 content = file(os.path.join(script_dir, | 833 content = file(os.path.join(script_dir, |
| 834 'java/src/org/chromium/example/jni_generator/SampleForTests.java') | 834 'java/src/org/chromium/example/jni_generator/SampleForTests.java') |
| 835 ).read() | 835 ).read() |
| 836 golden_file = os.path.join(script_dir, 'golden_sample_for_tests_jni.h') | 836 golden_file = os.path.join(script_dir, 'SampleForTests_jni.golden') |
| 837 golden_content = file(golden_file).read() | 837 golden_content = file(golden_file).read() |
| 838 jni_from_java = jni_generator.JNIFromJavaSource( | 838 jni_from_java = jni_generator.JNIFromJavaSource( |
| 839 content, 'org/chromium/example/jni_generator/SampleForTests', | 839 content, 'org/chromium/example/jni_generator/SampleForTests', |
| 840 TestOptions()) | 840 TestOptions()) |
| 841 generated_text = jni_from_java.GetContent() | 841 generated_text = jni_from_java.GetContent() |
| 842 if not self.compareText(golden_content, generated_text): | 842 if not self.compareText(golden_content, generated_text): |
| 843 if os.environ.get(REBASELINE_ENV): | 843 if os.environ.get(REBASELINE_ENV): |
| 844 with file(golden_file, 'w') as f: | 844 with file(golden_file, 'w') as f: |
| 845 f.write(generated_text) | 845 f.write(generated_text) |
| 846 return | 846 return |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 test_result = unittest.main(argv=argv[0:1], exit=False) | 1060 test_result = unittest.main(argv=argv[0:1], exit=False) |
| 1061 | 1061 |
| 1062 if test_result.result.wasSuccessful() and options.stamp: | 1062 if test_result.result.wasSuccessful() and options.stamp: |
| 1063 TouchStamp(options.stamp) | 1063 TouchStamp(options.stamp) |
| 1064 | 1064 |
| 1065 return not test_result.result.wasSuccessful() | 1065 return not test_result.result.wasSuccessful() |
| 1066 | 1066 |
| 1067 | 1067 |
| 1068 if __name__ == '__main__': | 1068 if __name__ == '__main__': |
| 1069 sys.exit(main(sys.argv)) | 1069 sys.exit(main(sys.argv)) |
| OLD | NEW |