From b999b0cb0f6cb1e63d4f77dcf87fa05a33960cf2 Mon Sep 17 00:00:00 2001 From: Daichi Hirono Date: Tue, 27 Oct 2015 16:29:18 +0900 Subject: [PATCH] Move TestResources class to the outside of MtpDocumentProviderTest. TestResources class will be used in MtpDatabaseTest. BUG=25162822 Change-Id: I4f51b517532bbc111e95e7ebd96787a2e6f0f87a --- .../android/mtp/MtpDocumentsProviderTest.java | 15 +--------- .../src/com/android/mtp/TestResources.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java index 0c03814cc4e8e..5765f0a905019 100644 --- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java +++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java @@ -16,9 +16,6 @@ package com.android.mtp; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.Resources.NotFoundException; import android.database.Cursor; import android.mtp.MtpConstants; import android.mtp.MtpObjectInfo; @@ -26,7 +23,6 @@ import android.net.Uri; import android.provider.DocumentsContract.Root; import android.provider.DocumentsContract; import android.test.AndroidTestCase; -import android.test.mock.MockResources; import android.test.suitebuilder.annotation.SmallTest; import java.io.FileNotFoundException; @@ -39,16 +35,7 @@ public class MtpDocumentsProviderTest extends AndroidTestCase { private TestContentResolver mResolver; private MtpDocumentsProvider mProvider; private TestMtpManager mMtpManager; - private final MockResources mResources = new MockResources() { - @Override - public String getString(int id) throws NotFoundException { - switch (id) { - case R.string.root_name: - return "%1$s %2$s"; - } - throw new NotFoundException(); - } - }; + private final TestResources mResources = new TestResources(); @Override public void setUp() throws IOException { diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java new file mode 100644 index 0000000000000..eb80e3b60e6a5 --- /dev/null +++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/TestResources.java @@ -0,0 +1,30 @@ +/* + * 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 com.android.mtp; + +import android.test.mock.MockResources; + +class TestResources extends MockResources { + @Override + public String getString(int id) throws NotFoundException { + switch (id) { + case R.string.root_name: + return "%1$s %2$s"; + } + throw new NotFoundException(); + } +}