forked from openthread/ot-commissioner
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] add basic tests for auto generated java lib
When the SWIG interface file (commissioner.i) is updated, the generated java library API may be broken. There are currently no tests to guard this. This commit adds a basic androidTest for this purpose. Note that an Android rather than junit test is added because the test case depends on an JNI library.
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...service/src/androidTest/java/io/openthread/commissioner/ActiveOperationalDatasetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.openthread.commissioner; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import java.util.stream.Collectors; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public final class ActiveOperationalDatasetTest { | ||
@Test | ||
public void channelMask_valuesAreCorrect() { | ||
ActiveOperationalDataset dataset = new ActiveOperationalDataset(); | ||
ChannelMaskEntry entry1 = new ChannelMaskEntry(); | ||
entry1.setPage((short) 0); | ||
entry1.setMasks(new ByteArray(new byte[] {0x01, 0x02, 0x03, 0x04})); | ||
ChannelMaskEntry entry2 = new ChannelMaskEntry(); | ||
entry2.setPage((short) 1); | ||
entry2.setMasks(new ByteArray(new byte[] {0x05, 0x06, 0x07, 0x08})); | ||
ChannelMask maskEntries = new ChannelMask(); | ||
maskEntries.add(entry1); | ||
maskEntries.add(entry2); | ||
dataset.setChannelMask(maskEntries); | ||
|
||
assertThat(dataset.getChannelMask()).hasSize(2); | ||
assertThat(dataset.getChannelMask().get(0).getPage()).isEqualTo(0); | ||
assertThat(dataset.getChannelMask().get(0).getMasks().stream().collect(Collectors.toList())) | ||
.containsExactly((byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04); | ||
assertThat(dataset.getChannelMask().get(1).getPage()).isEqualTo(1); | ||
assertThat(dataset.getChannelMask().get(1).getMasks().stream().collect(Collectors.toList())) | ||
.containsExactly((byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08); | ||
} | ||
} |