diff options
author | Yigit Boyar <yboyar@google.com> | 2015-06-24 22:11:03 -0700 |
---|---|---|
committer | Yigit Boyar <yboyar@google.com> | 2015-06-25 14:46:31 -0700 |
commit | c1560e6b00b398867da12fbdc5a1fcd1d50b801c (patch) | |
tree | 27521fb6aa8dc42bdc2a4e4fec92b3d68e5fb422 /integration-tests/TestApp/app | |
parent | 2611838bffef5a009ca71e3e9e59a93f29b098ed (diff) | |
download | data-binding-c1560e6b00b398867da12fbdc5a1fcd1d50b801c.tar.gz |
Carry over location information from parser to annotation processor
This CL changes LayoutParser to use Antlr which provides us the location
information. This information is now serialized inside the bundle so
that we can read it in the annotation processor, enabling better error
logs with location information.
Bug:21953001
Change-Id: If9b5cf2f87598a609ddf77235decc17098a46a6b
Diffstat (limited to 'integration-tests/TestApp/app')
-rw-r--r-- | integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/ViewWithTagTest.java | 41 | ||||
-rw-r--r-- | integration-tests/TestApp/app/src/main/res/layout/view_with_tag.xml | 30 |
2 files changed, 71 insertions, 0 deletions
diff --git a/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/ViewWithTagTest.java b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/ViewWithTagTest.java new file mode 100644 index 00000000..05ad2b1d --- /dev/null +++ b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/ViewWithTagTest.java @@ -0,0 +1,41 @@ +/* + * 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.ViewWithTagBinding; +import android.support.annotation.UiThread; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +public class ViewWithTagTest extends BaseDataBinderTest<ViewWithTagBinding> { + public ViewWithTagTest() { + super(ViewWithTagBinding.class); + } + + @UiThread + public void test() { + ViewWithTagBinding binder = initBinder(); + binder.setStr("i don't have tag"); + binder.executePendingBindings(); + ViewGroup root = (ViewGroup) binder.getRoot(); + View view1 = root.getChildAt(0); + View view2 = root.getChildAt(1); + assertTrue(view2 instanceof TextView); + assertEquals("i don't have tag", ((TextView) view2).getText().toString()); + assertEquals("i have a tag", view1.getTag().toString()); + } +} diff --git a/integration-tests/TestApp/app/src/main/res/layout/view_with_tag.xml b/integration-tests/TestApp/app/src/main/res/layout/view_with_tag.xml new file mode 100644 index 00000000..a7103902 --- /dev/null +++ b/integration-tests/TestApp/app/src/main/res/layout/view_with_tag.xml @@ -0,0 +1,30 @@ +<?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> + <variable name="str" type="String"/> + </data> + <LinearLayout + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + <View + android:tag="i have a tag" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + <TextView + android:text="@{str}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </LinearLayout> +</layout> |