This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Convert bold and link markdown to HTML equivalents (handled by EncodingFixer) * Subreddit mentions (eg "/r/Android") are converted to HTML links * Support for HTML app descriptions in App Details view and App List view * Clickable links in app details view * Unit tests for changes, updates to other tests and mocks
- Loading branch information
Showing
8 changed files
with
184 additions
and
16 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
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
58 changes: 58 additions & 0 deletions
58
...rc/test/java/subreddit/android/appstore/backend/reddit/wiki/parser/EncodingFixerTest.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,58 @@ | ||
package subreddit.android.appstore.backend.reddit.wiki.parser; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
|
||
public class EncodingFixerTest { | ||
private String descriptionBoldMarkdown, descriptionLinkMarkdown, descriptionSubreddits; | ||
private EncodingFixer encodingFixer; | ||
|
||
@Before | ||
public void setup() { | ||
encodingFixer = new EncodingFixer(); | ||
|
||
descriptionBoldMarkdown = "New ingenious full feature Reddit client. **Read AMA in magazine" + | ||
"style QA format.** Add upcoming AMA to your calendar. **Only app with Text to " + | ||
"Speech: Listen to the content.** Zero wait, streams all GIF instantly."; | ||
descriptionLinkMarkdown = "Tutorial screencast for [Propellerheads Reason](https://www" + | ||
".propellerheads.se/products/reason/) and [Link 2](https://www.google.com)"; | ||
descriptionSubreddits = "You can setup playlists, geofences, volume control, and share" + | ||
" playlists with others. Share playlists at /r/androidrrm and /r/android"; | ||
} | ||
|
||
@Test | ||
public void testConvertMarkdownToHtml() { | ||
String output = encodingFixer.convertMarkdownToHtml(""); | ||
assertEquals("", output); | ||
|
||
output = encodingFixer.convertMarkdownToHtml("This description has no markdown"); | ||
assertEquals("This description has no markdown", output); | ||
} | ||
|
||
@Test | ||
public void testConvertMarkdownToHtml_bold() { | ||
String output = encodingFixer.convertMarkdownToHtml(descriptionBoldMarkdown); | ||
assertEquals("New ingenious full feature Reddit client. <b>Read AMA in magazine" + | ||
"style QA format.</b> Add upcoming AMA to your calendar. <b>Only app with Text to " + | ||
"Speech: Listen to the content.</b> Zero wait, streams all GIF instantly.", output); | ||
} | ||
|
||
@Test | ||
public void testConvertMarkdownToHtml_link() { | ||
String output = encodingFixer.convertMarkdownToHtml(descriptionLinkMarkdown); | ||
assertEquals("Tutorial screencast for " + | ||
"<a href=\"https://www.propellerheads.se/products/reason/\">" + | ||
"Propellerheads Reason</a> and <a href=\"https://www.google.com\">Link 2</a>", output); | ||
} | ||
|
||
@Test | ||
public void testConvertSubredditsToLinks() { | ||
String output = encodingFixer.convertSubredditsToLinks(descriptionSubreddits); | ||
assertEquals("You can setup playlists, geofences, volume control, and share " + | ||
"playlists with others. Share playlists at " + | ||
"<a href=\"https://www.reddit.com/r/androidrrm\">/r/androidrrm</a> " + | ||
"and <a href=\"https://www.reddit.com/r/android\">/r/android</a>", output); | ||
} | ||
} |