blob: dbba4f329eae73676132164b9bd6ff82b6304104 [file] [log] [blame]
Paul Duffin772b6922017-12-22 16:13:15 +00001/*
2 * Copyright (C) 2017 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 */
16package android.test.mock;
17
18import android.app.Application;
19import android.app.Service;
20import android.content.Context;
21
22/**
23 * A mock {@link android.app.Service} class.
24 *
25 * <p>Provided for use by {@code android.test.ServiceTestCase}.
26 *
27 * @deprecated Use a mocking framework like <a href="https://github.com/mockito/mockito">Mockito</a>.
28 * New tests should be written using the
29 * <a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>.
30 */
31@Deprecated
32public class MockService {
33
34 public static <T extends Service> void attachForTesting(Service service, Context context,
35 String serviceClassName,
36 Application application) {
37 service.attach(
38 context,
39 null, // ActivityThread not actually used in Service
40 serviceClassName,
41 null, // token not needed when not talking with the activity manager
42 application,
43 null // mocked services don't talk with the activity manager
44 );
45 }
46
47 private MockService() {
48 }
49}