2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.widget.listview;
19 import android.app.Instrumentation;
20 import android.test.ActivityInstrumentationTestCase;
21 import android.test.suitebuilder.annotation.MediumTest;
22 import android.widget.Button;
23 import android.widget.ListView;
25 import com.android.frameworks.coretests.R;
26 import android.widget.listview.ListViewHeight;
28 public class ListViewHeightTest extends ActivityInstrumentationTestCase<ListViewHeight> {
29 private ListViewHeight mActivity;
32 public ListViewHeightTest() {
33 super("com.android.frameworks.coretests", ListViewHeight.class);
37 protected void setUp() throws Exception {
40 mActivity = getActivity();
44 public void testPreconditions() {
45 assertNotNull(mActivity);
49 public void testButtons() {
50 Instrumentation inst = getInstrumentation();
51 final Button button1 = (Button) mActivity.findViewById(R.id.button1);
52 final Button button2 = (Button) mActivity.findViewById(R.id.button2);
53 final Button button3 = (Button) mActivity.findViewById(R.id.button3);
56 ListView list = (ListView) mActivity.findViewById(R.id.inner_list);
57 assertEquals("Unexpected items in adapter", 0, list.getCount());
58 assertEquals("Unexpected children in list view", 0, list.getChildCount());
60 mActivity.runOnUiThread(new Runnable() {
62 button1.performClick();
65 inst.waitForIdleSync();
66 assertTrue("List not be visible after clicking button1", list.isShown());
67 assertTrue("List incorrect height", list.getHeight() == 200);
69 mActivity.runOnUiThread(new Runnable() {
71 button2.performClick();
74 inst.waitForIdleSync();
75 assertTrue("List not be visible after clicking button2", list.isShown());
77 mActivity.runOnUiThread(new Runnable() {
79 button3.performClick();
82 inst.waitForIdleSync();
83 assertFalse("List should not be visible clicking button3", list.isShown());