This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Long for file length instead of Int Remove Metadata.layout (now in Presentation.layout)
- Loading branch information
1 parent
7a21ab9
commit 362fa97
Showing
7 changed files
with
99 additions
and
47 deletions.
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
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
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
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
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
35 changes: 0 additions & 35 deletions
35
r2-shared/src/test/java/org/readium/r2/shared/publication/epub/MetadataTest.kt
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
r2-shared/src/test/java/org/readium/r2/shared/publication/epub/PresentationTest.kt
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,68 @@ | ||
/* | ||
* Module: r2-shared-kotlin | ||
* Developers: Mickaël Menu | ||
* | ||
* Copyright (c) 2020. Readium Foundation. All rights reserved. | ||
* Use of this source code is governed by a BSD-style license which is detailed in the | ||
* LICENSE file present in the project repository where this source code is maintained. | ||
*/ | ||
|
||
package org.readium.r2.shared.publication.epub | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.readium.r2.shared.publication.Link | ||
import org.readium.r2.shared.publication.Properties | ||
import org.readium.r2.shared.publication.presentation.Presentation | ||
|
||
class PresentationTest { | ||
|
||
@Test | ||
fun `Get the layout of a reflowable resource`() { | ||
assertEquals( | ||
EpubLayout.REFLOWABLE, | ||
Presentation(layout = null).layoutOf(createLink(EpubLayout.REFLOWABLE)) | ||
) | ||
} | ||
|
||
@Test | ||
fun `Get the layout of a fixed resource`() { | ||
assertEquals( | ||
EpubLayout.FIXED, | ||
Presentation(layout = null).layoutOf(createLink(EpubLayout.FIXED)) | ||
) | ||
} | ||
|
||
@Test | ||
fun `The layout of a resource takes precedence over the document layout`() { | ||
assertEquals( | ||
EpubLayout.FIXED, | ||
Presentation(layout = EpubLayout.REFLOWABLE).layoutOf(createLink(EpubLayout.FIXED)) | ||
) | ||
} | ||
|
||
@Test | ||
fun `Get the layout falls back on the document layout`() { | ||
assertEquals( | ||
EpubLayout.FIXED, | ||
Presentation(layout = EpubLayout.FIXED).layoutOf(createLink(null)) | ||
) | ||
} | ||
|
||
@Test | ||
fun `Get the layout falls back on REFLOWABLE`() { | ||
assertEquals( | ||
EpubLayout.REFLOWABLE, | ||
Presentation(layout = null).layoutOf(createLink(null)) | ||
) | ||
} | ||
|
||
private fun createLink(layout: EpubLayout?) = Link( | ||
href = "res", | ||
properties = Properties( | ||
otherProperties = layout?.let { mapOf("layout" to layout.value) } | ||
?: emptyMap() | ||
) | ||
) | ||
|
||
} |