Skip to content

Commit

Permalink
Merge commit '0b9c6088555e856e9fc7cdfe3e1e7b835ea4f08d' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	libs/utils/WordPressUtils/build.gradle
	libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/AppLog.java
	libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/SwipeToRefreshHelper.java
  • Loading branch information
aforcier committed Feb 12, 2016
2 parents b927220 + c611f1e commit fc52906
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion WordPressUtils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
buildToolsVersion "23.0.2"

defaultConfig {
versionName "1.8.0"
versionName "1.9.0"
minSdkVersion 14
targetSdkVersion 23
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.wordpress.android.util;

import android.test.InstrumentationTestCase;

public class ShortcodeUtilsTest extends InstrumentationTestCase {
public void testGetVideoPressShortcodeFromId() {
assertEquals("[wpvideo abcd1234]", ShortcodeUtils.getVideoPressShortcodeFromId("abcd1234"));
}

public void testGetVideoPressShortcodeFromNullId() {
assertEquals("", ShortcodeUtils.getVideoPressShortcodeFromId(null));
}

public void testGetVideoPressIdFromCorrectShortcode() {
assertEquals("abcd1234", ShortcodeUtils.getVideoPressIdFromShortCode("[wpvideo abcd1234]"));
}

public void testGetVideoPressIdFromInvalidShortcode() {
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode("[other abcd1234]"));
}

public void testGetVideoPressIdFromNullShortcode() {
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode(null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.wordpress.android.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ShortcodeUtils {
public static String getVideoPressShortcodeFromId(String videoPressId) {
if (videoPressId == null || videoPressId.isEmpty()) {
return "";
}

return "[wpvideo " + videoPressId + "]";
}

public static String getVideoPressIdFromShortCode(String shortcode) {
String videoPressId = "";

if (shortcode != null) {
String videoPressShortcodeRegex = "^\\[wpvideo (.*)]$";

Pattern pattern = Pattern.compile(videoPressShortcodeRegex);
Matcher matcher = pattern.matcher(shortcode);

if (matcher.find()) {
videoPressId = matcher.group(1);
}
}

return videoPressId;
}
}

0 comments on commit fc52906

Please sign in to comment.