171eb6908f2689bd17000237eb645896c36da0138George Mount/*
271eb6908f2689bd17000237eb645896c36da0138George Mount * Copyright (C) 2015 The Android Open Source Project
371eb6908f2689bd17000237eb645896c36da0138George Mount *
471eb6908f2689bd17000237eb645896c36da0138George Mount * Licensed under the Apache License, Version 2.0 (the "License");
571eb6908f2689bd17000237eb645896c36da0138George Mount * you may not use this file except in compliance with the License.
671eb6908f2689bd17000237eb645896c36da0138George Mount * You may obtain a copy of the License at
771eb6908f2689bd17000237eb645896c36da0138George Mount *
871eb6908f2689bd17000237eb645896c36da0138George Mount *      http://www.apache.org/licenses/LICENSE-2.0
971eb6908f2689bd17000237eb645896c36da0138George Mount *
1071eb6908f2689bd17000237eb645896c36da0138George Mount * Unless required by applicable law or agreed to in writing, software
1171eb6908f2689bd17000237eb645896c36da0138George Mount * distributed under the License is distributed on an "AS IS" BASIS,
1271eb6908f2689bd17000237eb645896c36da0138George Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1371eb6908f2689bd17000237eb645896c36da0138George Mount * See the License for the specific language governing permissions and
1471eb6908f2689bd17000237eb645896c36da0138George Mount * limitations under the License.
1571eb6908f2689bd17000237eb645896c36da0138George Mount */
16fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountpackage android.databinding.testapp;
1771eb6908f2689bd17000237eb645896c36da0138George Mount
182e2043d30f95585de2069e1cbb23e022ab0e71c4George Mountimport android.databinding.testapp.databinding.ViewGroupAdapterTestBinding;
19fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountimport android.databinding.testapp.vo.ViewGroupBindingObject;
2071eb6908f2689bd17000237eb645896c36da0138George Mount
2171eb6908f2689bd17000237eb645896c36da0138George Mountimport android.os.Build;
2271eb6908f2689bd17000237eb645896c36da0138George Mountimport android.view.ViewGroup;
2371eb6908f2689bd17000237eb645896c36da0138George Mount
2471eb6908f2689bd17000237eb645896c36da0138George Mountpublic class ViewGroupBindingAdapterTest
254c5cc009bcbcfb19e33fb19db5ec80f83f7b3326George Mount        extends BindingAdapterTestBase<ViewGroupAdapterTestBinding, ViewGroupBindingObject> {
2671eb6908f2689bd17000237eb645896c36da0138George Mount
2771eb6908f2689bd17000237eb645896c36da0138George Mount    ViewGroup mView;
2871eb6908f2689bd17000237eb645896c36da0138George Mount
2971eb6908f2689bd17000237eb645896c36da0138George Mount    public ViewGroupBindingAdapterTest() {
304c5cc009bcbcfb19e33fb19db5ec80f83f7b3326George Mount        super(ViewGroupAdapterTestBinding.class, ViewGroupBindingObject.class,
3171eb6908f2689bd17000237eb645896c36da0138George Mount                R.layout.view_group_adapter_test);
3271eb6908f2689bd17000237eb645896c36da0138George Mount    }
3371eb6908f2689bd17000237eb645896c36da0138George Mount
3471eb6908f2689bd17000237eb645896c36da0138George Mount    @Override
3571eb6908f2689bd17000237eb645896c36da0138George Mount    protected void setUp() throws Exception {
3671eb6908f2689bd17000237eb645896c36da0138George Mount        super.setUp();
3734a18e6a231f3b64726bd93e7e097a0d5a75995dGeorge Mount        mView = mBinder.view;
3871eb6908f2689bd17000237eb645896c36da0138George Mount    }
3971eb6908f2689bd17000237eb645896c36da0138George Mount
4071eb6908f2689bd17000237eb645896c36da0138George Mount    public void testDrawnWithCache() throws Throwable {
4171eb6908f2689bd17000237eb645896c36da0138George Mount        assertEquals(mBindingObject.isAlwaysDrawnWithCache(),
4271eb6908f2689bd17000237eb645896c36da0138George Mount                mView.isAlwaysDrawnWithCacheEnabled());
4371eb6908f2689bd17000237eb645896c36da0138George Mount
4471eb6908f2689bd17000237eb645896c36da0138George Mount        changeValues();
4571eb6908f2689bd17000237eb645896c36da0138George Mount
4671eb6908f2689bd17000237eb645896c36da0138George Mount        assertEquals(mBindingObject.isAlwaysDrawnWithCache(),
4771eb6908f2689bd17000237eb645896c36da0138George Mount                mView.isAlwaysDrawnWithCacheEnabled());
4871eb6908f2689bd17000237eb645896c36da0138George Mount    }
4971eb6908f2689bd17000237eb645896c36da0138George Mount
5071eb6908f2689bd17000237eb645896c36da0138George Mount    public void testAnimationCache() throws Throwable {
5171eb6908f2689bd17000237eb645896c36da0138George Mount        assertEquals(mBindingObject.isAnimationCache(), mView.isAnimationCacheEnabled());
5271eb6908f2689bd17000237eb645896c36da0138George Mount
5371eb6908f2689bd17000237eb645896c36da0138George Mount        changeValues();
5471eb6908f2689bd17000237eb645896c36da0138George Mount
5571eb6908f2689bd17000237eb645896c36da0138George Mount        assertEquals(mBindingObject.isAnimationCache(), mView.isAnimationCacheEnabled());
5671eb6908f2689bd17000237eb645896c36da0138George Mount    }
5771eb6908f2689bd17000237eb645896c36da0138George Mount
5871eb6908f2689bd17000237eb645896c36da0138George Mount    public void testSplitMotionEvents() throws Throwable {
5971eb6908f2689bd17000237eb645896c36da0138George Mount        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
6071eb6908f2689bd17000237eb645896c36da0138George Mount            assertEquals(mBindingObject.isSplitMotionEvents(),
6171eb6908f2689bd17000237eb645896c36da0138George Mount                    mView.isMotionEventSplittingEnabled());
6271eb6908f2689bd17000237eb645896c36da0138George Mount
6371eb6908f2689bd17000237eb645896c36da0138George Mount            changeValues();
6471eb6908f2689bd17000237eb645896c36da0138George Mount
6571eb6908f2689bd17000237eb645896c36da0138George Mount            assertEquals(mBindingObject.isSplitMotionEvents(),
6671eb6908f2689bd17000237eb645896c36da0138George Mount                    mView.isMotionEventSplittingEnabled());
6771eb6908f2689bd17000237eb645896c36da0138George Mount        }
6871eb6908f2689bd17000237eb645896c36da0138George Mount    }
6971eb6908f2689bd17000237eb645896c36da0138George Mount
7071eb6908f2689bd17000237eb645896c36da0138George Mount    public void testAnimateLayoutChanges() throws Throwable {
7171eb6908f2689bd17000237eb645896c36da0138George Mount        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
7271eb6908f2689bd17000237eb645896c36da0138George Mount            assertEquals(mBindingObject.isAnimateLayoutChanges(),
7371eb6908f2689bd17000237eb645896c36da0138George Mount                    mView.getLayoutTransition() != null);
7471eb6908f2689bd17000237eb645896c36da0138George Mount
7571eb6908f2689bd17000237eb645896c36da0138George Mount            changeValues();
7671eb6908f2689bd17000237eb645896c36da0138George Mount
7771eb6908f2689bd17000237eb645896c36da0138George Mount            assertEquals(mBindingObject.isAnimateLayoutChanges(),
7871eb6908f2689bd17000237eb645896c36da0138George Mount                    mView.getLayoutTransition() != null);
7971eb6908f2689bd17000237eb645896c36da0138George Mount        }
8071eb6908f2689bd17000237eb645896c36da0138George Mount    }
8171eb6908f2689bd17000237eb645896c36da0138George Mount}
82