1 /* 2 * Copyright (C) 2009 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 android.view.cts; 18 19 import com.android.cts.view.R; 20 21 22 import android.app.Activity; 23 import android.test.ActivityInstrumentationTestCase2; 24 import android.test.UiThreadTest; 25 import android.view.View; 26 import android.widget.Button; 27 import android.widget.EditText; 28 import android.widget.TextView; 29 30 public class View_IdsTest extends ActivityInstrumentationTestCase2<UsingViewsCtsActivity> { 31 public View_IdsTest() { 32 super("com.android.cts.view", UsingViewsCtsActivity.class); 33 } 34 35 @UiThreadTest 36 public void testIds() { 37 Activity activity = getActivity(); 38 39 EditText editText = (EditText) activity.findViewById(R.id.entry); 40 Button buttonOk = (Button) activity.findViewById(R.id.ok); 41 Button buttonCancel = (Button) activity.findViewById(R.id.cancel); 42 TextView symbol = (TextView) activity.findViewById(R.id.symbolball); 43 TextView warning = (TextView) activity.findViewById(R.id.warning); 44 45 assertNotNull(editText); 46 assertNotNull(buttonOk); 47 assertNotNull(buttonCancel); 48 assertNotNull(symbol); 49 assertNotNull(warning); 50 51 assertEquals(activity.getString(R.string.id_ok), buttonOk.getText().toString()); 52 assertEquals(activity.getString(R.string.id_cancel), buttonCancel.getText().toString()); 53 54 editText.setId(0x1111); 55 assertEquals(0x1111, editText.getId()); 56 assertSame(editText, (EditText) activity.findViewById(0x1111)); 57 58 buttonCancel.setId(0x9999); 59 assertEquals(0x9999, buttonCancel.getId()); 60 assertSame(buttonCancel, (Button) activity.findViewById(0x9999)); 61 } 62 } 63