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.ViewWithTagBinding;
     19 import android.support.annotation.UiThread;
     20 import android.view.View;
     21 import android.view.ViewGroup;
     22 import android.widget.TextView;
     23 
     24 public class ViewWithTagTest extends BaseDataBinderTest<ViewWithTagBinding> {
     25     public ViewWithTagTest() {
     26         super(ViewWithTagBinding.class);
     27     }
     28 
     29     @UiThread
     30     public void test() {
     31         ViewWithTagBinding binder = initBinder();
     32         binder.setStr("i don't have tag");
     33         binder.executePendingBindings();
     34         ViewGroup root = (ViewGroup) binder.getRoot();
     35         View view1 = root.getChildAt(0);
     36         View view2 = root.getChildAt(1);
     37         assertTrue(view2 instanceof TextView);
     38         assertEquals("i don't have tag", ((TextView) view2).getText().toString());
     39         assertEquals("i have a tag", view1.getTag().toString());
     40         assertEquals("Hello", view2.getTag(R.id.customTag));
     41     }
     42 }
     43