summaryrefslogtreecommitdiff
path: root/integration-tests
diff options
context:
space:
mode:
authorYigit Boyar <yboyar@google.com>2015-10-15 11:02:39 -0700
committerYigit Boyar <yboyar@google.com>2015-10-16 09:38:55 -0700
commit88ce44ccc65e74a8553244ca246cc9f4c48483e0 (patch)
tree6be0849dac09954b51388881c9c7577802d7ec2e /integration-tests
parent5cc6ea2e84b7c310fbb355ce76001648132a80cb (diff)
downloaddata-binding-88ce44ccc65e74a8553244ca246cc9f4c48483e0.tar.gz
Create BR id from Callable
This CL fixes a bug where if an expression maps into a method with a different name, we would create the BR id from the expression instead of the referenced method. Bug: 24973950 Change-Id: Ia57c31d926a737c9fc84775780aeb5e617769d43
Diffstat (limited to 'integration-tests')
-rw-r--r--integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/NameMappingTest.java71
-rw-r--r--integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/BasicObject.java11
-rw-r--r--integration-tests/TestApp/app/src/main/res/layout/name_mapping_test.xml24
3 files changed, 106 insertions, 0 deletions
diff --git a/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/NameMappingTest.java b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/NameMappingTest.java
new file mode 100644
index 00000000..ce505d52
--- /dev/null
+++ b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/NameMappingTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 android.databinding.testapp;
+
+import android.databinding.testapp.databinding.NameMappingTestBinding;
+import android.databinding.testapp.vo.BasicObject;
+import android.test.UiThreadTest;
+import android.databinding.testapp.BR;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class NameMappingTest extends BaseDataBinderTest<NameMappingTestBinding> {
+
+ public NameMappingTest() {
+ super(NameMappingTestBinding.class);
+ }
+
+ @UiThreadTest
+ public void testChanges() {
+ initBinder();
+ final AtomicBoolean f1 = new AtomicBoolean(false);
+ final AtomicBoolean f2 = new AtomicBoolean(false);
+ BasicObject object = new BasicObject() {
+ @Override
+ public boolean isThisNameDoesNotMatchAnythingElse1() {
+ return f1.get();
+ }
+
+ @Override
+ public boolean getThisNameDoesNotMatchAnythingElse2() {
+ return f2.get();
+ }
+ };
+ mBinder.setObj(object);
+ mBinder.executePendingBindings();
+ for (int i = 0; i < 5; i ++) {
+ boolean f1New = (i & 1) != 0;
+ boolean f2New = (i & 1 << 1) != 0;
+ if (f1New != f1.get()) {
+ f1.set(f1New);
+ object.notifyPropertyChanged(BR.thisNameDoesNotMatchAnythingElse1);
+ }
+ if (f2New != f2.get()) {
+ f1.set(f2New);
+ object.notifyPropertyChanged(BR.thisNameDoesNotMatchAnythingElse2);
+ }
+ mBinder.executePendingBindings();
+ assertEquals(f2.get(), mBinder.textView.isEnabled());
+ assertEquals(f2.get(), mBinder.textView2.isEnabled());
+ assertEquals(false, mBinder.textView3.isEnabled());
+
+ assertEquals(f1.get(), mBinder.textView.isFocusable());
+ assertEquals(f1.get(), mBinder.textView2.isFocusable());
+ assertEquals(false, mBinder.textView3.isFocusable());
+ }
+ }
+}
diff --git a/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/BasicObject.java b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/BasicObject.java
index 4ec76c5a..5f332ef6 100644
--- a/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/BasicObject.java
+++ b/integration-tests/TestApp/app/src/main/java/android/databinding/testapp/vo/BasicObject.java
@@ -43,6 +43,17 @@ public class BasicObject extends BaseObservable {
notifyPropertyChanged(BR.field1);
}
+ @Bindable
+ public boolean isThisNameDoesNotMatchAnythingElse1() {
+ // see: https://code.google.com/p/android/issues/detail?id=190207
+ return false;
+ }
+
+ @Bindable
+ public boolean getThisNameDoesNotMatchAnythingElse2() {
+ return false;
+ }
+
public String boolMethod(boolean value) {
return value ? "true" : "false";
}
diff --git a/integration-tests/TestApp/app/src/main/res/layout/name_mapping_test.xml b/integration-tests/TestApp/app/src/main/res/layout/name_mapping_test.xml
new file mode 100644
index 00000000..1ed651b0
--- /dev/null
+++ b/integration-tests/TestApp/app/src/main/res/layout/name_mapping_test.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout>
+ <data>
+ <variable name="obj" type="android.databinding.testapp.vo.BasicObject"/>
+ </data>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:id="@+id/textView"
+ android:enabled="@{obj.getThisNameDoesNotMatchAnythingElse2}"
+ android:focusable="@{obj.isThisNameDoesNotMatchAnythingElse1}"/>
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:id="@+id/textView2"
+ android:enabled="@{obj.thisNameDoesNotMatchAnythingElse2}"
+ android:focusable="@{obj.thisNameDoesNotMatchAnythingElse1}"/>
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:id="@+id/textView3"
+ android:enabled="@{obj.getThisNameDoesNotMatchAnythingElse2()}"
+ android:focusable="@{obj.isThisNameDoesNotMatchAnythingElse1()}"/>
+
+ </LinearLayout>
+</layout> \ No newline at end of file