diff options
author | Yigit Boyar <yboyar@google.com> | 2015-11-10 18:16:36 -0800 |
---|---|---|
committer | Yigit Boyar <yboyar@google.com> | 2015-11-11 13:18:22 -0800 |
commit | 28e7064d455e2ef9da31c817dfc05ec7405c60df (patch) | |
tree | 82dcf9066526452f185cbddcc189b3c43c6a235c /integration-tests | |
parent | fccc888b6465488b9ad74f4ca0b58c85502ae089 (diff) | |
download | data-binding-28e7064d455e2ef9da31c817dfc05ec7405c60df.tar.gz |
Override layout file metadata from module
If a layout file is inherited from a module but also exists
in the app, w~e force the app version to the metadata of the
module version. This means forcing its created class location
to be the same as the module. This usually happens when gradle
or aapt generates some layout during app compilation.
Bug: 25369165
Change-Id: I5d2002ac04d16cfe9935fe5580548344b19b4aca
Diffstat (limited to 'integration-tests')
3 files changed, 85 insertions, 1 deletions
diff --git a/integration-tests/IndependentLibrary/app/src/main/res/layout-sw600dp-land/library_layout.xml b/integration-tests/IndependentLibrary/app/src/main/res/layout-sw600dp-land/library_layout.xml new file mode 100644 index 00000000..301663b0 --- /dev/null +++ b/integration-tests/IndependentLibrary/app/src/main/res/layout-sw600dp-land/library_layout.xml @@ -0,0 +1,29 @@ +<?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. + --> +<layout xmlns:android="http://schemas.android.com/apk/res/android"> + <data class=".IndependentLibraryBinding"> + <variable name="foo" + type="android.databinding.test.independentlibrary.vo.MyBindableObject"/> + </data> + <LinearLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <TextView android:layout_width="match_parent" android:layout_height="wrap_content" + android:id="@+id/fooTextView" + android:text='@{foo.field + " " + foo.field}'/> + </LinearLayout> +</layout> diff --git a/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/EventIdsTest.java b/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/EventIdsTest.java index 9a04368c..8ef36b45 100644 --- a/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/EventIdsTest.java +++ b/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/EventIdsTest.java @@ -20,7 +20,6 @@ import android.databinding.testlibrary.ObservableInLibrary; import android.databinding.Observable; import android.databinding.Observable.OnPropertyChangedCallback; -import android.os.Debug; import android.test.AndroidTestCase; import java.util.HashMap; diff --git a/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/GeneratedLayoutTest.java b/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/GeneratedLayoutTest.java new file mode 100644 index 00000000..f83e9c04 --- /dev/null +++ b/integration-tests/MultiModuleTestApp/app/src/androidTest/java/com/android/databinding/multimoduletestapp/GeneratedLayoutTest.java @@ -0,0 +1,56 @@ +/* + * 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.multimoduletestapp; + +import android.databinding.DataBindingUtil; +import android.databinding.ViewDataBinding; +import android.databinding.multimoduletestapp.R; +import android.test.AndroidTestCase; +import android.view.LayoutInflater; +import android.view.View; + +public class GeneratedLayoutTest extends AndroidTestCase { + public void testBindToGeneratedLayout() { + LayoutInflater inflater = LayoutInflater.from(getContext()); + View view = inflater.inflate(R.layout.library_layout, null); + // force override tag + view.setTag("layout-sw600dp-land-v13/library_layout_0"); + ViewDataBinding bind = DataBindingUtil.bind(view); + assertEquals("IndependentLibraryBindingSw600dpLandV13Impl", + bind.getClass().getSimpleName()); + } + + public void testBindToDefault() { + LayoutInflater inflater = LayoutInflater.from(getContext()); + View view = inflater.inflate(R.layout.library_layout, null); + // force override tag + view.setTag("layout/library_layout_0"); + ViewDataBinding bind = DataBindingUtil.bind(view); + assertEquals("IndependentLibraryBindingImpl", + bind.getClass().getSimpleName()); + } + + public void testBindToSw600() { + LayoutInflater inflater = LayoutInflater.from(getContext()); + View view = inflater.inflate(R.layout.library_layout, null); + // force override tag + view.setTag("layout-sw600dp-land/library_layout_0"); + ViewDataBinding bind = DataBindingUtil.bind(view); + assertEquals("IndependentLibraryBindingSw600dpLandImpl", + bind.getClass().getSimpleName()); + } +} |