diff options
author | Xavier Ducrohet <xav@android.com> | 2013-02-01 00:14:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-02-01 00:14:36 +0000 |
commit | fe7619fba11fad0ca5cc1550d18f45c20eb8401c (patch) | |
tree | ac12afcad14b202eadc102e8251c47fb70dd14a5 /tests | |
parent | 5c3042311f016d8086b7f8744d3ac088656495e6 (diff) | |
parent | 5fdd1fe8a46f5d87aced3c544ec966e2b038f757 (diff) | |
download | build-fe7619fba11fad0ca5cc1550d18f45c20eb8401c.tar.gz |
Merge "Fix generation of R class for libraries."
Diffstat (limited to 'tests')
30 files changed, 464 insertions, 1 deletions
diff --git a/tests/libsTest/app/build.gradle b/tests/libsTest/app/build.gradle index 29c70bc..eded7c2 100644 --- a/tests/libsTest/app/build.gradle +++ b/tests/libsTest/app/build.gradle @@ -9,4 +9,6 @@ android { // dependencies { compile project(':lib1') + compile project(':lib2b') + compile project(':libapp') } diff --git a/tests/libsTest/app/src/main/java/com/android/tests/libstest/app/MainActivity.java b/tests/libsTest/app/src/main/java/com/android/tests/libstest/app/MainActivity.java index 8992066..739f91e 100644 --- a/tests/libsTest/app/src/main/java/com/android/tests/libstest/app/MainActivity.java +++ b/tests/libsTest/app/src/main/java/com/android/tests/libstest/app/MainActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import com.android.tests.libstest.lib1.Lib1; import com.android.tests.libstest.lib2.Lib2; +import com.android.tests.libstest.lib2.Lib2b; public class MainActivity extends Activity { /** Called when the activity is first created. */ @@ -16,5 +17,7 @@ public class MainActivity extends Activity { App.handleTextView(this); Lib1.handleTextView(this); Lib2.handleTextView(this); + Lib2b.handleTextView(this); + LibApp.handleTextView(this); } }
\ No newline at end of file diff --git a/tests/libsTest/app/src/main/res/layout/main.xml b/tests/libsTest/app/src/main/res/layout/main.xml index f735960..fa1aaba 100644 --- a/tests/libsTest/app/src/main/res/layout/main.xml +++ b/tests/libsTest/app/src/main/res/layout/main.xml @@ -18,4 +18,8 @@ <include layout="@layout/lib1_main" /> + <include layout="@layout/lib2b_main" /> + + <include layout="@layout/libapp_main" /> + </LinearLayout>
\ No newline at end of file diff --git a/tests/libsTest/app/src/test/java/com/android/tests/libstest/app/MainActivityTest.java b/tests/libsTest/app/src/test/java/com/android/tests/libstest/app/MainActivityTest.java index 012a4e2..61a0a31 100644 --- a/tests/libsTest/app/src/test/java/com/android/tests/libstest/app/MainActivityTest.java +++ b/tests/libsTest/app/src/test/java/com/android/tests/libstest/app/MainActivityTest.java @@ -45,6 +45,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv private TextView mLib1TextView2; private TextView mLib2TextView1; private TextView mLib2TextView2; + private TextView mLib2bTextView1; + private TextView mLib2bTextView2; + private TextView mLibappTextView1; + private TextView mLibappTextView2; /** * Creates an {@link ActivityInstrumentationTestCase2} that tests the {@link Focus2} activity. @@ -66,6 +70,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv mLib1TextView2 = (TextView) a.findViewById(R.id.lib1_text2); mLib2TextView1 = (TextView) a.findViewById(R.id.lib2_text1); mLib2TextView2 = (TextView) a.findViewById(R.id.lib2_text2); + mLib2bTextView1 = (TextView) a.findViewById(R.id.lib2b_text1); + mLib2bTextView2 = (TextView) a.findViewById(R.id.lib2b_text2); + mLibappTextView1 = (TextView) a.findViewById(R.id.libapp_text1); + mLibappTextView2 = (TextView) a.findViewById(R.id.libapp_text2); } /** @@ -82,6 +90,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv assertNotNull(mLib1TextView2); assertNotNull(mLib2TextView1); assertNotNull(mLib2TextView2); + assertNotNull(mLib2bTextView1); + assertNotNull(mLib2bTextView2); + assertNotNull(mLibappTextView1); + assertNotNull(mLibappTextView2); } @MediumTest @@ -89,6 +101,8 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv assertEquals(mAppTextView1.getText(), "SUCCESS-APP"); assertEquals(mLib1TextView1.getText(), "SUCCESS-LIB1"); assertEquals(mLib2TextView1.getText(), "SUCCESS-LIB2"); + assertEquals(mLib2bTextView1.getText(), "SUCCESS-LIB2b"); + assertEquals(mLibappTextView1.getText(), "SUCCESS-LIBAPP"); } @MediumTest @@ -96,5 +110,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv assertEquals(mAppTextView2.getText(), "SUCCESS-APP"); assertEquals(mLib1TextView2.getText(), "SUCCESS-LIB1"); assertEquals(mLib2TextView2.getText(), "SUCCESS-LIB2"); + assertEquals(mLib2bTextView2.getText(), "SUCCESS-LIB2b"); + assertEquals(mLibappTextView2.getText(), "SUCCESS-LIBAPP"); } } diff --git a/tests/libsTest/build.gradle b/tests/libsTest/build.gradle index a0832c6..8090336 100644 --- a/tests/libsTest/build.gradle +++ b/tests/libsTest/build.gradle @@ -6,3 +6,5 @@ buildscript { classpath 'com.android.tools.build:gradle:0.3-SNAPSHOT' } } + +apply plugin: 'android-reporting'
\ No newline at end of file diff --git a/tests/libsTest/lib2b/build.gradle b/tests/libsTest/lib2b/build.gradle new file mode 100644 index 0000000..a810790 --- /dev/null +++ b/tests/libsTest/lib2b/build.gradle @@ -0,0 +1,6 @@ +apply plugin: 'android-library' + +android { + target = "android-15" + +}
\ No newline at end of file diff --git a/tests/libsTest/lib2b/proguard-project.txt b/tests/libsTest/lib2b/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/tests/libsTest/lib2b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/libsTest/lib2b/src/main/AndroidManifest.xml b/tests/libsTest/lib2b/src/main/AndroidManifest.xml new file mode 100644 index 0000000..814af46 --- /dev/null +++ b/tests/libsTest/lib2b/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.tests.libstest.lib2" + android:versionCode="1" + android:versionName="1.0" > + + <application + android:icon="@drawable/ic_launcher" + android:label="@string/lib2b_name" > + <activity + android:name="MainActivity2b" + android:label="@string/lib2b_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest>
\ No newline at end of file diff --git a/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/Lib2b.java b/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/Lib2b.java new file mode 100644 index 0000000..e4329e5 --- /dev/null +++ b/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/Lib2b.java @@ -0,0 +1,43 @@ +package com.android.tests.libstest.lib2; + +import android.app.Activity; +import android.widget.TextView; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class Lib2b { + + public static void handleTextView(Activity a) { + TextView tv = (TextView) a.findViewById(R.id.lib2b_text2); + if (tv != null) { + tv.setText(getContent()); + } + } + + private static String getContent() { + InputStream input = Lib2b.class.getResourceAsStream("Lib2b.txt"); + if (input == null) { + return "FAILED TO FIND Lib2b.txt"; + } + + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + + return reader.readLine(); + } catch (IOException e) { + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + } + } + } + + return "FAILED TO READ CONTENT"; + } +} diff --git a/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/MainActivity2b.java b/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/MainActivity2b.java new file mode 100644 index 0000000..2e09018 --- /dev/null +++ b/tests/libsTest/lib2b/src/main/java/com/android/tests/libstest/lib2/MainActivity2b.java @@ -0,0 +1,15 @@ +package com.android.tests.libstest.lib2; + +import android.app.Activity; +import android.os.Bundle; + +public class MainActivity2b extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.lib2b_main); + + Lib2b.handleTextView(this); + } +} diff --git a/tests/libsTest/lib2b/src/main/res/drawable-hdpi/ic_launcher.png b/tests/libsTest/lib2b/src/main/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..8074c4c --- /dev/null +++ b/tests/libsTest/lib2b/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/tests/libsTest/lib2b/src/main/res/drawable-ldpi/ic_launcher.png b/tests/libsTest/lib2b/src/main/res/drawable-ldpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..1095584 --- /dev/null +++ b/tests/libsTest/lib2b/src/main/res/drawable-ldpi/ic_launcher.png diff --git a/tests/libsTest/lib2b/src/main/res/drawable-mdpi/ic_launcher.png b/tests/libsTest/lib2b/src/main/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..a07c69f --- /dev/null +++ b/tests/libsTest/lib2b/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/tests/libsTest/lib2b/src/main/res/layout/lib2b_main.xml b/tests/libsTest/lib2b/src/main/res/layout/lib2b_main.xml new file mode 100644 index 0000000..01e6a9f --- /dev/null +++ b/tests/libsTest/lib2b/src/main/res/layout/lib2b_main.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/lib2b_text1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/lib2b_string" /> + + <TextView + android:id="@+id/lib2b_text2" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + +</LinearLayout>
\ No newline at end of file diff --git a/tests/libsTest/lib2b/src/main/res/values/strings.xml b/tests/libsTest/lib2b/src/main/res/values/strings.xml new file mode 100644 index 0000000..d21e21f --- /dev/null +++ b/tests/libsTest/lib2b/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="lib2b_name">LibsTest-lib2b</string> + <string name="lib2b_string">SUCCESS-LIB2b</string> + +</resources>
\ No newline at end of file diff --git a/tests/libsTest/lib2b/src/main/resources/com/android/tests/libstest/lib2/Lib2b.txt b/tests/libsTest/lib2b/src/main/resources/com/android/tests/libstest/lib2/Lib2b.txt new file mode 100644 index 0000000..59e6b48 --- /dev/null +++ b/tests/libsTest/lib2b/src/main/resources/com/android/tests/libstest/lib2/Lib2b.txt @@ -0,0 +1 @@ +SUCCESS-LIB2b
\ No newline at end of file diff --git a/tests/libsTest/lib2b/src/test/java/com/android/tests/libstest/lib2/MainActivity2bTest.java b/tests/libsTest/lib2b/src/test/java/com/android/tests/libstest/lib2/MainActivity2bTest.java new file mode 100644 index 0000000..35c56e3 --- /dev/null +++ b/tests/libsTest/lib2b/src/test/java/com/android/tests/libstest/lib2/MainActivity2bTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2008 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 com.android.tests.libstest.lib2; + +import android.test.ActivityInstrumentationTestCase2; +import android.test.suitebuilder.annotation.MediumTest; +import android.widget.TextView; + +import com.android.tests.libstest.lib2.R; + +/** + * An example of an {@link ActivityInstrumentationTestCase2} of a specific activity {@link Focus2}. + * By virtue of extending {@link ActivityInstrumentationTestCase2}, the target activity is automatically + * launched and finished before and after each test. This also extends + * {@link android.test.InstrumentationTestCase}, which provides + * access to methods for sending events to the target activity, such as key and + * touch events. See {@link #sendKeys}. + * + * In general, {@link android.test.InstrumentationTestCase}s and {@link ActivityInstrumentationTestCase2}s + * are heavier weight functional tests available for end to end testing of your + * user interface. When run via a {@link android.test.InstrumentationTestRunner}, + * the necessary {@link android.app.Instrumentation} will be injected for you to + * user via {@link #getInstrumentation} in your tests. + * + * See {@link com.example.android.apis.AllTests} for documentation on running + * all tests and individual tests in this application. + */ +public class MainActivity2bTest extends ActivityInstrumentationTestCase2<MainActivity2b> { + + private TextView mTextView1; + private TextView mTextView2; + + /** + * Creates an {@link ActivityInstrumentationTestCase2} that tests the {@link Focus2} activity. + */ + public MainActivity2bTest() { + super(MainActivity2b.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + final MainActivity2b a = getActivity(); + // ensure a valid handle to the activity has been returned + assertNotNull(a); + + mTextView1 = (TextView) a.findViewById(R.id.lib2b_text1); + mTextView2 = (TextView) a.findViewById(R.id.lib2b_text2); + } + + /** + * The name 'test preconditions' is a convention to signal that if this + * test doesn't pass, the test case was not set up properly and it might + * explain any and all failures in other tests. This is not guaranteed + * to run before other tests, as junit uses reflection to find the tests. + */ + @MediumTest + public void testPreconditions() { + assertNotNull(mTextView1); + assertNotNull(mTextView2); + } + + @MediumTest + public void testAndroidStrings() { + assertEquals("SUCCESS-LIB2b", mTextView1.getText()); + } + + @MediumTest + public void testJavaStrings() { + assertEquals("SUCCESS-LIB2b", mTextView2.getText()); + } +} diff --git a/tests/libsTest/libapp/build.gradle b/tests/libsTest/libapp/build.gradle new file mode 100644 index 0000000..a810790 --- /dev/null +++ b/tests/libsTest/libapp/build.gradle @@ -0,0 +1,6 @@ +apply plugin: 'android-library' + +android { + target = "android-15" + +}
\ No newline at end of file diff --git a/tests/libsTest/libapp/proguard-project.txt b/tests/libsTest/libapp/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/tests/libsTest/libapp/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/libsTest/libapp/src/main/AndroidManifest.xml b/tests/libsTest/libapp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0592d2d --- /dev/null +++ b/tests/libsTest/libapp/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.tests.libstest.app" + android:versionCode="1" + android:versionName="1.0" > + + <application + android:icon="@drawable/ic_launcher" + android:label="@string/libapp_name" > + <activity + android:name="MainActivityLibApp" + android:label="@string/libapp_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest>
\ No newline at end of file diff --git a/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/LibApp.java b/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/LibApp.java new file mode 100644 index 0000000..9a25e9e --- /dev/null +++ b/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/LibApp.java @@ -0,0 +1,43 @@ +package com.android.tests.libstest.app; + +import android.app.Activity; +import android.widget.TextView; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class LibApp { + + public static void handleTextView(Activity a) { + TextView tv = (TextView) a.findViewById(R.id.libapp_text2); + if (tv != null) { + tv.setText(getContent()); + } + } + + private static String getContent() { + InputStream input = LibApp.class.getResourceAsStream("Libapp.txt"); + if (input == null) { + return "FAILED TO FIND Libapp.txt"; + } + + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); + + return reader.readLine(); + } catch (IOException e) { + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + } + } + } + + return "FAILED TO READ CONTENT"; + } +} diff --git a/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/MainActivityLibApp.java b/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/MainActivityLibApp.java new file mode 100644 index 0000000..65460f7 --- /dev/null +++ b/tests/libsTest/libapp/src/main/java/com/android/tests/libstest/app/MainActivityLibApp.java @@ -0,0 +1,15 @@ +package com.android.tests.libstest.app; + +import android.app.Activity; +import android.os.Bundle; + +public class MainActivityLibApp extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.libapp_main); + + LibApp.handleTextView(this); + } +} diff --git a/tests/libsTest/libapp/src/main/res/drawable-hdpi/ic_launcher.png b/tests/libsTest/libapp/src/main/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..8074c4c --- /dev/null +++ b/tests/libsTest/libapp/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/tests/libsTest/libapp/src/main/res/drawable-ldpi/ic_launcher.png b/tests/libsTest/libapp/src/main/res/drawable-ldpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..1095584 --- /dev/null +++ b/tests/libsTest/libapp/src/main/res/drawable-ldpi/ic_launcher.png diff --git a/tests/libsTest/libapp/src/main/res/drawable-mdpi/ic_launcher.png b/tests/libsTest/libapp/src/main/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..a07c69f --- /dev/null +++ b/tests/libsTest/libapp/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/tests/libsTest/libapp/src/main/res/layout/libapp_main.xml b/tests/libsTest/libapp/src/main/res/layout/libapp_main.xml new file mode 100644 index 0000000..6bf607b --- /dev/null +++ b/tests/libsTest/libapp/src/main/res/layout/libapp_main.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/libapp_text1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/libapp_string" /> + + <TextView + android:id="@+id/libapp_text2" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + +</LinearLayout>
\ No newline at end of file diff --git a/tests/libsTest/libapp/src/main/res/values/strings.xml b/tests/libsTest/libapp/src/main/res/values/strings.xml new file mode 100644 index 0000000..0a0a597 --- /dev/null +++ b/tests/libsTest/libapp/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="libapp_name">LibsTest-libapp</string> + <string name="libapp_string">SUCCESS-LIBAPP</string> + +</resources>
\ No newline at end of file diff --git a/tests/libsTest/libapp/src/main/resources/com/android/tests/libstest/app/Libapp.txt b/tests/libsTest/libapp/src/main/resources/com/android/tests/libstest/app/Libapp.txt new file mode 100644 index 0000000..9d626ac --- /dev/null +++ b/tests/libsTest/libapp/src/main/resources/com/android/tests/libstest/app/Libapp.txt @@ -0,0 +1 @@ +SUCCESS-LIBAPP
\ No newline at end of file diff --git a/tests/libsTest/libapp/src/test/java/com/android/tests/libstest/libapp/MainActivityLibAppTest.java b/tests/libsTest/libapp/src/test/java/com/android/tests/libstest/libapp/MainActivityLibAppTest.java new file mode 100644 index 0000000..e6087a7 --- /dev/null +++ b/tests/libsTest/libapp/src/test/java/com/android/tests/libstest/libapp/MainActivityLibAppTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2008 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 com.android.tests.libstest.app; + +import android.test.ActivityInstrumentationTestCase2; +import android.test.suitebuilder.annotation.MediumTest; +import android.widget.TextView; + +import com.android.tests.libstest.app.R; + +/** + * An example of an {@link ActivityInstrumentationTestCase2} of a specific activity {@link Focus2}. + * By virtue of extending {@link ActivityInstrumentationTestCase2}, the target activity is automatically + * launched and finished before and after each test. This also extends + * {@link android.test.InstrumentationTestCase}, which provides + * access to methods for sending events to the target activity, such as key and + * touch events. See {@link #sendKeys}. + * + * In general, {@link android.test.InstrumentationTestCase}s and {@link ActivityInstrumentationTestCase2}s + * are heavier weight functional tests available for end to end testing of your + * user interface. When run via a {@link android.test.InstrumentationTestRunner}, + * the necessary {@link android.app.Instrumentation} will be injected for you to + * user via {@link #getInstrumentation} in your tests. + * + * See {@link com.example.android.apis.AllTests} for documentation on running + * all tests and individual tests in this application. + */ +public class MainActivityLibAppTest extends ActivityInstrumentationTestCase2<MainActivityLibApp> { + + private TextView mTextView1; + private TextView mTextView2; + + /** + * Creates an {@link ActivityInstrumentationTestCase2} that tests the {@link Focus2} activity. + */ + public MainActivityLibAppTest() { + super(MainActivityLibApp.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + final MainActivityLibApp a = getActivity(); + // ensure a valid handle to the activity has been returned + assertNotNull(a); + + mTextView1 = (TextView) a.findViewById(R.id.libapp_text1); + mTextView2 = (TextView) a.findViewById(R.id.libapp_text2); + } + + /** + * The name 'test preconditions' is a convention to signal that if this + * test doesn't pass, the test case was not set up properly and it might + * explain any and all failures in other tests. This is not guaranteed + * to run before other tests, as junit uses reflection to find the tests. + */ + @MediumTest + public void testPreconditions() { + assertNotNull(mTextView1); + assertNotNull(mTextView2); + } + + @MediumTest + public void testAndroidStrings() { + assertEquals("SUCCESS-LIBAPP", mTextView1.getText()); + } + + @MediumTest + public void testJavaStrings() { + assertEquals("SUCCESS-LIBAPP", mTextView2.getText()); + } +} diff --git a/tests/libsTest/settings.gradle b/tests/libsTest/settings.gradle index 1a602d2..c8ed4b4 100644 --- a/tests/libsTest/settings.gradle +++ b/tests/libsTest/settings.gradle @@ -1,3 +1,5 @@ include 'app' include 'lib1' -include 'lib2'
\ No newline at end of file +include 'lib2' +include 'lib2b' +include 'libapp' |