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.CastTestBinding;
19
20import android.support.v4.util.ArrayMap;
21import android.test.UiThreadTest;
22
23import java.util.ArrayList;
24
25public class CastTest extends BaseDataBinderTest<CastTestBinding> {
26    ArrayList<String> mValues = new ArrayList<>();
27    ArrayMap<String, String> mMap = new ArrayMap<>();
28
29    public CastTest() {
30        super(CastTestBinding.class);
31    }
32
33    @UiThreadTest
34    public void testCast() throws Throwable {
35        initBinder();
36        mValues.clear();
37        mValues.add("hello");
38        mValues.add("world");
39        mValues.add("not seen");
40        mMap.clear();
41        mMap.put("hello", "world");
42        mMap.put("world", "hello");
43        mBinder.setList(mValues);
44        mBinder.setMap(mMap);
45        mBinder.executePendingBindings();
46        assertEquals("hello", mBinder.textView0.getText().toString());
47        assertEquals("world", mBinder.textView1.getText().toString());
48    }
49}
50