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.InnerCannotReadDependencyBinding;
     19 import android.databinding.testapp.vo.BasicObject;
     20 import android.os.Debug;
     21 import android.test.UiThreadTest;
     22 
     23 public class InnerCannotReadDependencyTest extends
     24         BaseDataBinderTest<InnerCannotReadDependencyBinding> {
     25 
     26     public InnerCannotReadDependencyTest() {
     27         super(InnerCannotReadDependencyBinding.class);
     28     }
     29 
     30     @UiThreadTest
     31     public void testBinding() {
     32         initBinder();
     33         BasicObject object = new BasicObject();
     34         object.setField1("a");
     35         mBinder.setObj(object);
     36         mBinder.executePendingBindings();
     37         assertEquals("a ", mBinder.textView.getText().toString());
     38         object.setField1(null);
     39         mBinder.executePendingBindings();
     40         assertEquals("null ", mBinder.textView.getText().toString());
     41         object.setField2("b");
     42         mBinder.executePendingBindings();
     43         assertEquals("null b", mBinder.textView.getText().toString());
     44         object.setField1("c");
     45         mBinder.executePendingBindings();
     46         assertEquals("c b", mBinder.textView.getText().toString());
     47     }
     48 }
     49