1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package com.cyngn.audiofx;
import android.os.Parcel;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
/**
* Created by roman on 9/29/15.
*/
public class PresetTests extends AndroidTestCase {
private Preset.PermCustomPreset permPreset;
private Preset.PermCustomPreset permPresetCopy;
private Preset.CustomPreset customPreset;
@Override
protected void setUp() throws Exception {
super.setUp();
permPreset = new Preset.PermCustomPreset("test perm preset", new float[]{10, 50, 20, 30, 10000});
permPresetCopy = new Preset.PermCustomPreset("test perm preset", new float[]{10, 50, 20, 30, 10000});
customPreset = new Preset.CustomPreset("test custom preset", new float[]{10, 50, 20, 30, 10000}, false);
}
@SmallTest
public void testPresetsEqual() {
assertNotSame(permPreset, customPreset);
assertEquals(permPreset, permPresetCopy);
}
@SmallTest
public void testPresetsFromString() {
final String permPresetTest = permPreset.toString();
final Preset.PermCustomPreset fromString = Preset.PermCustomPreset.fromString(permPresetTest);
assertEquals(permPreset, fromString);
}
@SmallTest
public void testPermPresetParcelable() {
Parcel parcel = Parcel.obtain();
// write the parcel
permPreset.writeToParcel(parcel, 0);
// reset position for reading
parcel.setDataPosition(0);
// reconstruct object
final Preset.PermCustomPreset fromParcel = Preset.PermCustomPreset.CREATOR.createFromParcel(parcel);
assertNotNull(fromParcel);
assertEquals(permPreset.getName(), fromParcel.getName());
assertPresetLevels(permPreset, fromParcel);
assertEquals(permPreset, fromParcel);
}
@SmallTest
public void testCustomPresetParcelable() {
Parcel parcel = Parcel.obtain();
// write the parcel
customPreset.writeToParcel(parcel, 0);
// reset position for reading
parcel.setDataPosition(0);
// reconstruct object
final Preset.CustomPreset fromParcel = Preset.CustomPreset.CREATOR.createFromParcel(parcel);
assertNotNull(fromParcel);
assertEquals(customPreset.getName(), fromParcel.getName());
assertPresetLevels(customPreset, fromParcel);
assertEquals(customPreset.isLocked(), fromParcel.isLocked());
assertEquals(customPreset, fromParcel);
}
private void assertPresetLevels(Preset p1, Preset p2) {
for(int i = 0; i < p1.getLevels().length; i++) {
assertEquals(p1.getLevels()[i], p2.getLevels()[i]);
}
}
}
|