Skip to content

Commit

Permalink
Fix warning in ListIndexModel and add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Sep 15, 2023
1 parent 08c1df3 commit 7a27525
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ public void setSize(int size) {
* Returns the gtype of {@link ListIndex}
* @return always returns the value of {@link ListIndex#gtype}
*/
@Property(name="item-type", writable=false)
@Property(name="item-type", constructOnly = true)
@Override
public Type getItemType() {
return ListIndex.gtype;
}

@Property(name="item-type")
public void setItemType(Type itemType) {
}

/**
* Returns the size of the list model
* @return the value of the size field
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.github.jwharm.javagi.test.gio;

import io.github.jwharm.javagi.gio.ListIndexModel;
import org.gnome.gio.Gio;
import org.gnome.gio.ListModel;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* Test some operations on ListIndexModel
*/
public class ListModelTest {

@Test
public void createListModel() {
// explicitly trigger initialization
Gio.javagi$ensureInitialized();

ListModel listIndexModel = ListIndexModel.newInstance(1000);
assertEquals(listIndexModel.getItemType(), ListIndexModel.ListIndex.getType());
assertEquals(1000, listIndexModel.getNItems());

var item500 = (ListIndexModel.ListIndex) listIndexModel.getItem(500);
assertNotNull(item500);
assertEquals(500, item500.getIndex());
}
}

0 comments on commit 7a27525

Please sign in to comment.