Introduce TestItem.java

This commit is contained in:
Matthieu Gautier 2023-06-13 17:46:21 +02:00
parent ff6469a34f
commit 80f6920201
4 changed files with 43 additions and 7 deletions

View File

@ -20,7 +20,6 @@
package org.kiwix.test.libzim;
import org.kiwix.libzim.ZimFileFormatException;
import org.kiwix.libzim.Item;
import org.kiwix.libzim.EntryIterator;
import org.kiwix.libzim.Archive;
import java.io.FileDescriptor;
@ -54,10 +53,10 @@ public class TestArchive
public int getMediaCount() { return inner.getMediaCount(); }
public String getUuid() { return inner.getUuid(); }
public String getMetadata(String name) { return inner.getMetadata(name); }
public Item getMetadataItem(String name) { return inner.getMetadataItem(name); }
public TestItem getMetadataItem(String name) { return new TestItem(inner.getMetadataItem(name)); }
public String[] getMetadataKeys() { return inner.getMetadataKeys(); }
public Item getIllustrationItem(int size) { return inner.getIllustrationItem(size); }
public TestItem getIllustrationItem(int size) { return new TestItem(inner.getIllustrationItem(size)); }
public boolean hasIllustration(int size) { return inner.hasIllustration(size); }
public long[] getIllustrationSizes() { return inner.getIllustrationSizes(); }

View File

@ -20,7 +20,6 @@
package org.kiwix.test.libzim;
import org.kiwix.libzim.Entry;
import org.kiwix.libzim.Item;
public class TestEntry
{
@ -30,7 +29,7 @@ public class TestEntry
public String getTitle() { return inner.getTitle(); }
public String getPath() { return inner.getPath(); }
public Item getItem(boolean follow) { return inner.getItem(follow); }
public Item getRedirect() { return inner.getRedirect(); }
public TestItem getItem(boolean follow) { return new TestItem(inner.getItem(follow)); }
public TestItem getRedirect() { return new TestItem(inner.getRedirect()); }
public TestEntry getRedirectEntry() { return new TestEntry(inner.getRedirectEntry()); }
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2022 Matthieu Gautier <mgautier@kymeria.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.kiwix.test.libzim;
import org.kiwix.libzim.Item;
import org.kiwix.libzim.Blob;
import org.kiwix.libzim.DirectAccessInfo;
public class TestItem
{
private Item inner;
public TestItem(Item _inner) { inner = _inner; }
public String getTitle() { return inner.getTitle(); }
public String getPath() { return inner.getPath(); }
public String getMimetype() { return inner.getMimetype(); }
public Blob getData() { return inner.getData(); }
public long getSize() { return inner.getSize(); }
public DirectAccessInfo getDirectAccessInformation() { return inner.getDirectAccessInformation(); }
}

View File

@ -61,7 +61,7 @@ public class test {
// test zim file icon
assertEquals(true, archive.hasIllustration(48));
byte[] faviconData = getFileContent("small_zimfile_data/favicon.png");
Item item = archive.getIllustrationItem(48);
TestItem item = archive.getIllustrationItem(48);
assertEquals(faviconData.length, item.getSize());
assert(Arrays.equals(faviconData, item.getData().getData()));