Extract vibrator service tests from FrameworksServicesTests
Move all tests for package com.android.server.vibrator from frameworks/base/services/tests/servicestests to a new folder frameworks/base/services/tests/vibratorservicestests. Create a new private java library for test utility classes in a new folder vibratorservicestests/utils, with fake implementations used in service tests. Create a new android_test module VibratorServiceTests for the moved tests, configured for pre/postsubmit test mappings. Fix: 290745798 Test: atest VibratorServiceTests Change-Id: I07cb81f484584cada371a00f2d3e798350ddf8f2
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
# Bug component: 345036
|
||||
|
||||
lsandrade@google.com
|
||||
michaelwr@google.com
|
||||
sbowden@google.com
|
||||
sbowden@google.com
|
||||
khalilahmad@google.com
|
||||
62
services/tests/vibrator/Android.bp
Normal file
62
services/tests/vibrator/Android.bp
Normal file
@@ -0,0 +1,62 @@
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "frameworks_base_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["frameworks_base_license"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "FrameworksVibratorServicesTests",
|
||||
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
],
|
||||
|
||||
libs: [
|
||||
"android.hardware.vibrator-V2-java",
|
||||
"android.test.mock",
|
||||
"android.test.base",
|
||||
"android.test.runner",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"androidx.test.core",
|
||||
"androidx.test.ext.truth",
|
||||
"androidx.test.runner",
|
||||
"androidx.test.rules",
|
||||
"androidx.test.ext.junit",
|
||||
"frameworks-base-testutils",
|
||||
"frameworks-services-vibrator-testutils",
|
||||
"junit",
|
||||
"mockito-target-minus-junit4",
|
||||
"platform-test-annotations",
|
||||
"service-permission.stubs.system_server",
|
||||
"services.core",
|
||||
],
|
||||
|
||||
platform_apis: true,
|
||||
certificate: "platform",
|
||||
dxflags: ["--multi-dex"],
|
||||
|
||||
test_suites: [
|
||||
"device-tests",
|
||||
"automotive-tests",
|
||||
],
|
||||
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "frameworks-services-vibrator-testutils",
|
||||
visibility: [":__subpackages__"],
|
||||
srcs: [
|
||||
"utils/**/*.java",
|
||||
],
|
||||
static_libs: [
|
||||
"services.core",
|
||||
],
|
||||
}
|
||||
45
services/tests/vibrator/AndroidManifest.xml
Normal file
45
services/tests/vibrator/AndroidManifest.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2023 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.framework.services.tests.vibrator">
|
||||
|
||||
<!-- Required to set user settings -->
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
<!-- Required to register uid observer -->
|
||||
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
|
||||
<!-- Required to acquire wake locks during vibrations -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
|
||||
<!-- Required to request vibrations -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- Required to listen to the vibrator state -->
|
||||
<uses-permission android:name="android.permission.ACCESS_VIBRATOR_STATE" />
|
||||
<!-- Required to set always-on vibrations -->
|
||||
<uses-permission android:name="android.permission.VIBRATE_ALWAYS_ON" />
|
||||
|
||||
<application android:debuggable="true"
|
||||
android:testOnly="true">
|
||||
<uses-library android:name="android.test.mock" android:required="true" />
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
<instrumentation
|
||||
android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:label="Vibrator Service Tests"
|
||||
android:targetPackage="com.android.framework.services.tests.vibrator" />
|
||||
|
||||
</manifest>
|
||||
34
services/tests/vibrator/AndroidTest.xml
Normal file
34
services/tests/vibrator/AndroidTest.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2023 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 Frameworks Vibrator Services Tests.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-instrumentation" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
||||
<option name="cleanup-apks" value="true" />
|
||||
<option name="install-arg" value="-t" />
|
||||
<option name="test-file-name" value="FrameworksVibratorServicesTests.apk" />
|
||||
</target_preparer>
|
||||
|
||||
<option name="test-tag" value="FrameworksVibratorServicesTests" />
|
||||
|
||||
<test class="com.android.tradefed.testtype.AndroidJUnitTest">
|
||||
<option name="package" value="com.android.framework.services.tests.vibrator" />
|
||||
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
|
||||
<option name="hidden-api-checks" value="false" />
|
||||
</test>
|
||||
</configuration>
|
||||
@@ -1 +1,3 @@
|
||||
# Bug component: 345036
|
||||
|
||||
include /services/core/java/com/android/server/vibrator/OWNERS
|
||||
21
services/tests/vibrator/TEST_MAPPING
Normal file
21
services/tests/vibrator/TEST_MAPPING
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"presubmit": [
|
||||
{
|
||||
"name": "FrameworksVibratorServicesTests",
|
||||
"options": [
|
||||
{"exclude-annotation": "android.platform.test.annotations.LargeTest"},
|
||||
{"exclude-annotation": "android.platform.test.annotations.FlakyTest"},
|
||||
{"exclude-annotation": "androidx.test.filters.FlakyTest"},
|
||||
{"exclude-annotation": "org.junit.Ignore"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"postsubmit": [
|
||||
{
|
||||
"name": "FrameworksVibratorServicesTests",
|
||||
"options": [
|
||||
{"exclude-annotation": "org.junit.Ignore"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.RampSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
@@ -48,13 +47,6 @@ import org.mockito.junit.MockitoRule;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Tests for {@link DeviceAdapter}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:DeviceAdapterTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class DeviceAdapterTest {
|
||||
private static final int EMPTY_VIBRATOR_ID = 1;
|
||||
private static final int PWLE_VIBRATOR_ID = 2;
|
||||
@@ -41,7 +41,6 @@ import android.os.Process;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.test.TestLooper;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.view.InputDevice;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
@@ -54,13 +53,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
/**
|
||||
* Tests for {@link InputDeviceDelegate}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:InputDeviceDelegateTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class InputDeviceDelegateTest {
|
||||
|
||||
private static final int UID = Process.ROOT_UID;
|
||||
@@ -25,7 +25,6 @@ import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.RampSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -34,13 +33,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tests for {@link RampDownAdapter}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:RampDownAdapterTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class RampDownAdapterTest {
|
||||
private static final int TEST_RAMP_DOWN_DURATION = 20;
|
||||
private static final int TEST_STEP_DURATION = 5;
|
||||
@@ -26,7 +26,6 @@ import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.RampSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -36,13 +35,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* Tests for {@link RampToStepAdapter}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:RampToStepAdapterTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class RampToStepAdapterTest {
|
||||
private static final int TEST_STEP_DURATION = 5;
|
||||
private static final float[] TEST_AMPLITUDE_MAP = new float[]{
|
||||
@@ -26,7 +26,6 @@ import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.RampSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -36,13 +35,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* Tests for {@link StepToRampAdapter}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:StepToRampAdapterTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class StepToRampAdapterTest {
|
||||
private static final float[] TEST_AMPLITUDE_MAP = new float[]{
|
||||
/* 50Hz= */ 0.1f, 0.2f, 0.4f, 0.8f, /* 150Hz= */ 1f, 0.9f, /* 200Hz= */ 0.8f};
|
||||
@@ -48,7 +48,6 @@ import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationConfig;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
@@ -65,13 +64,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibrationScaler}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibrationScalerTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibrationScalerTest {
|
||||
|
||||
@Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
@@ -70,7 +70,6 @@ import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.os.test.TestLooper;
|
||||
import android.os.vibrator.VibrationConfig;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.Settings;
|
||||
import android.util.ArraySet;
|
||||
import android.view.Display;
|
||||
@@ -94,13 +93,6 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibrationSettings}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibrationSettingsTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibrationSettingsTest {
|
||||
|
||||
private static final int UID = 1;
|
||||
@@ -20,19 +20,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Tests for {@link Vibration}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibrationTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibrationTest {
|
||||
|
||||
@Test
|
||||
@@ -61,7 +61,6 @@ import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationConfig;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.LargeTest;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
@@ -70,6 +69,7 @@ import com.android.server.LocalServices;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InOrder;
|
||||
@@ -85,13 +85,6 @@ import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibrationThread}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibrationThreadTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibrationThreadTest {
|
||||
|
||||
private static final int TEST_TIMEOUT_MILLIS = 900;
|
||||
@@ -468,6 +461,7 @@ public class VibrationThreadTest {
|
||||
fakeVibrator.getEffectSegments(vibrationId));
|
||||
}
|
||||
|
||||
@Ignore("b/290940400")
|
||||
@LargeTest
|
||||
@Test
|
||||
public void vibrate_singleVibratorRepeatingAlwaysOnWaveform_turnsVibratorBackOn()
|
||||
@@ -45,7 +45,6 @@ import android.os.test.TestLooper;
|
||||
import android.os.vibrator.PrebakedSegment;
|
||||
import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.RampSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
|
||||
@@ -61,13 +60,6 @@ import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibratorController}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibratorControllerTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibratorControllerTest {
|
||||
private static final int VIBRATOR_ID = 0;
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.test.TestLooper;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -29,13 +28,6 @@ import org.junit.Test;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibratorFrameworkStatsLogger}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibratorFrameworkStatsLoggerTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibratorFrameworkStatsLoggerTest {
|
||||
|
||||
@Rule public MockitoRule rule = MockitoJUnit.rule();
|
||||
@@ -70,13 +70,13 @@ import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.os.VibratorInfo;
|
||||
import android.os.test.FakeVibrator;
|
||||
import android.os.test.TestLooper;
|
||||
import android.os.vibrator.PrebakedSegment;
|
||||
import android.os.vibrator.PrimitiveSegment;
|
||||
import android.os.vibrator.StepSegment;
|
||||
import android.os.vibrator.VibrationConfig;
|
||||
import android.os.vibrator.VibrationEffectSegment;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.Settings;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseBooleanArray;
|
||||
@@ -111,13 +111,6 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Tests for {@link VibratorManagerService}.
|
||||
*
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:VibratorManagerServiceTest
|
||||
*/
|
||||
@Presubmit
|
||||
public class VibratorManagerServiceTest {
|
||||
|
||||
private static final int TEST_TIMEOUT_MILLIS = 1_000;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.vibrator;
|
||||
package android.os.test;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
@@ -23,9 +23,9 @@ import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
|
||||
/** Fake implementation of {@link Vibrator} for service tests. */
|
||||
final class FakeVibrator extends Vibrator {
|
||||
public final class FakeVibrator extends Vibrator {
|
||||
|
||||
FakeVibrator(Context context) {
|
||||
public FakeVibrator(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Provides {@link VibratorController} with controlled vibrator hardware capabilities and
|
||||
* interactions.
|
||||
* Provides {@link VibratorController} with configurable vibrator hardware capabilities and
|
||||
* fake interactions for tests.
|
||||
*/
|
||||
final class FakeVibratorControllerProvider {
|
||||
public final class FakeVibratorControllerProvider {
|
||||
private static final int EFFECT_DURATION = 20;
|
||||
|
||||
private final Map<Long, PrebakedSegment> mEnabledAlwaysOnEffects = new HashMap<>();
|
||||
Reference in New Issue
Block a user