diff options
author | Brett Chabot <brettchabot@android.com> | 2010-03-18 18:47:53 -0700 |
---|---|---|
committer | Brett Chabot <brettchabot@android.com> | 2010-03-18 18:54:57 -0700 |
commit | 880855ed20bf9e95ca02e88ab54b71efa6dce45b (patch) | |
tree | ab0b976cbff10d8f4c80abc5963ff5c0b9dc8f88 | |
parent | 75a73dc9fb5345844c9529b578b473d84b04a158 (diff) | |
download | android_development-880855ed20bf9e95ca02e88ab54b71efa6dce45b.tar.gz android_development-880855ed20bf9e95ca02e88ab54b71efa6dce45b.tar.bz2 android_development-880855ed20bf9e95ca02e88ab54b71efa6dce45b.zip |
Remove use of deprecated API from test sample code.
Modify tests sample code to use ActivityInstrumentationTestCase2 and its new
constructor.
Change-Id: Idf927b6641c8dfb4aede8cb2bba45de29320bcf5
7 files changed, 98 insertions, 55 deletions
diff --git a/samples/ApiDemos/tests/src/com/example/android/apis/ApiDemosTest.java b/samples/ApiDemos/tests/src/com/example/android/apis/ApiDemosTest.java index bc174eaa0..ace52c497 100644 --- a/samples/ApiDemos/tests/src/com/example/android/apis/ApiDemosTest.java +++ b/samples/ApiDemos/tests/src/com/example/android/apis/ApiDemosTest.java @@ -16,22 +16,25 @@ package com.example.android.apis; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityInstrumentationTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class ApiDemosTest extends ActivityInstrumentationTestCase<ApiDemos> { +public class ApiDemosTest extends ActivityInstrumentationTestCase2<ApiDemos> { /** - * The first constructor parameter must refer to the package identifier of the - * package hosting the activity to be launched, which is specified in the AndroidManifest.xml - * file. This is not necessarily the same as the java package name of the class - in fact, in - * some cases it may not match at all. + * Create an {@link ActivityInstrumentationTestCase2} that tests the {@link ApiDemos} activity. */ public ApiDemosTest() { - super("com.example.android.apis", ApiDemos.class); + super(ApiDemos.class); } + /** + * Verifies that activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } diff --git a/samples/ApiDemos/tests/src/com/example/android/apis/view/Focus2ActivityTest.java b/samples/ApiDemos/tests/src/com/example/android/apis/view/Focus2ActivityTest.java index 5938209c4..b555913e4 100644 --- a/samples/ApiDemos/tests/src/com/example/android/apis/view/Focus2ActivityTest.java +++ b/samples/ApiDemos/tests/src/com/example/android/apis/view/Focus2ActivityTest.java @@ -18,7 +18,7 @@ package com.example.android.apis.view; import com.example.android.apis.R; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.MediumTest; import android.view.KeyEvent; import android.widget.Button; @@ -42,26 +42,25 @@ import android.widget.Button; * See {@link com.example.android.apis.AllTests} for documentation on running * all tests and individual tests in this application. */ -public class Focus2ActivityTest extends ActivityInstrumentationTestCase<Focus2> { +public class Focus2ActivityTest extends ActivityInstrumentationTestCase2<Focus2> { private Button mLeftButton; private Button mCenterButton; private Button mRightButton; /** - * The first constructor parameter must refer to the package identifier of the - * package hosting the activity to be launched, which is specified in the AndroidManifest.xml - * file. This is not necessarily the same as the java package name of the class - in fact, in - * some cases it may not match at all. + * Creates an {@link ActivityInstrumentationTestCase2} that tests the {@link Focus2} activity. */ public Focus2ActivityTest() { - super("com.example.android.apis", Focus2.class); + super(Focus2.class); } @Override protected void setUp() throws Exception { super.setUp(); final Focus2 a = getActivity(); + // ensure a valid handle to the activity has been returned + assertNotNull(a); mLeftButton = (Button) a.findViewById(R.id.leftButton); mCenterButton = (Button) a.findViewById(R.id.centerButton); mRightButton = (Button) a.findViewById(R.id.rightButton); diff --git a/samples/HelloActivity/tests/src/com/example/android/helloactivity/HelloActivityTest.java b/samples/HelloActivity/tests/src/com/example/android/helloactivity/HelloActivityTest.java index 6e032da2f..12f4991d3 100644 --- a/samples/HelloActivity/tests/src/com/example/android/helloactivity/HelloActivityTest.java +++ b/samples/HelloActivity/tests/src/com/example/android/helloactivity/HelloActivityTest.java @@ -16,18 +16,25 @@ package com.example.android.helloactivity; -import android.test.ActivityInstrumentationTestCase; - -import com.example.android.helloactivity.HelloActivity; +import android.test.ActivityInstrumentationTestCase2; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class HelloActivityTest extends ActivityInstrumentationTestCase<HelloActivity> { +public class HelloActivityTest extends ActivityInstrumentationTestCase2<HelloActivity> { + + /** + * Creates an {@link ActivityInstrumentationTestCase2} for the {@link HelloActivity} activity. + */ + public HelloActivityTest() { + super(HelloActivity.class); + } - public HelloActivityTest() { - super("com.example.android.helloactivity", HelloActivity.class); - } - + /** + * Verifies that the activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } diff --git a/samples/LunarLander/tests/src/com/example/android/lunarlander/LunarLanderTest.java b/samples/LunarLander/tests/src/com/example/android/lunarlander/LunarLanderTest.java index fae02da64..491748a9f 100644 --- a/samples/LunarLander/tests/src/com/example/android/lunarlander/LunarLanderTest.java +++ b/samples/LunarLander/tests/src/com/example/android/lunarlander/LunarLanderTest.java @@ -16,18 +16,27 @@ package com.example.android.lunarlander; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import com.example.android.lunarlander.LunarLander; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class LunarLanderTest extends ActivityInstrumentationTestCase<LunarLander> { +public class LunarLanderTest extends ActivityInstrumentationTestCase2<LunarLander> { - public LunarLanderTest() { - super("com.example.android.lunarlander", LunarLander.class); - } - + /** + * Creates an {@link ActivityInstrumentationTestCase2} for the {@link LunarLander} activity. + */ + public LunarLanderTest() { + super(LunarLander.class); + } + + /** + * Verifies that the activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } diff --git a/samples/NotePad/tests/src/com/example/android/notepad/NotePadTest.java b/samples/NotePad/tests/src/com/example/android/notepad/NotePadTest.java index 452c5991c..80f71d289 100644 --- a/samples/NotePad/tests/src/com/example/android/notepad/NotePadTest.java +++ b/samples/NotePad/tests/src/com/example/android/notepad/NotePadTest.java @@ -16,18 +16,27 @@ package com.example.android.notepad; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import com.example.android.notepad.NotesList; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class NotePadTest extends ActivityInstrumentationTestCase<NotesList> { +public class NotePadTest extends ActivityInstrumentationTestCase2<NotesList> { - public NotePadTest() { - super("com.example.android.notepad", NotesList.class); - } + /** + * Creates an {@link ActivityInstrumentationTestCase2} for the {@link NotesList} activity. + */ + public NotePadTest() { + super(NotesList.class); + } + /** + * Verifies that the activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } diff --git a/samples/SkeletonApp/tests/src/com/example/android/skeletonapp/SkeletonAppTest.java b/samples/SkeletonApp/tests/src/com/example/android/skeletonapp/SkeletonAppTest.java index 3123348eb..a7e00b5e8 100644 --- a/samples/SkeletonApp/tests/src/com/example/android/skeletonapp/SkeletonAppTest.java +++ b/samples/SkeletonApp/tests/src/com/example/android/skeletonapp/SkeletonAppTest.java @@ -16,17 +16,26 @@ package com.example.android.skeletonapp; -import android.test.ActivityInstrumentationTestCase; - -import com.example.android.skeletonapp.SkeletonActivity; +import android.test.ActivityInstrumentationTestCase2; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class SkeletonAppTest extends ActivityInstrumentationTestCase<SkeletonActivity> { +public class SkeletonAppTest extends ActivityInstrumentationTestCase2<SkeletonActivity> { + + /** + * Creates an {@link ActivityInstrumentationTestCase2} for the {@link SkeletonActivity} + * activity. + */ + public SkeletonAppTest() { + super(SkeletonActivity.class); + } - public SkeletonAppTest() { - super("com.example.android.skeletonapp", SkeletonActivity.class); - } + /** + * Verifies that the activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } diff --git a/samples/Snake/tests/src/com/example/android/snake/SnakeTest.java b/samples/Snake/tests/src/com/example/android/snake/SnakeTest.java index 35d1b1278..686eb5fd5 100644 --- a/samples/Snake/tests/src/com/example/android/snake/SnakeTest.java +++ b/samples/Snake/tests/src/com/example/android/snake/SnakeTest.java @@ -16,18 +16,25 @@ package com.example.android.snake; -import android.test.ActivityInstrumentationTestCase; - -import com.example.android.snake.Snake; +import android.test.ActivityInstrumentationTestCase2; /** * Make sure that the main launcher activity opens up properly, which will be - * verified by {@link ActivityTestCase#testActivityTestCaseSetUpProperly}. + * verified by {@link #testActivityTestCaseSetUpProperly}. */ -public class SnakeTest extends ActivityInstrumentationTestCase<Snake> { - - public SnakeTest() { - super("com.example.android.snake", Snake.class); - } - +public class SnakeTest extends ActivityInstrumentationTestCase2<Snake> { + + /** + * Creates an {@link ActivityInstrumentationTestCase2} for the {@link Snake} activity. + */ + public SnakeTest() { + super(Snake.class); + } + + /** + * Verifies that the activity under test can be launched. + */ + public void testActivityTestCaseSetUpProperly() { + assertNotNull("activity should be launched successfully", getActivity()); + } } |