blob: bfb4d172f6c395804a7d5cc2ae15076b9dec1035 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
Neal Nguyen1d3165f2010-01-12 13:26:10 -080017package android.widget.layout.table;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
Neal Nguyen1d3165f2010-01-12 13:26:10 -080019import android.widget.layout.table.AddColumn;
20import com.android.frameworks.coretests.R;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021
22import android.test.ActivityInstrumentationTestCase;
23import android.test.suitebuilder.annotation.MediumTest;
24import android.view.KeyEvent;
25import android.widget.Button;
26import android.widget.TableLayout;
27import android.widget.TableRow;
28
29/**
Neal Nguyen1d3165f2010-01-12 13:26:10 -080030 * {@link android.widget.layout.table.AddColumn} is
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031 * setup to exercise the case of adding row programmatically in a table.
32 */
33public class AddColumnTest extends ActivityInstrumentationTestCase<AddColumn> {
34 private Button mAddRow;
35 private TableLayout mTable;
36
37 public AddColumnTest() {
Neal Nguyen1d3165f2010-01-12 13:26:10 -080038 super("com.android.frameworks.coretests", AddColumn.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 }
40
41 @Override
42 protected void setUp() throws Exception {
43 super.setUp();
44
45 final AddColumn activity = getActivity();
46 mAddRow = (Button) activity.findViewById(R.id.add_row_button);
47 mTable = (TableLayout) activity.findViewById(R.id.table);
48 }
49
50 @MediumTest
51 public void testSetUpConditions() throws Exception {
52 assertNotNull(mAddRow);
53 assertNotNull(mTable);
54 assertTrue(mAddRow.hasFocus());
55 }
56
57 @MediumTest
58 public void testWidths() throws Exception {
59 sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
60 getInstrumentation().waitForIdleSync();
61
62 TableRow row1 = (TableRow) mTable.getChildAt(0);
63 TableRow row2 = (TableRow) mTable.getChildAt(1);
64
65 assertTrue(row1.getChildCount() < row2.getChildCount());
66
67 for (int i = 0; i < row1.getChildCount(); i++) {
68 assertEquals(row2.getChildAt(i).getWidth(), row1.getChildAt(i).getWidth());
69 }
70 }
71}