Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51843716 authored by George Mount's avatar George Mount
Browse files

Made new breaking test.

Bug 19286803
parent e7b29847
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.databinding.testapp;

import com.android.databinding.testapp.generated.BindToFinalBinder;
import com.android.databinding.testapp.vo.PublicFinalTestVo;
import com.android.databinding.testapp.vo.PublicFinalWithObservableTestVo;

import android.test.UiThreadTest;
import android.widget.TextView;

public class BindToFinalObservableFieldTest extends BaseDataBinderTest<BindToFinalObservableBinder>{

    public BindToFinalObservableFieldTest() {
        super(BindToFinalBinder.class, R.layout.bind_to_final_observable);
    }

    @UiThreadTest
    public void testSimple() {
        final PublicFinalWithObservableTestVo vo = new PublicFinalWithObservableTestVo(R.string.app_name);
        mBinder.setObj(vo);
        mBinder.rebindDirty();
        final TextView textView = (TextView) mBinder.getRoot().findViewById(R.id.text_view);
        assertEquals(getActivity().getResources().getString(R.string.app_name), textView.getText().toString());
        final TextView textView2 = (TextView) mBinder.getRoot().findViewById(R.id.text_view2);
        assertEquals(getActivity().getResources().getString(R.string.app_name), textView2.getText().toString());
    }


}
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.databinding.testapp.vo;

import com.android.databinding.library.BaseObservable;
import com.android.databinding.testapp.R;

import android.binding.Bindable;

public class PublicFinalWithObservableTestVo {
    public final int myField;
    public final MyVo myFinalVo = new MyVo();

    public PublicFinalWithObservableTestVo(int field) {
        myField = field;
    }

    public static class MyVo extends BaseObservable {
        @Bindable
        private int val = R.string.app_name;

        public int getVal() {
            return val;
        }

        public void setVal(int val) {
            this.val = val;
            notifyPropertyChanged(android.binding.BR.val);
        }
    }
}
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <variable name="obj" type="com.android.databinding.testapp.vo.PublicFinalTestVo"/>
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:id="@+id/text_view"
            android:text="@{obj.myField}"/>
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
              android:id="@+id/text_view2"
              android:text="@{obj.myVo.val}"/>
</LinearLayout>
 No newline at end of file