diff options
author | Peter Li <pyli@google.com> | 2021-11-11 22:16:12 -0800 |
---|---|---|
committer | Peter Li <pyli@google.com> | 2021-11-17 22:09:49 +0000 |
commit | aab2bdbb820776745f178eced9f9cd61780254b7 (patch) | |
tree | eec36c9282186f4987f317e2599973bf09c84358 | |
parent | c7df51807e792be10bd477a4930b4dec633dcad6 (diff) | |
download | Messenger-aab2bdbb820776745f178eced9f9cd61780254b7.tar.gz |
Set up Android.bp and gradle for testsandroid-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r11android-12.1.0_r10android12L-devandroid12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-release
Fix: 205772173
Test: gradle build, atest CarMessengerUnitTests
Change-Id: I65b3cfd5b9c19b744fe71d8bd6e40d33bc9045d5
-rw-r--r-- | Android.bp | 69 | ||||
-rw-r--r-- | AndroidManifest.xml | 7 | ||||
-rw-r--r-- | build.gradle | 30 | ||||
-rw-r--r-- | tests/Android.bp | 43 | ||||
-rw-r--r-- | tests/AndroidManifest.xml | 30 | ||||
-rw-r--r-- | tests/src/com/android/car/messenger/BuildTest.java | 33 |
6 files changed, 208 insertions, 4 deletions
@@ -25,10 +25,69 @@ android_app { resource_dirs: ["res"], + min_sdk_version: "30", + + target_sdk_version: "31", + + sdk_version: "system_current", + + required: ["allowed_privapp_com.android.car.messenger"], + + certificate: "platform", + + overrides: ["messaging"], + + optimize: { + enabled: false, + }, + + privileged: true, + + libs: ["android.car-system-stubs"], + + // must be unbundled dependencies + static_libs: [ + "androidx-constraintlayout_constraintlayout", + "androidx.lifecycle_lifecycle-common-java8", + "androidx.lifecycle_lifecycle-extensions", + "androidx.legacy_legacy-support-v4", + "androidx.preference_preference", + "androidx.recyclerview_recyclerview", + "car-assist-lib", + "car-messenger-common", + "car-telephony-common", + "car-ui-lib", + "androidx.annotation_annotation", + ], + + dex_preopt: { + enabled: false, + }, + + product_variables: { + pdk: { + enabled: false, + }, + }, +} + +android_test_helper_app { + name: "CarMessengerAppForTesting", + + srcs: ["src/**/*.java"], + + resource_dirs: ["res"], + + min_sdk_version: "30", + + target_sdk_version: "31", + sdk_version: "system_current", required: ["allowed_privapp_com.android.car.messenger"], + certificate: "platform", + overrides: ["messaging"], optimize: { @@ -63,4 +122,14 @@ android_app { enabled: false, }, }, + + // runtime cc library which is used by mockito-target-extended. + jni_libs: [ + // For mockito extended + "libdexmakerjvmtiagent", + "libstaticjvmtiagent", + ], + + // Enforce the jni libraries to be grouped into the APK file. + use_embedded_native_libs: true, } diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d48bd17..11014dd 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -16,7 +16,9 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.car.messenger"> + package="com.android.car.messenger" + android:versionCode="10000" + android:versionName="1.0.0"> <application android:name="com.android.car.messenger.impl.CarMessengerApp" @@ -131,7 +133,4 @@ --> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> - <uses-sdk - android:minSdkVersion="30" - android:targetSdkVersion="30" /> </manifest> diff --git a/build.gradle b/build.gradle index b0e8bc2..88e8ced 100644 --- a/build.gradle +++ b/build.gradle @@ -44,6 +44,29 @@ android { renderscript.srcDirs = ['src'] res.srcDirs = ['res'] } + + androidTest { + java.srcDirs = ['tests/src'] + setRoot('tests') + } + } + + testOptions { + animationsDisabled = true + } + + buildTypes { + debug { + testCoverageEnabled = true + } + } + + signingConfigs { + debug { + // The following signs the apk with platform key. + storeFile file('../../../../vendor/google/certs/devkeys/platform.keystore') + storePassword 'android' + } } } @@ -65,4 +88,11 @@ dependencies { implementation project(":car-messenger-common:model") implementation project(":car-telephony-common") implementation project(":car-ui-lib") + + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test:core:1.4.0' + androidTestImplementation 'androidx.test:rules:1.4.0' + androidTestImplementation 'androidx.test:runner:1.4.0' + androidTestImplementation 'com.google.truth:truth:1.1.3' + androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.1' } diff --git a/tests/Android.bp b/tests/Android.bp new file mode 100644 index 0000000..8dac782 --- /dev/null +++ b/tests/Android.bp @@ -0,0 +1,43 @@ +// +// Copyright (C) 2021 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +android_test { + name: "CarMessengerUnitTests", + + min_sdk_version: "30", + + target_sdk_version: "31", + + srcs: ["src/**/*.java"], + + libs: ["android.car-system-stubs"], + + static_libs: [ + "androidx.test.core", + "androidx.test.rules", + "androidx.test.runner", + "androidx.test.ext.junit", + "androidx.test.ext.truth", + "mockito-target-extended-minus-junit4", + "truth-prebuilt", + ], + + instrumentation_for: "CarMessengerAppForTesting", +} diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml new file mode 100644 index 0000000..e59c7c4 --- /dev/null +++ b/tests/AndroidManifest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2021 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. + --> + +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.car.messenger.unittests"> + + <application android:testOnly="false" + android:debuggable="true"> + <uses-library android:name="android.test.runner" /> + </application> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.car.messenger" + android:label="Car Messenger Unit Tests" /> +</manifest> diff --git a/tests/src/com/android/car/messenger/BuildTest.java b/tests/src/com/android/car/messenger/BuildTest.java new file mode 100644 index 0000000..3d35ddb --- /dev/null +++ b/tests/src/com/android/car/messenger/BuildTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2021 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.car.messenger; + +import static com.google.common.truth.Truth.assertThat; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class BuildTest { + + @Test + public void test() { + assertThat(true).isEqualTo(true); + } +} |