PortraitConfigTest.java revision 23910cf498c35704a03ba4f3889de2ab97ccbe21
1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *      http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 */
13
14package android.databinding.testapp.multiconfig;
15
16import android.databinding.ViewDataBinding;
17import android.databinding.testapp.BaseDataBinderTest;
18import android.databinding.testapp.BR;
19import android.databinding.testapp.databinding.BasicBindingBinding;
20import android.databinding.testapp.databinding.ConditionalBindingBinding;
21import android.databinding.testapp.databinding.IncludedLayoutBinding;
22import android.databinding.testapp.databinding.MultiResLayoutBinding;
23import android.databinding.testapp.vo.NotBindableVo;
24
25import android.content.pm.ActivityInfo;
26import android.test.UiThreadTest;
27import android.view.View;
28import android.widget.EditText;
29import android.widget.TextView;
30
31public class PortraitConfigTest extends BaseDataBinderTest<MultiResLayoutBinding> {
32    public PortraitConfigTest() {
33        super(MultiResLayoutBinding.class, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
34    }
35
36    public void testSharedViewIdAndVariableInheritance()
37            throws InterruptedException, NoSuchMethodException, NoSuchFieldException {
38        initBinder();
39        assertEquals("MultiResLayoutBindingImpl", mBinder.getClass().getSimpleName());
40        assertPublicField(TextView.class, "objectInLandTextView");
41        assertPublicField(TextView.class, "objectInDefaultTextView");
42        assertPublicField(View.class, "objectInDefaultTextView2");
43
44        assertField(NotBindableVo.class, "mObjectInDefault");
45
46        // includes
47        assertPublicField(ViewDataBinding.class, "includedLayoutConflict");
48        assertPublicField(BasicBindingBinding.class, "includedLayoutShared");
49        assertPublicField(ConditionalBindingBinding.class, "includedLayoutPort");
50        assertPublicField(ConditionalBindingBinding.class, "includedLayoutLand");
51    }
52
53    @UiThreadTest
54    public void testSetVariable() throws Throwable {
55        initBinder();
56        assertTrue(mBinder.setVariable(BR.objectInBoth, null));
57        assertTrue(mBinder.setVariable(BR.objectInDefault, null));
58        assertFalse(mBinder.setVariable(BR.obj, null));
59        assertFalse(mBinder.setVariable(BR.objectInLand, null));
60    }
61}
62