Merge "To add the Android.bp of ExternalStorageProvider"
am: 6569dd8c24
Change-Id: I4cb30701103cf77a25d7d127765dc8f58ade463b
This commit is contained in:
19
packages/ExternalStorageProvider/Android.bp
Normal file
19
packages/ExternalStorageProvider/Android.bp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
android_app {
|
||||||
|
name: "ExternalStorageProvider",
|
||||||
|
|
||||||
|
manifest: "AndroidManifest.xml",
|
||||||
|
|
||||||
|
resource_dirs: [
|
||||||
|
"res",
|
||||||
|
],
|
||||||
|
|
||||||
|
srcs: [
|
||||||
|
"src/**/*.java",
|
||||||
|
],
|
||||||
|
|
||||||
|
platform_apis: true,
|
||||||
|
|
||||||
|
certificate: "platform",
|
||||||
|
|
||||||
|
privileged: true,
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := ExternalStorageProvider
|
|
||||||
LOCAL_PRIVATE_PLATFORM_APIS := true
|
|
||||||
LOCAL_CERTIFICATE := platform
|
|
||||||
LOCAL_PRIVILEGED_MODULE := true
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
||||||
25
packages/ExternalStorageProvider/tests/Android.bp
Normal file
25
packages/ExternalStorageProvider/tests/Android.bp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
android_test {
|
||||||
|
name: "ExternalStorageProviderTests",
|
||||||
|
|
||||||
|
manifest: "AndroidManifest.xml",
|
||||||
|
|
||||||
|
srcs: [
|
||||||
|
"src/**/*.java",
|
||||||
|
],
|
||||||
|
|
||||||
|
libs: [
|
||||||
|
"android.test.base",
|
||||||
|
"android.test.mock",
|
||||||
|
"android.test.runner",
|
||||||
|
],
|
||||||
|
|
||||||
|
static_libs: [
|
||||||
|
"android-support-test",
|
||||||
|
"mockito-target",
|
||||||
|
"truth-prebuilt",
|
||||||
|
],
|
||||||
|
|
||||||
|
certificate: "platform",
|
||||||
|
|
||||||
|
instrumentation_for: "ExternalStorageProvider",
|
||||||
|
}
|
||||||
13
packages/ExternalStorageProvider/tests/AndroidManifest.xml
Normal file
13
packages/ExternalStorageProvider/tests/AndroidManifest.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.android.externalstorage.tests">
|
||||||
|
|
||||||
|
<application android:label="ExternalStorageProvider Tests">
|
||||||
|
<uses-library android:name="android.test.runner" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
android:targetPackage="com.android.externalstorage"
|
||||||
|
android:label="ExternalStorageProvider Tests" />
|
||||||
|
</manifest>
|
||||||
|
|
||||||
29
packages/ExternalStorageProvider/tests/AndroidTest.xml
Normal file
29
packages/ExternalStorageProvider/tests/AndroidTest.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2018 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.
|
||||||
|
-->
|
||||||
|
<configuration description="Runs Tests for ExternalStorageProvider.">
|
||||||
|
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
|
||||||
|
<option name="test-file-name" value="ExternalStorageProviderTests.apk" />
|
||||||
|
</target_preparer>
|
||||||
|
|
||||||
|
<option name="test-suite-tag" value="apct" />
|
||||||
|
<option name="test-suite-tag" value="framework-base-presubmit" />
|
||||||
|
<option name="test-tag" value="ExternalStorageProviderTests" />
|
||||||
|
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
|
||||||
|
<option name="package" value="com.android.externalstorage.tests" />
|
||||||
|
<option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
|
||||||
|
<option name="hidden-api-checks" value="false"/>
|
||||||
|
</test>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.externalstorage;
|
||||||
|
|
||||||
|
import static com.android.externalstorage.ExternalStorageProvider.AUTHORITY;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.atLeast;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.content.pm.ProviderInfo;
|
||||||
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExternalStorageProviderTest {
|
||||||
|
@Test
|
||||||
|
public void onCreate_shouldUpdateVolumes() throws Exception {
|
||||||
|
ExternalStorageProvider externalStorageProvider = new ExternalStorageProvider();
|
||||||
|
ExternalStorageProvider spyProvider = spy(externalStorageProvider);
|
||||||
|
ProviderInfo providerInfo = new ProviderInfo();
|
||||||
|
providerInfo.authority = AUTHORITY;
|
||||||
|
providerInfo.grantUriPermissions = true;
|
||||||
|
providerInfo.exported = true;
|
||||||
|
|
||||||
|
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
spyProvider.attachInfoForTesting(
|
||||||
|
InstrumentationRegistry.getTargetContext(), providerInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
verify(spyProvider, atLeast(1)).updateVolumes();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user