1# Copyright (C) 2022 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15# Licensed under the Apache License, Version 2.0 (the "License"); 16# you may not use this file except in compliance with the License. 17# You may obtain a copy of the License at 18# 19# http://www.apache.org/licenses/LICENSE-2.0 20# 21# Unless required by applicable law or agreed to in writing, software 22# distributed under the License is distributed on an "AS IS" BASIS, 23# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24# See the License for the specific language governing permissions and 25# limitations under the License. 26 27import classes_collector 28import unittest 29 30class TestGenJarjar(unittest.TestCase): 31 32 def setUp(self): 33 # This allows printing the entire diff in the output when there's a mismatch otherwise 34 # the diff will be truncated. 35 self.maxDiff = None 36 37 def test_classes_collection(self): 38 args = classes_collector.parse_arguments([ 39 "test_classes_collector_java.jar", 40 "--prefix", "jarjar.prefix", 41 "--output", "test-output-rules.txt", 42 "--prefix-excludes", "testdata/test-package-prefix-excludes.txt", 43 "--excludes", "testdata/test-excludes.txt", 44 ]) 45 46 self.assertCountEqual([ 47 '"android.net.ParentClass"', 48 '"android.net.ParentClass$ChildClassA"', 49 '"jarjar.prefix.android.jarjared.FooClass"' 50 ], classes_collector.make_classes_list(args)) 51 52 53if __name__ == '__main__': 54 # Need verbosity=2 for the test results parser to find results 55 unittest.main(verbosity=2)