The Android Open Source Project | f805710 | 2009-03-15 16:47:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package dex.reader; |
| 18 | |
| 19 | import static org.junit.Assert.assertEquals; |
| 20 | import dex.reader.util.JavaSource; |
| 21 | import dex.structure.DexClass; |
| 22 | import dex.structure.DexFile; |
| 23 | |
| 24 | import org.junit.Test; |
| 25 | |
| 26 | import java.io.IOException; |
| 27 | |
| 28 | public class LargeDexTests extends DexTestsCommon{ |
| 29 | |
| 30 | /** |
| 31 | * Tests parsing a class with 10000 Fields. |
| 32 | */ |
| 33 | @Test |
| 34 | public void testManyFields() throws IOException{ |
| 35 | String CLASS_NAME = "L0"; |
| 36 | int NR_OF_FIELDS = 10000; |
| 37 | StringBuilder b = new StringBuilder(); |
| 38 | b.append("public class ").append(CLASS_NAME).append("{\n"); |
| 39 | for (int i = 0; i < NR_OF_FIELDS; i++) { |
| 40 | b.append("\tpublic int f").append(i).append(";\n"); |
| 41 | } |
| 42 | b.append("}\n"); |
| 43 | |
| 44 | JavaSource source = new JavaSource(CLASS_NAME, b.toString()); |
| 45 | DexFile dexFile = javaToDexUtil.getFrom(source); |
| 46 | assertEquals(1, dexFile.getDefinedClasses().size()); |
| 47 | DexClass clazz = dexFile.getDefinedClasses().get(0); |
| 48 | assertEquals("LL0;", clazz.getName()); |
| 49 | assertPublic(clazz); |
| 50 | assertEquals(NR_OF_FIELDS, clazz.getFields().size()); |
| 51 | } |
| 52 | } |