BaseDataBinderTest.java revision dc69f49d687ec036947f26a9bf9025a305de0721
1dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar/* 2dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * Copyright (C) 2015 The Android Open Source Project 3dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * Licensed under the Apache License, Version 2.0 (the "License"); 4dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * you may not use this file except in compliance with the License. 5dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * You may obtain a copy of the License at 6dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * http://www.apache.org/licenses/LICENSE-2.0 7dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * Unless required by applicable law or agreed to in writing, software 8dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * distributed under the License is distributed on an "AS IS" BASIS, 9dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * See the License for the specific language governing permissions and 11dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar * limitations under the License. 12dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar */ 13dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 14dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyarpackage com.android.databinding.testapp; 15dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 16dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyarimport com.android.databinding.library.DataBinder; 17dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyarimport com.android.databinding.library.IViewDataBinder; 18dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 19dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyarimport android.test.ActivityInstrumentationTestCase2; 20dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 21dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyarpublic class BaseDataBinderTest<T extends IViewDataBinder> 22dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar extends ActivityInstrumentationTestCase2<TestActivity> { 23dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar private Class<T> mBinderClass; 24dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar private int mLayoutId; 25dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar protected T mBinder; 26dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 27dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar public BaseDataBinderTest(final Class<T> binderClass, final int layoutId) { 28dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar super(TestActivity.class); 29dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar mBinderClass = binderClass; 30dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar mLayoutId = layoutId; 31dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar } 32dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar 33dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar @Override 34dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar protected void setUp() throws Exception { 35dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar super.setUp(); 36dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar getActivity().runOnUiThread(new Runnable() { 37dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar @Override 38dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar public void run() { 39dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar mBinder = DataBinder.createBinder(mBinderClass, getActivity(), mLayoutId, null); 40dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar } 41dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar }); 42dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar getInstrumentation().waitForIdleSync(); 43dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar assertNotNull(mBinder); 44dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar } 45dc69f49d687ec036947f26a9bf9025a305de0721Yigit Boyar} 46