diff options
author | Yigit Boyar <yboyar@google.com> | 2015-06-26 16:08:10 -0700 |
---|---|---|
committer | Yigit Boyar <yboyar@google.com> | 2015-06-30 10:15:01 -0700 |
commit | 4df4ba38a62b791bbbc25e923efe8d9c2f9a52e9 (patch) | |
tree | 5f02b3c7293c044b19c3a35f58e6d60181500703 /integration-tests | |
parent | 1b506ae96dc762ac027104248807ca3ae078711d (diff) | |
download | data-binding-4df4ba38a62b791bbbc25e923efe8d9c2f9a52e9.tar.gz |
Data binding startup improvement
This CL replaces how we map tags(string) to layout ids in the
generated DataBindingMapper class. Previously, we would create
a hashmap which was some unnecessary work in startup. The alternative
was using switch(string) but we did not want to require java 7.
This CL does what java 7's switch(string) would do thanks to the
well defined API of String.hashCode.
This CL also adds a method to DataBindingUtil to convert BR.ids
back to String for debugging purposes.
Bug: 22108735
Change-Id: I4b8ef816f4aac99b2963793dd46519b056ce4a30
Diffstat (limited to 'integration-tests')
-rw-r--r-- | integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/DataBindingMapperTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/DataBindingMapperTest.java b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/DataBindingMapperTest.java new file mode 100644 index 00000000..62904b49 --- /dev/null +++ b/integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/DataBindingMapperTest.java @@ -0,0 +1,30 @@ +/* + * 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.DataBindingUtil; +import android.test.AndroidTestCase; +import android.databinding.testapp.BR; + +import java.lang.reflect.Field; + + +public class DataBindingMapperTest extends AndroidTestCase { + public void testBrIds() throws IllegalAccessException { + for (Field field : BR.class.getDeclaredFields()) { + assertEquals(field.getName(), + DataBindingUtil.convertBrIdToString((int) field.get(BR.class))); + } + } +} |