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.listview.touch;
18
19import android.test.ActivityInstrumentationTestCase;
20import android.test.suitebuilder.annotation.LargeTest;
21import android.test.suitebuilder.annotation.MediumTest;
22import android.test.TouchUtils;
23import android.widget.ListView;
24import android.view.View;
25
26import android.widget.listview.ListGetSelectedView;
27
28/**
29 * This test is made to check that getSelectedView() will return
30 * null in touch mode.
31 */
32public class ListGetSelectedViewTest extends ActivityInstrumentationTestCase<ListGetSelectedView> {
33    private ListGetSelectedView mActivity;
34    private ListView mListView;
35
36    public ListGetSelectedViewTest() {
37        super("com.android.frameworks.coretests", ListGetSelectedView.class);
38    }
39
40    @Override
41    protected void setUp() throws Exception {
42        super.setUp();
43
44        mActivity = getActivity();
45        mListView = getActivity().getListView();
46    }
47
48    @MediumTest
49    public void testPreconditions() {
50        assertNotNull(mActivity);
51        assertNotNull(mListView);
52
53        assertEquals(0, mListView.getSelectedItemPosition());
54    }
55
56    @LargeTest
57    public void testGetSelectedView() {
58        View last = mListView.getChildAt(1);
59        TouchUtils.clickView(this, last);
60
61        assertNull(mListView.getSelectedItem());
62        assertNull(mListView.getSelectedView());
63        assertEquals(-1, mListView.getSelectedItemPosition());
64    }
65}
66