Home | History | Annotate | Download | only in multimoduletestapp
      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  */
     16 
     17 package com.android.databinding.multimoduletestapp;
     18 
     19 import android.databinding.DataBindingUtil;
     20 import android.databinding.ViewDataBinding;
     21 import android.databinding.multimoduletestapp.R;
     22 import android.test.AndroidTestCase;
     23 import android.view.LayoutInflater;
     24 import android.view.View;
     25 
     26 public class GeneratedLayoutTest extends AndroidTestCase {
     27     public void testBindToGeneratedLayout() {
     28         LayoutInflater inflater = LayoutInflater.from(getContext());
     29         View view = inflater.inflate(R.layout.library_layout, null);
     30         // force override tag
     31         view.setTag("layout-sw600dp-land-v13/library_layout_0");
     32         ViewDataBinding bind = DataBindingUtil.bind(view);
     33         assertEquals("IndependentLibraryBindingSw600dpLandV13Impl",
     34                 bind.getClass().getSimpleName());
     35     }
     36 
     37     public void testBindToDefault() {
     38         LayoutInflater inflater = LayoutInflater.from(getContext());
     39         View view = inflater.inflate(R.layout.library_layout, null);
     40         // force override tag
     41         view.setTag("layout/library_layout_0");
     42         ViewDataBinding bind = DataBindingUtil.bind(view);
     43         assertEquals("IndependentLibraryBindingImpl",
     44                 bind.getClass().getSimpleName());
     45     }
     46 
     47     public void testBindToSw600() {
     48         LayoutInflater inflater = LayoutInflater.from(getContext());
     49         View view = inflater.inflate(R.layout.library_layout, null);
     50         // force override tag
     51         view.setTag("layout-sw600dp-land/library_layout_0");
     52         ViewDataBinding bind = DataBindingUtil.bind(view);
     53         assertEquals("IndependentLibraryBindingSw600dpLandImpl",
     54                 bind.getClass().getSimpleName());
     55     }
     56 }
     57