use of android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel in project android_frameworks_base by ResurrectionRemix.
the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_noKeyphrases.
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_noKeyphrases() throws Exception {
byte[] data = new byte[10];
mRandom.nextBytes(data);
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), data, null);
// Write to a parcel
Parcel parcel = Parcel.obtain();
ksm.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(ksm.uuid, unparceled.uuid);
assertEquals(ksm.type, unparceled.type);
assertNull(unparceled.keyphrases);
assertTrue(Arrays.equals(ksm.data, unparceled.data));
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel in project android_frameworks_base by ResurrectionRemix.
the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_zeroKeyphrases.
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_zeroKeyphrases() throws Exception {
byte[] data = new byte[10];
mRandom.nextBytes(data);
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), data, new Keyphrase[0]);
// Write to a parcel
Parcel parcel = Parcel.obtain();
ksm.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(ksm.uuid, unparceled.uuid);
assertEquals(ksm.type, unparceled.type);
assertTrue(Arrays.equals(ksm.keyphrases, unparceled.keyphrases));
assertTrue(Arrays.equals(ksm.data, unparceled.data));
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel in project android_frameworks_base by crdroidandroid.
the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_noKeyphrases.
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_noKeyphrases() throws Exception {
byte[] data = new byte[10];
mRandom.nextBytes(data);
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), data, null);
// Write to a parcel
Parcel parcel = Parcel.obtain();
ksm.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(ksm.uuid, unparceled.uuid);
assertEquals(ksm.type, unparceled.type);
assertNull(unparceled.keyphrases);
assertTrue(Arrays.equals(ksm.data, unparceled.data));
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel in project android_frameworks_base by crdroidandroid.
the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_largeData.
@LargeTest
public void testKeyphraseSoundModelParcelUnparcel_largeData() throws Exception {
Keyphrase[] keyphrases = new Keyphrase[2];
keyphrases[0] = new Keyphrase(1, 0, "en-US", "hello", new int[] { 0 });
keyphrases[1] = new Keyphrase(2, 0, "fr-FR", "there", new int[] { 1, 2 });
byte[] data = new byte[200 * 1024];
mRandom.nextBytes(data);
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), data, keyphrases);
// Write to a parcel
Parcel parcel = Parcel.obtain();
ksm.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(ksm.uuid, unparceled.uuid);
assertEquals(ksm.type, unparceled.type);
assertTrue(Arrays.equals(ksm.data, unparceled.data));
assertTrue(Arrays.equals(ksm.keyphrases, unparceled.keyphrases));
}
use of android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel in project android_frameworks_base by crdroidandroid.
the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_noData.
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_noData() throws Exception {
Keyphrase[] keyphrases = new Keyphrase[2];
keyphrases[0] = new Keyphrase(1, 0, "en-US", "hello", new int[] { 0 });
keyphrases[1] = new Keyphrase(2, 0, "fr-FR", "there", new int[] { 1, 2 });
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), null, keyphrases);
// Write to a parcel
Parcel parcel = Parcel.obtain();
ksm.writeToParcel(parcel, 0);
// Read from it
parcel.setDataPosition(0);
KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
// Verify that they are the same
assertEquals(ksm.uuid, unparceled.uuid);
assertNull(unparceled.data);
assertEquals(ksm.type, unparceled.type);
assertTrue(Arrays.equals(keyphrases, unparceled.keyphrases));
}
Aggregations