Debian Codegraph @

integration-tests/TestApp/app/src/androidTestApi7/java/android/databinding/testapp/NoIdTest.java

raw
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
14 package android.databinding.testapp;
15
16 import android.databinding.testapp.databinding.NoIdTestBinding;
17
18 import android.test.UiThreadTest;
19 import android.widget.LinearLayout;
20 import android.widget.TextView;
21
22 public class NoIdTest extends BaseDataBinderTest<NoIdTestBinding> {
23 public NoIdTest() {
24 super(NoIdTestBinding.class);
25 }
26
27 @Override
28 protected void setUp() throws Exception {
29 super.setUp();
30 initBinder(new Runnable() {
31 @Override
32 public void run() {
33 mBinder.setName("hello");
34 mBinder.setOrientation(LinearLayout.VERTICAL);
35 mBinder.executePendingBindings();
36 }
37 });
38 }
39
40 @UiThreadTest
41 public void testOnRoot() {
42 LinearLayout linearLayout = (LinearLayout) mBinder.getRoot();
43 assertEquals(LinearLayout.VERTICAL, linearLayout.getOrientation());
44 mBinder.setOrientation(LinearLayout.HORIZONTAL);
45 mBinder.executePendingBindings();
46 assertEquals(LinearLayout.HORIZONTAL, linearLayout.getOrientation());
47 }
48
49 @UiThreadTest
50 public void testNormal() {
51 LinearLayout linearLayout = (LinearLayout) mBinder.getRoot();
52 TextView view = (TextView) linearLayout.getChildAt(0);
53 assertEquals("hello world", view.getTag());
54 assertEquals("hello", view.getText().toString());
55 mBinder.setName("world");
56 mBinder.executePendingBindings();
57 assertEquals("world", view.getText().toString());
58 }
59
60 @UiThreadTest
61 public void testNoTag() {
62 LinearLayout linearLayout = (LinearLayout) mBinder.getRoot();
63 TextView view = (TextView) linearLayout.getChildAt(1);
64 assertNull(view.getTag());
65 }
66
67 @UiThreadTest
68 public void testResourceTag() {
69 LinearLayout linearLayout = (LinearLayout) mBinder.getRoot();
70 TextView view = (TextView) linearLayout.getChildAt(2);
71 String expectedValue = view.getResources().getString(R.string.app_name);
72 assertEquals(expectedValue, view.getTag());
73 }
74
75 @UiThreadTest
76 public void testAndroidResourceTag() {
77 LinearLayout linearLayout = (LinearLayout) mBinder.getRoot();
78 TextView view = (TextView) linearLayout.getChildAt(3);
79 String expectedValue = view.getResources().getString(android.R.string.ok);
80 assertEquals(expectedValue, view.getTag());
81 }
82
83 @UiThreadTest
84 public void testIdOnly() {
85 assertEquals("hello", mBinder.textView.getText().toString());
86 }
87 }