summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Wharton <jakew@google.com>2020-01-13 11:34:21 -0500
committerTreeHugger Robot <treehugger-gerrit@google.com>2020-02-26 04:21:18 +0000
commitbdccf4df8473123a4c60a5cf6857146c6104c007 (patch)
tree227c344a9d35c46618100bc2e0647579ceb24e11
parent648545ea6d60aaab35669904d926833445495751 (diff)
downloaddata-binding-bdccf4df8473123a4c60a5cf6857146c6104c007.tar.gz
Add feature module to integration test
This reproduces an incorrect behavior where an included layout from the app module does not propagate the binding type and instead reverts back to View. Bug: 142939794 Test: ../base/bazel/bazel test --test_output=all //tools/base/build-system/integration-test/databinding:tests //tools/data-binding/... Change-Id: I276fc309a0398f10f93cff3402c9c1050b571dd8
-rw-r--r--integration-tests/ViewBindingTestApp/app-with-features/build.gradle45
-rw-r--r--integration-tests/ViewBindingTestApp/app-with-features/src/main/AndroidManifest.xml17
-rw-r--r--integration-tests/ViewBindingTestApp/app-with-features/src/main/res/layout/include_from_library.xml30
-rw-r--r--integration-tests/ViewBindingTestApp/app-with-features/src/main/res/values/strings.xml19
-rw-r--r--integration-tests/ViewBindingTestApp/feature/build.gradle41
-rw-r--r--integration-tests/ViewBindingTestApp/feature/src/androidTest/java/com/example/feature/IncludeFromAppTest.java39
-rw-r--r--integration-tests/ViewBindingTestApp/feature/src/main/AndroidManifest.xml28
-rw-r--r--integration-tests/ViewBindingTestApp/feature/src/main/res/layout/include_from_app.xml26
-rw-r--r--integration-tests/ViewBindingTestApp/settings.gradle2
9 files changed, 247 insertions, 0 deletions
diff --git a/integration-tests/ViewBindingTestApp/app-with-features/build.gradle b/integration-tests/ViewBindingTestApp/app-with-features/build.gradle
new file mode 100644
index 00000000..ef5ef7f2
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/app-with-features/build.gradle
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion rootProject.latestCompileSdk
+
+ defaultConfig {
+ applicationId 'com.example.viewbinding'
+ minSdkVersion 14
+ targetSdkVersion rootProject.latestCompileSdk
+ versionCode 1
+ versionName '1.0'
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ buildFeatures.viewBinding = true
+
+ dynamicFeatures = [
+ ":feature",
+ ]
+}
+
+dependencies {
+ implementation project(':lib-with-view-binding')
+ implementation project(':lib-without-view-binding')
+}
diff --git a/integration-tests/ViewBindingTestApp/app-with-features/src/main/AndroidManifest.xml b/integration-tests/ViewBindingTestApp/app-with-features/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..ce59c106
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/app-with-features/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+<!--
+ ~ 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.
+ -->
+
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.viewbinding.withfeatures"
+ />
diff --git a/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/layout/include_from_library.xml b/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/layout/include_from_library.xml
new file mode 100644
index 00000000..c261017a
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/layout/include_from_library.xml
@@ -0,0 +1,30 @@
+<?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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ >
+ <include
+ layout="@layout/simple_with_view_binding"
+ android:id="@+id/with"
+ />
+ <include
+ layout="@layout/simple_without_view_binding"
+ android:id="@+id/without"
+ />
+</LinearLayout>
diff --git a/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/values/strings.xml b/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/values/strings.xml
new file mode 100644
index 00000000..7fcbfd58
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/app-with-features/src/main/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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.
+ -->
+<resources>
+ <string name="feature_name">Feature</string>
+</resources> \ No newline at end of file
diff --git a/integration-tests/ViewBindingTestApp/feature/build.gradle b/integration-tests/ViewBindingTestApp/feature/build.gradle
new file mode 100644
index 00000000..34d8db22
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/feature/build.gradle
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 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.
+ `*/
+
+apply plugin: 'com.android.dynamic-feature'
+
+android {
+ compileSdkVersion rootProject.latestCompileSdk
+
+ defaultConfig {
+ minSdkVersion 14
+ targetSdkVersion rootProject.latestCompileSdk
+ testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ buildFeatures.viewBinding = true
+}
+
+dependencies {
+ implementation project(':app-with-features')
+
+ androidTestImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.1'
+}
diff --git a/integration-tests/ViewBindingTestApp/feature/src/androidTest/java/com/example/feature/IncludeFromAppTest.java b/integration-tests/ViewBindingTestApp/feature/src/androidTest/java/com/example/feature/IncludeFromAppTest.java
new file mode 100644
index 00000000..28cb90f8
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/feature/src/androidTest/java/com/example/feature/IncludeFromAppTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 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.example.feature;
+
+import static org.junit.Assert.assertNotNull;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.view.LayoutInflater;
+import android.view.View;
+import com.example.feature.databinding.IncludeFromAppBinding;
+import org.junit.Test;
+
+public final class IncludeFromAppTest {
+ private final Context context = InstrumentationRegistry.getTargetContext();
+ private final LayoutInflater inflater = LayoutInflater.from(context);
+
+ @Test public void inflate() {
+ IncludeFromAppBinding binding = IncludeFromAppBinding.inflate(inflater);
+
+ // TODO(b/142939794): This should be of type com.example.viewbinding.databinding.IncludeFromLibraryBinding
+ View with = binding.fromApp;
+ assertNotNull(with);
+ }
+}
diff --git a/integration-tests/ViewBindingTestApp/feature/src/main/AndroidManifest.xml b/integration-tests/ViewBindingTestApp/feature/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..4951cf29
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/feature/src/main/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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.
+ -->
+
+<manifest
+ xmlns:dist="http://schemas.android.com/apk/distribution"
+ package="com.example.feature"
+ >
+ <dist:module
+ dist:onDemand="true"
+ dist:title="@string/feature_name"
+ >
+ <dist:fusing dist:include="true" />
+ </dist:module>
+</manifest>
diff --git a/integration-tests/ViewBindingTestApp/feature/src/main/res/layout/include_from_app.xml b/integration-tests/ViewBindingTestApp/feature/src/main/res/layout/include_from_app.xml
new file mode 100644
index 00000000..43dc08ab
--- /dev/null
+++ b/integration-tests/ViewBindingTestApp/feature/src/main/res/layout/include_from_app.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ >
+ <include
+ layout="@layout/include_from_library"
+ android:id="@+id/from_app"
+ />
+</LinearLayout>
diff --git a/integration-tests/ViewBindingTestApp/settings.gradle b/integration-tests/ViewBindingTestApp/settings.gradle
index 9f1b48a1..67c31f2e 100644
--- a/integration-tests/ViewBindingTestApp/settings.gradle
+++ b/integration-tests/ViewBindingTestApp/settings.gradle
@@ -1,4 +1,6 @@
include ':app'
include ':app-test'
+include ':app-with-features'
+include ':feature'
include ':lib-with-view-binding'
include ':lib-without-view-binding'