Loading core/tests/coretests/Android.mk +10 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,16 @@ LOCAL_SRC_FILES := \ LOCAL_DX_FLAGS := --core-library LOCAL_AAPT_FLAGS = -0 dat -0 gld LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support android-common frameworks-core-util-lib mockwebserver guava littlemock mockito-target LOCAL_STATIC_JAVA_LIBRARIES := \ core-tests-support \ android-common \ frameworks-core-util-lib \ mockwebserver \ guava \ littlemock \ android-support-test \ mockito-target \ espresso-core LOCAL_JAVA_LIBRARIES := android.test.runner conscrypt telephony-common org.apache.http.legacy LOCAL_PACKAGE_NAME := FrameworksCoreTests Loading core/tests/coretests/AndroidManifest.xml +8 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,13 @@ </intent-filter> </activity> <activity android:name="android.widget.TextViewActivity" android:label="TextViewActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" /> </intent-filter> </activity> <activity android:name="android.widget.focus.DescendantFocusability" android:label="DescendantFocusability"> <intent-filter> <action android:name="android.intent.action.MAIN" /> Loading Loading @@ -1269,7 +1276,7 @@ </application> <instrumentation android:name="android.test.InstrumentationTestRunner" <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.coretests" android:label="Frameworks Core Tests" /> <key-sets> Loading core/tests/coretests/res/layout/activity_text_view.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2015 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/textview" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> No newline at end of file core/tests/coretests/src/android/widget/TextViewActivity.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package android.widget; import com.android.frameworks.coretests.R; import android.app.Activity; import android.os.Bundle; /** * An activity for testing the TextView widget. */ public class TextViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_text_view); } } core/tests/coretests/src/android/widget/TextViewActivityTest.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package android.widget; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; import com.android.frameworks.coretests.R; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.SmallTest; /** * Tests the TextView widget from an Activity */ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextViewActivity>{ public TextViewActivityTest() { super(TextViewActivity.class); } @SmallTest public void testTypedTextIsOnScreen() throws Exception { getActivity(); final String helloWorld = "Hello world!"; onView(withId(R.id.textview)).perform(click()); onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(helloWorld)); onView(withId(R.id.textview)).check(matches(withText(helloWorld))); } } Loading
core/tests/coretests/Android.mk +10 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,16 @@ LOCAL_SRC_FILES := \ LOCAL_DX_FLAGS := --core-library LOCAL_AAPT_FLAGS = -0 dat -0 gld LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support android-common frameworks-core-util-lib mockwebserver guava littlemock mockito-target LOCAL_STATIC_JAVA_LIBRARIES := \ core-tests-support \ android-common \ frameworks-core-util-lib \ mockwebserver \ guava \ littlemock \ android-support-test \ mockito-target \ espresso-core LOCAL_JAVA_LIBRARIES := android.test.runner conscrypt telephony-common org.apache.http.legacy LOCAL_PACKAGE_NAME := FrameworksCoreTests Loading
core/tests/coretests/AndroidManifest.xml +8 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,13 @@ </intent-filter> </activity> <activity android:name="android.widget.TextViewActivity" android:label="TextViewActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" /> </intent-filter> </activity> <activity android:name="android.widget.focus.DescendantFocusability" android:label="DescendantFocusability"> <intent-filter> <action android:name="android.intent.action.MAIN" /> Loading Loading @@ -1269,7 +1276,7 @@ </application> <instrumentation android:name="android.test.InstrumentationTestRunner" <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.frameworks.coretests" android:label="Frameworks Core Tests" /> <key-sets> Loading
core/tests/coretests/res/layout/activity_text_view.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2015 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/textview" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> No newline at end of file
core/tests/coretests/src/android/widget/TextViewActivity.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package android.widget; import com.android.frameworks.coretests.R; import android.app.Activity; import android.os.Bundle; /** * An activity for testing the TextView widget. */ public class TextViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_text_view); } }
core/tests/coretests/src/android/widget/TextViewActivityTest.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package android.widget; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; import com.android.frameworks.coretests.R; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.SmallTest; /** * Tests the TextView widget from an Activity */ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextViewActivity>{ public TextViewActivityTest() { super(TextViewActivity.class); } @SmallTest public void testTypedTextIsOnScreen() throws Exception { getActivity(); final String helloWorld = "Hello world!"; onView(withId(R.id.textview)).perform(click()); onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(helloWorld)); onView(withId(R.id.textview)).check(matches(withText(helloWorld))); } }