AbsListViewBindingAdapterTest.java revision 4d4979490e1fa374c0d7f3599fed0a9e83a579d0
1/*
2 * Copyright (C) 2015 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 */
16package android.databinding.testapp;
17
18import android.databinding.testapp.databinding.AbsListViewAdapterTestBinding;
19import android.databinding.testapp.vo.AbsListViewBindingObject;
20
21import android.graphics.drawable.ColorDrawable;
22import android.os.Build;
23import android.os.Debug;
24import android.widget.ListView;
25
26public class AbsListViewBindingAdapterTest
27        extends BindingAdapterTestBase<AbsListViewAdapterTestBinding, AbsListViewBindingObject> {
28
29    ListView mView;
30
31    public AbsListViewBindingAdapterTest() {
32        super(AbsListViewAdapterTestBinding.class, AbsListViewBindingObject.class,
33                R.layout.abs_list_view_adapter_test);
34    }
35
36    @Override
37    protected void setUp() throws Exception {
38        super.setUp();
39        mView = getBinder().view;
40    }
41
42    public void testListSelector() throws Throwable {
43        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
44            assertEquals(mBindingObject.getListSelector().getColor(),
45                    ((ColorDrawable) mView.getSelector()).getColor());
46
47            changeValues();
48
49            assertEquals(mBindingObject.getListSelector().getColor(),
50                    ((ColorDrawable) mView.getSelector()).getColor());
51        }
52    }
53
54    public void testScrollingCache() throws Throwable {
55        assertEquals(mBindingObject.isScrollingCache(), mView.isScrollingCacheEnabled());
56
57        changeValues();
58
59        assertEquals(mBindingObject.isScrollingCache(), mView.isScrollingCacheEnabled());
60    }
61
62    public void testSmoothScrollbar() throws Throwable {
63        assertEquals(mBindingObject.isSmoothScrollbar(), mView.isSmoothScrollbarEnabled());
64
65        changeValues();
66
67        assertEquals(mBindingObject.isSmoothScrollbar(), mView.isSmoothScrollbarEnabled());
68    }
69}
70