1e4b93061ac703e48fc2c9994c9059ed016f05559George Mount/* 2e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * Copyright (C) 2015 The Android Open Source Project 3e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * 4e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * Licensed under the Apache License, Version 2.0 (the "License"); 5e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * you may not use this file except in compliance with the License. 6e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * You may obtain a copy of the License at 7e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * 8e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * http://www.apache.org/licenses/LICENSE-2.0 9e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * 10e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * Unless required by applicable law or agreed to in writing, software 11e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * distributed under the License is distributed on an "AS IS" BASIS, 12e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * See the License for the specific language governing permissions and 14e4b93061ac703e48fc2c9994c9059ed016f05559George Mount * limitations under the License. 15e4b93061ac703e48fc2c9994c9059ed016f05559George Mount */ 16fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountpackage android.databinding.testapp; 17e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 182e2043d30f95585de2069e1cbb23e022ab0e71c4George Mountimport android.databinding.testapp.databinding.CastTestBinding; 19e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 20e4b93061ac703e48fc2c9994c9059ed016f05559George Mountimport android.support.v4.util.ArrayMap; 21e4b93061ac703e48fc2c9994c9059ed016f05559George Mountimport android.test.UiThreadTest; 22e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 23e4b93061ac703e48fc2c9994c9059ed016f05559George Mountimport java.util.ArrayList; 24e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 254c5cc009bcbcfb19e33fb19db5ec80f83f7b3326George Mountpublic class CastTest extends BaseDataBinderTest<CastTestBinding> { 26e4b93061ac703e48fc2c9994c9059ed016f05559George Mount ArrayList<String> mValues = new ArrayList<>(); 27e4b93061ac703e48fc2c9994c9059ed016f05559George Mount ArrayMap<String, String> mMap = new ArrayMap<>(); 28e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 29e4b93061ac703e48fc2c9994c9059ed016f05559George Mount public CastTest() { 304c5cc009bcbcfb19e33fb19db5ec80f83f7b3326George Mount super(CastTestBinding.class); 31e4b93061ac703e48fc2c9994c9059ed016f05559George Mount } 32e4b93061ac703e48fc2c9994c9059ed016f05559George Mount 33e4b93061ac703e48fc2c9994c9059ed016f05559George Mount @UiThreadTest 34e4b93061ac703e48fc2c9994c9059ed016f05559George Mount public void testCast() throws Throwable { 353f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar initBinder(); 363f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mValues.clear(); 373f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mValues.add("hello"); 383f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mValues.add("world"); 393f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mValues.add("not seen"); 403f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mMap.clear(); 413f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mMap.put("hello", "world"); 423f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mMap.put("world", "hello"); 433f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mBinder.setList(mValues); 443f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mBinder.setMap(mMap); 453f73e3149732132c02f5d19aab7b5da429794058Yigit Boyar mBinder.executePendingBindings(); 4634a18e6a231f3b64726bd93e7e097a0d5a75995dGeorge Mount assertEquals("hello", mBinder.textView0.getText().toString()); 4734a18e6a231f3b64726bd93e7e097a0d5a75995dGeorge Mount assertEquals("world", mBinder.textView1.getText().toString()); 48e4b93061ac703e48fc2c9994c9059ed016f05559George Mount } 49e4b93061ac703e48fc2c9994c9059ed016f05559George Mount} 50