/**@class android.test.ServiceTestCase @extends android.test.AndroidTestCase This test case provides a framework in which you can test Service classes in a controlled environment. It provides basic support for the lifecycle of a Service, and hooks with which you can inject various dependencies and control the environment in which your Service is tested. <div class="special reference"> <h3>Developer Guides</h3> <p>For more information about application testing, read the <a href="{@docRoot}guide/topics/testing/index.html">Testing</a> developer guide.</p> </div> <p><b>Lifecycle Support.</b> A Service is accessed with a specific sequence of calls, as described in the <a href="http://developer.android.com/guide/topics/fundamentals/services.html">Services</a> document. In order to support the lifecycle of a Service, <code>ServiceTestCase</code> enforces this protocol: <ul> <li> The {@link #setUp}() method is called before each test method. The base implementation gets the system context. If you override <code>setUp()</code>, you must call <code>super.setUp()</code> as the first statement in your override. </li> <li> The test case waits to call {@link android.app.Service#onCreate()} until one of your test methods calls {@link #startService} or {@link #bindService}. This gives you an opportunity to set up or adjust any additional framework or test logic before you test the running service. </li> <li> When one of your test methods calls {@link #startService android.test.ServiceTestCase.startService()} or {@link #bindService android.test.ServiceTestCase.bindService()}, the test case calls {@link android.app.Service#onCreate() Service.onCreate()} and then calls either {@link android.app.Service#startService(Intent) Service.startService(Intent)} or {@link android.app.Service#bindService(Intent, ServiceConnection, int) Service.bindService(Intent, ServiceConnection, int)}, as appropriate. It also stores values needed to track and support the lifecycle. </li> <li> After each test method finishes, the test case calls the {@link #tearDown} method. This method stops and destroys the service with the appropriate calls, depending on how the service was started. If you override <code>tearDown()</code>, your must call the <code>super.tearDown()</code> as the last statement in your override. </li> </ul> <p> <strong>Dependency Injection.</strong> A service has two inherent dependencies, its {@link android.content.Context Context} and its associated {@link android.app.Application Application}. The ServiceTestCase framework allows you to inject modified, mock, or isolated replacements for these dependencies, and thus perform unit tests with controlled dependencies in an isolated environment. </p> <p> By default, the test case is injected with a full system context and a generic {@link android.test.mock.MockApplication MockApplication} object. You can inject alternatives to either of these by invoking {@link android.test.AndroidTestCase#setContext(Context) setContext()} or {@link #setApplication setApplication()}. You must do this <em>before</em> calling startService() or bindService(). The test framework provides a number of alternatives for Context, including {@link android.test.mock.MockContext MockContext}, {@link android.test.RenamingDelegatingContext RenamingDelegatingContext}, {@link android.content.ContextWrapper ContextWrapper}, and {@link android.test.IsolatedContext}. @deprecated Use <a href="{@docRoot}reference/android/support/test/rule/ServiceTestRule.html"> ServiceTestRule</a> instead. New tests should be written using the <a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>. */ var ServiceTestCase = { /** @return {Object {android.app.Service}} An instance of the service under test. This instance is created automatically when a test calls {@link #startService} or {@link #bindService}. */ getService : function( ) {}, /**Sets the application that is used during the test. If you do not call this method, a new {@link android.test.mock.MockApplication MockApplication} object is used. @param {Object {Application}} application The Application object that is used by the service under test. @see #getApplication() */ setApplication : function( ) {}, /**Returns the Application object in use by the service under test. @return {Object {android.app.Application}} The application object. @see #setApplication */ getApplication : function( ) {}, /**Returns the real system context that is saved by {@link #setUp}(). Use it to create mock or other types of context objects for the service under test. @return {Object {android.content.Context}} A normal system context. */ getSystemContext : function( ) {}, /**Tests that {@link #setupService}() runs correctly and issues an {@link junit.framework.Assert#assertNotNull(String, Object)} if it does. You can override this test method if you wish. @throws Exception */ testServiceTestCaseSetUpProperly : function( ) {}, };