OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import unittest |
| 6 |
| 7 from pylib.utils import proguard |
| 8 |
| 9 class TestParse(unittest.TestCase): |
| 10 |
| 11 def testClass(self): |
| 12 actual = proguard.Parse( |
| 13 ['- Program class: org/example/Test', |
| 14 ' Superclass: java/lang/Object']) |
| 15 expected = { |
| 16 'classes': [ |
| 17 { |
| 18 'class': 'org.example.Test', |
| 19 'superclass': 'java.lang.Object', |
| 20 'annotations': {}, |
| 21 'methods': [] |
| 22 } |
| 23 ] |
| 24 } |
| 25 self.assertEquals(expected, actual) |
| 26 |
| 27 def testMethod(self): |
| 28 actual = proguard.Parse( |
| 29 ['- Program class: org/example/Test', |
| 30 'Methods (count = 1):', |
| 31 '- Method: <init>()V']) |
| 32 expected = { |
| 33 'classes': [ |
| 34 { |
| 35 'class': 'org.example.Test', |
| 36 'superclass': '', |
| 37 'annotations': {}, |
| 38 'methods': [ |
| 39 { |
| 40 'method': '<init>', |
| 41 'annotations': {} |
| 42 } |
| 43 ] |
| 44 } |
| 45 ] |
| 46 } |
| 47 self.assertEquals(expected, actual) |
| 48 |
| 49 def testClassAnnotation(self): |
| 50 actual = proguard.Parse( |
| 51 ['- Program class: org/example/Test', |
| 52 ' - Annotation [Lorg/example/Annotation;]:', |
| 53 ' - Annotation [Lorg/example/AnnotationWithValue;]:', |
| 54 ' - Constant element value [attr \'13\']', |
| 55 ' - Utf8 [val]']) |
| 56 expected = { |
| 57 'classes': [ |
| 58 { |
| 59 'class': 'org.example.Test', |
| 60 'superclass': '', |
| 61 'annotations': { |
| 62 'Annotation': None, |
| 63 'AnnotationWithValue': 'val' |
| 64 }, |
| 65 'methods': [] |
| 66 } |
| 67 ] |
| 68 } |
| 69 self.assertEquals(expected, actual) |
| 70 |
| 71 def testMethodAnnotation(self): |
| 72 actual = proguard.Parse( |
| 73 ['- Program class: org/example/Test', |
| 74 'Methods (count = 1):', |
| 75 '- Method: Test()V', |
| 76 ' - Annotation [Lorg/example/Annotation;]:', |
| 77 ' - Annotation [Lorg/example/AnnotationWithValue;]:', |
| 78 ' - Constant element value [attr \'13\']', |
| 79 ' - Utf8 [val]']) |
| 80 expected = { |
| 81 'classes': [ |
| 82 { |
| 83 'class': 'org.example.Test', |
| 84 'superclass': '', |
| 85 'annotations': {}, |
| 86 'methods': [ |
| 87 { |
| 88 'method': 'Test', |
| 89 'annotations': { |
| 90 'Annotation': None, |
| 91 'AnnotationWithValue': 'val' |
| 92 }, |
| 93 } |
| 94 ] |
| 95 } |
| 96 ] |
| 97 } |
| 98 self.assertEquals(expected, actual) |
OLD | NEW |