Merge "Adds Ability to Test with SoundTrigger Stub HAL" into nyc-dev
This commit is contained in:
@@ -18,7 +18,14 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_MODULE_TAGS := tests
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
ifeq ($(SOUND_TRIGGER_USE_STUB_MODULE), 1)
|
||||||
|
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||||
|
LOCAL_PRIVILEGED_MODULE := true
|
||||||
|
LOCAL_CERTIFICATE := platform
|
||||||
|
TARGET_OUT_DATA_APPS_PRIVILEGED := $(TARGET_OUT_DATA)/priv-app
|
||||||
|
else
|
||||||
|
LOCAL_SRC_FILES := src/android/hardware/soundtrigger/SoundTriggerTest.java
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
LOCAL_JAVA_LIBRARIES := android.test.runner
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.hardware.soundtrigger">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="android.hardware.soundtrigger">
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_SOUND_TRIGGER" />
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<uses-library android:name="android.test.runner" />
|
<uses-library android:name="android.test.runner" />
|
||||||
</application>
|
</application>
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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 android.hardware.soundtrigger;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
|
||||||
|
import android.media.soundtrigger.SoundTriggerManager;
|
||||||
|
import android.os.ParcelUuid;
|
||||||
|
import android.os.ServiceManager;
|
||||||
|
import android.test.AndroidTestCase;
|
||||||
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
|
import com.android.internal.app.ISoundTriggerService;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class GenericSoundModelTest extends AndroidTestCase {
|
||||||
|
private Random mRandom = new Random();
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testUpdateGenericSoundModel() throws Exception {
|
||||||
|
Context context = getContext();
|
||||||
|
ISoundTriggerService mSoundTriggerService = ISoundTriggerService.Stub.asInterface(
|
||||||
|
ServiceManager.getService(Context.SOUND_TRIGGER_SERVICE));
|
||||||
|
SoundTriggerManager mSoundTriggerManager = (SoundTriggerManager) context.getSystemService(
|
||||||
|
Context.SOUND_TRIGGER_SERVICE);
|
||||||
|
|
||||||
|
byte[] data = new byte[1024];
|
||||||
|
mRandom.nextBytes(data);
|
||||||
|
UUID modelUuid = UUID.randomUUID();
|
||||||
|
UUID mVendorUuid = UUID.randomUUID();
|
||||||
|
GenericSoundModel model = new GenericSoundModel(modelUuid, mVendorUuid, data);
|
||||||
|
|
||||||
|
mSoundTriggerService.updateSoundModel(model);
|
||||||
|
GenericSoundModel returnedModel =
|
||||||
|
mSoundTriggerService.getSoundModel(new ParcelUuid(modelUuid));
|
||||||
|
|
||||||
|
assertEquals(model, returnedModel);
|
||||||
|
|
||||||
|
// Cleanup sound model
|
||||||
|
mSoundTriggerService.deleteSoundModel(new ParcelUuid(modelUuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testDeleteGenericSoundModel() throws Exception {
|
||||||
|
Context context = getContext();
|
||||||
|
ISoundTriggerService mSoundTriggerService = ISoundTriggerService.Stub.asInterface(
|
||||||
|
ServiceManager.getService(Context.SOUND_TRIGGER_SERVICE));
|
||||||
|
SoundTriggerManager mSoundTriggerManager = (SoundTriggerManager) context.getSystemService(
|
||||||
|
Context.SOUND_TRIGGER_SERVICE);
|
||||||
|
|
||||||
|
byte[] data = new byte[1024];
|
||||||
|
mRandom.nextBytes(data);
|
||||||
|
UUID modelUuid = UUID.randomUUID();
|
||||||
|
UUID mVendorUuid = UUID.randomUUID();
|
||||||
|
GenericSoundModel model = new GenericSoundModel(modelUuid, mVendorUuid, data);
|
||||||
|
|
||||||
|
mSoundTriggerService.updateSoundModel(model);
|
||||||
|
mSoundTriggerService.deleteSoundModel(new ParcelUuid(modelUuid));
|
||||||
|
|
||||||
|
GenericSoundModel returnedModel =
|
||||||
|
mSoundTriggerService.getSoundModel(new ParcelUuid(modelUuid));
|
||||||
|
assertEquals(null, returnedModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user