diff options
Diffstat (limited to 'integration-tests')
7 files changed, 158 insertions, 20 deletions
diff --git a/integration-tests/TestApp/app/src/androidTest/AndroidManifest.xml b/integration-tests/TestApp/app/src/androidTest/AndroidManifest.xml index 6a02a9f2..9153bc8a 100644 --- a/integration-tests/TestApp/app/src/androidTest/AndroidManifest.xml +++ b/integration-tests/TestApp/app/src/androidTest/AndroidManifest.xml @@ -11,16 +11,13 @@ ~ limitations under the License. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - package="android.databinding.testapp"> - <uses-sdk android:minSdkVersion="14" tools:overrideLibrary="android.support.test, - android.app, android.support.test.rule, android.support.test.espresso, - android.support.test.espresso.idling"/> - <application android:allowBackup="true"> - <activity android:name=".TestActivity" - android:screenOrientation="portrait"/> - <activity android:name=".LandscapeActivity" - android:screenOrientation="landscape"/> - </application> + xmlns:tools="http://schemas.android.com/tools" + package="android.databinding.testapp"> + <uses-sdk + android:minSdkVersion="14" + tools:overrideLibrary="android.support.test, + android.app, android.support.test.rule, android.support.test.espresso, + android.support.test.espresso.idling" /> + <application android:allowBackup="true"/> </manifest> diff --git a/integration-tests/TestApp/app/src/androidTest/java/android/databinding/testapp/RecursiveLayoutTest.java b/integration-tests/TestApp/app/src/androidTest/java/android/databinding/testapp/RecursiveLayoutTest.java new file mode 100644 index 00000000..0dfff7c0 --- /dev/null +++ b/integration-tests/TestApp/app/src/androidTest/java/android/databinding/testapp/RecursiveLayoutTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 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 android.databinding.testapp; + +import android.databinding.testapp.databinding.RecursiveLayoutBinding; +import android.databinding.testapp.vo.RecursiveClass; +import android.support.test.annotation.UiThreadTest; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(AndroidJUnit4.class) +public class RecursiveLayoutTest extends BaseDataBinderTest<RecursiveLayoutBinding> { + public RecursiveLayoutTest() { + super(RecursiveLayoutBinding.class); + } + + @Test + @UiThreadTest + public void runRecursiveTest() { + initBinder(); + RecursiveClass recursiveClass = new RecursiveClass(); + recursiveClass.text = "foo"; + + mBinder.setRecursiveClass(recursiveClass); + mBinder.executePendingBindings(); + assertThat( + mBinder.recursiveClassText.getText().toString(), + is("foo") + ); + assertThat( + mBinder.recursiveClassViaAdapterText.getText().toString(), + is("foo foo") + ); + } +} diff --git a/integration-tests/TestApp/app/src/main/AndroidManifest.xml b/integration-tests/TestApp/app/src/main/AndroidManifest.xml index 10b5ec55..201c0b23 100644 --- a/integration-tests/TestApp/app/src/main/AndroidManifest.xml +++ b/integration-tests/TestApp/app/src/main/AndroidManifest.xml @@ -12,15 +12,19 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="android.databinding.testapp"> + package="android.databinding.testapp"> - <application android:allowBackup="true" - android:icon="@drawable/ic_launcher" - > - <activity android:name=".TestActivity" - android:screenOrientation="portrait"/> - <activity android:name=".LandscapeActivity" - android:screenOrientation="landscape"/> + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher"> + <activity + android:name=".TestActivity" + android:screenOrientation="portrait" + android:theme="@style/noAnimTheme" /> + <activity + android:name=".LandscapeActivity" + android:screenOrientation="landscape" + android:theme="@style/noAnimTheme"/> </application> </manifest> diff --git a/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/adapter/RecursiveAdapter.java b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/adapter/RecursiveAdapter.java new file mode 100644 index 00000000..d4147fee --- /dev/null +++ b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/adapter/RecursiveAdapter.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 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 android.databinding.testapp.adapter; + +import android.databinding.testapp.vo.RecursiveClass; +import android.widget.TextView; + +import androidx.databinding.BindingAdapter; + +public class RecursiveAdapter { + @BindingAdapter("recursive") + public static void setRecursive( + TextView textView, + RecursiveClass recursive + ) { + textView.setText(recursive.text + " " + recursive.text); + } +} diff --git a/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/RecursiveClass.java b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/RecursiveClass.java new file mode 100644 index 00000000..d5d26f00 --- /dev/null +++ b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/RecursiveClass.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2019 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 android.databinding.testapp.vo; + +public class RecursiveClass<T extends RecursiveClass<T>> { + public String text; +} diff --git a/integration-tests/TestApp/app/src/main/res/layout/recursive_layout.xml b/integration-tests/TestApp/app/src/main/res/layout/recursive_layout.xml new file mode 100644 index 00000000..0b4025f9 --- /dev/null +++ b/integration-tests/TestApp/app/src/main/res/layout/recursive_layout.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2019 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. + --> +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <data> + <variable name="recursiveClass" type="android.databinding.testapp.vo.RecursiveClass" /> + </data> + + <LinearLayout + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView + android:id="@+id/recursiveClassText" + android:text="@{recursiveClass.text}" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + <TextView + android:id="@+id/recursiveClassViaAdapterText" + app:recursive="@{recursiveClass}" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + </LinearLayout> +</layout>
\ No newline at end of file diff --git a/integration-tests/TestApp/app/src/main/res/values/styles.xml b/integration-tests/TestApp/app/src/main/res/values/styles.xml index c0d54711..6f0b9d1d 100644 --- a/integration-tests/TestApp/app/src/main/res/values/styles.xml +++ b/integration-tests/TestApp/app/src/main/res/values/styles.xml @@ -14,8 +14,11 @@ <resources> <!-- Base application theme. --> - <style name="AppTheme" parent="android:Theme.Holo"> + <style name="AppTheme" parent="android:Theme.Light"> <!-- Customize your theme here. --> </style> + <style name="noAnimTheme" parent="AppTheme"> + <item name="android:windowAnimationStyle">@null</item> + </style> </resources> |