ViewGroupBindingAdapterTest.java revision 4d4979490e1fa374c0d7f3599fed0a9e83a579d0
1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package android.databinding.testapp; 17 18import android.databinding.testapp.databinding.ViewGroupAdapterTestBinding; 19import android.databinding.testapp.vo.ViewGroupBindingObject; 20 21import android.os.Build; 22import android.view.ViewGroup; 23 24public class ViewGroupBindingAdapterTest 25 extends BindingAdapterTestBase<ViewGroupAdapterTestBinding, ViewGroupBindingObject> { 26 27 ViewGroup mView; 28 29 public ViewGroupBindingAdapterTest() { 30 super(ViewGroupAdapterTestBinding.class, ViewGroupBindingObject.class, 31 R.layout.view_group_adapter_test); 32 } 33 34 @Override 35 protected void setUp() throws Exception { 36 super.setUp(); 37 mView = mBinder.view; 38 } 39 40 public void testDrawnWithCache() throws Throwable { 41 assertEquals(mBindingObject.isAlwaysDrawnWithCache(), 42 mView.isAlwaysDrawnWithCacheEnabled()); 43 44 changeValues(); 45 46 assertEquals(mBindingObject.isAlwaysDrawnWithCache(), 47 mView.isAlwaysDrawnWithCacheEnabled()); 48 } 49 50 public void testAnimationCache() throws Throwable { 51 assertEquals(mBindingObject.isAnimationCache(), mView.isAnimationCacheEnabled()); 52 53 changeValues(); 54 55 assertEquals(mBindingObject.isAnimationCache(), mView.isAnimationCacheEnabled()); 56 } 57 58 public void testSplitMotionEvents() throws Throwable { 59 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 60 assertEquals(mBindingObject.isSplitMotionEvents(), 61 mView.isMotionEventSplittingEnabled()); 62 63 changeValues(); 64 65 assertEquals(mBindingObject.isSplitMotionEvents(), 66 mView.isMotionEventSplittingEnabled()); 67 } 68 } 69 70 public void testAnimateLayoutChanges() throws Throwable { 71 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 72 assertEquals(mBindingObject.isAnimateLayoutChanges(), 73 mView.getLayoutTransition() != null); 74 75 changeValues(); 76 77 assertEquals(mBindingObject.isAnimateLayoutChanges(), 78 mView.getLayoutTransition() != null); 79 } 80 } 81} 82