Roll android_tools support library to 25.1.0
[android_tools.git] / sdk / sources / android-23 / android / databinding / testapp / AbsSpinnerBindingAdapterTest.java
blobd1d45f5594634af9cff6377558294c32f45fea79
1 /*
2 * Copyright (C) 2015 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.
16 package android.databinding.testapp;
18 import android.databinding.testapp.databinding.AbsSpinnerAdapterTestBinding;
19 import android.databinding.testapp.vo.AbsSpinnerBindingObject;
21 import android.os.Build;
22 import android.widget.Spinner;
23 import android.widget.SpinnerAdapter;
25 public class AbsSpinnerBindingAdapterTest
26 extends BindingAdapterTestBase<AbsSpinnerAdapterTestBinding, AbsSpinnerBindingObject> {
28 Spinner mView;
30 public AbsSpinnerBindingAdapterTest() {
31 super(AbsSpinnerAdapterTestBinding.class, AbsSpinnerBindingObject.class,
32 R.layout.abs_spinner_adapter_test);
35 @Override
36 protected void setUp() throws Exception {
37 super.setUp();
38 mView = mBinder.view;
41 public void testEntries() throws Throwable {
42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
43 validateEntries();
45 changeValues();
47 validateEntries();
51 private void validateEntries() {
52 assertEquals(mBindingObject.getEntries().length, mView.getAdapter().getCount());
53 CharSequence[] entries = mBindingObject.getEntries();
54 SpinnerAdapter adapter = mView.getAdapter();
55 for (int i = 0; i < entries.length; i++) {
56 assertEquals(adapter.getItem(i), entries[i]);