Home | History | Annotate | Download | only in testapp
      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  */
     16 package android.databinding.testapp;
     17 
     18 import android.databinding.testapp.databinding.GenericAdapterBinding;
     19 import android.test.UiThreadTest;
     20 
     21 import java.util.ArrayList;
     22 import java.util.Arrays;
     23 import java.util.List;
     24 
     25 public class GenericAdapterTest extends BaseDataBinderTest<GenericAdapterBinding> {
     26 
     27     public GenericAdapterTest() {
     28         super(GenericAdapterBinding.class);
     29     }
     30 
     31     @UiThreadTest
     32     public void testGenericArgs() throws Throwable {
     33         initBinder();
     34 
     35         String[] arr = { "Hello", "World" };
     36         List<String> list = Arrays.asList(arr);
     37         getBinder().setList(list);
     38         getBinder().setArr(arr);
     39         getBinder().executePendingBindings();
     40         assertEquals("Hello World", getBinder().textView1.getText().toString());
     41         assertEquals("Hello World", getBinder().textView2.getText().toString());
     42         assertEquals("Hello World", getBinder().textView3.getText().toString());
     43         assertEquals("Hello World", getBinder().textView4.getText().toString());
     44         assertEquals(list, getBinder().view5.getList());
     45         assertEquals(list, getBinder().view6.getList());
     46         assertEquals("Hello World", getBinder().textView7.getText().toString());
     47     }
     48 }
     49