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
17package android.widget.focus;
18
19import android.widget.focus.ListWithFooterViewAndNewLabels;
20import com.android.frameworks.coretests.R;
21
22import android.test.ActivityInstrumentationTestCase;
23import android.widget.Button;
24import android.widget.ListAdapter;
25import android.widget.ListView;
26
27public class ListWithFooterViewAndNewLabelsTest
28        extends ActivityInstrumentationTestCase<ListWithFooterViewAndNewLabels> {
29
30    private Button mButton;
31
32    private ListAdapter mAdapter;
33
34    private ListView mListView;
35
36
37    public ListWithFooterViewAndNewLabelsTest() {
38        super("com.android.frameworks.coretests",
39                ListWithFooterViewAndNewLabels.class);
40    }
41
42
43    @Override
44    protected void setUp() throws Exception {
45        super.setUp();
46
47        ListWithFooterViewAndNewLabels a = getActivity();
48        mButton = (Button) a.findViewById(R.id.button);
49        mAdapter = a.getListAdapter();
50        mListView = a.getListView();
51    }
52
53    // bug 900885
54    public void FAILING_testPreconditions() {
55        assertNotNull(mButton);
56        assertNotNull(mAdapter);
57        assertNotNull(mListView);
58
59        assertTrue(mButton.hasFocus());
60        assertEquals("expected list adapter to have 1 item",
61                1, mAdapter.getCount());
62        assertEquals("expected list view to have 2 items (1 in adapter, plus "
63                + "the footer view).",
64                2, mListView.getCount());
65
66        // fails here!!!
67        assertEquals("Expecting the selected index to be 0, the first non footer "
68                + "view item.",
69                0, mListView.getSelectedItemPosition());
70    }
71
72}
73