The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 17 | package android.widget.layout.table; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Neal Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 19 | import android.widget.layout.table.AddColumn; |
| 20 | import com.android.frameworks.coretests.R; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
| 22 | import android.test.ActivityInstrumentationTestCase; |
| 23 | import android.test.suitebuilder.annotation.MediumTest; |
| 24 | import android.view.KeyEvent; |
| 25 | import android.widget.Button; |
| 26 | import android.widget.TableLayout; |
| 27 | import android.widget.TableRow; |
| 28 | |
| 29 | /** |
Neal Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 30 | * {@link android.widget.layout.table.AddColumn} is |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | * setup to exercise the case of adding row programmatically in a table. |
| 32 | */ |
| 33 | public class AddColumnTest extends ActivityInstrumentationTestCase<AddColumn> { |
| 34 | private Button mAddRow; |
| 35 | private TableLayout mTable; |
| 36 | |
| 37 | public AddColumnTest() { |
Neal Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 38 | super("com.android.frameworks.coretests", AddColumn.class); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | } |
| 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 | } |