1 /* 2 * Copyright (C) 2006 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 android.view; 18 19 import android.content.Context; 20 import android.test.AndroidTestCase; 21 import android.test.PerformanceTestCase; 22 import android.test.suitebuilder.annotation.SmallTest; 23 import android.view.View; 24 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; 25 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; 26 import android.widget.LinearLayout; 27 import android.widget.TextView; 28 29 public class CreateViewTest extends AndroidTestCase implements PerformanceTestCase { 30 31 public boolean isPerformanceOnly() { 32 return false; 33 } 34 35 public int startPerformance(PerformanceTestCase.Intermediates intermediates) { 36 return 0; 37 } 38 39 @SmallTest 40 public void testLayout1() throws Exception { 41 new CreateViewTest.ViewOne(mContext); 42 } 43 44 @SmallTest 45 public void testLayout2() throws Exception { 46 LinearLayout vert = new LinearLayout(mContext); 47 vert.addView(new CreateViewTest.ViewOne(mContext), 48 new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 49 } 50 51 @SmallTest 52 public void testLayout3() throws Exception { 53 LinearLayout vert = new LinearLayout(mContext); 54 55 ViewOne one = new ViewOne(mContext); 56 vert.addView(one, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 57 58 ViewOne two = new ViewOne(mContext); 59 vert.addView(two, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 60 61 ViewOne three = new ViewOne(mContext); 62 vert.addView(three, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 63 64 ViewOne four = new ViewOne(mContext); 65 vert.addView(four, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 66 67 ViewOne five = new ViewOne(mContext); 68 vert.addView(five, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 69 70 ViewOne six = new ViewOne(mContext); 71 vert.addView(six, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0)); 72 } 73 74 @SmallTest 75 public void testLayout4() throws Exception { 76 TextView text = new TextView(mContext); 77 text.setText("S"); 78 } 79 80 @SmallTest 81 public void testLayout5() throws Exception { 82 TextView text = new TextView(mContext); 83 text.setText("S"); 84 85 LinearLayout vert = new LinearLayout(mContext); 86 vert.addView(text, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 87 } 88 89 @SmallTest 90 public void testLayout6() throws Exception { 91 LinearLayout vert = new LinearLayout(mContext); 92 93 TextView one = new TextView(mContext); 94 one.setText("S"); 95 vert.addView(one, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 96 97 TextView two = new TextView(mContext); 98 two.setText("M"); 99 vert.addView(two, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 100 101 TextView three = new TextView(mContext); 102 three.setText("T"); 103 vert.addView(three, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 104 105 TextView four = new TextView(mContext); 106 four.setText("W"); 107 vert.addView(four, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 108 109 TextView five = new TextView(mContext); 110 five.setText("H"); 111 vert.addView(five, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 112 113 TextView six = new TextView(mContext); 114 six.setText("F"); 115 vert.addView(six, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0)); 116 } 117 118 public static class ViewOne extends View { 119 public ViewOne(Context context) { 120 super(context); 121 } 122 } 123 } 124