Fix markwon-html tests
This commit is contained in:
		
							parent
							
								
									4f02a793e7
								
							
						
					
					
						commit
						ef15ee4bd2
					
				| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.html.impl; | ||||
| package ru.noties.markwon.html; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| @ -14,13 +14,9 @@ import java.util.Map; | ||||
| 
 | ||||
| import ix.Ix; | ||||
| import ix.IxFunction; | ||||
| import ru.noties.markwon.html.CssInlineStyleParser; | ||||
| import ru.noties.markwon.html.CssProperty; | ||||
| import ru.noties.markwon.test.TestUtils; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static ru.noties.markwon.test.TestUtils.with; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| @ -42,7 +38,7 @@ public class CssInlineStyleParserTest { | ||||
| 
 | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
| @ -60,7 +56,7 @@ public class CssInlineStyleParserTest { | ||||
| 
 | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
| @ -68,7 +64,7 @@ public class CssInlineStyleParserTest { | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(1), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key2", cssProperty.key()); | ||||
| @ -84,7 +80,7 @@ public class CssInlineStyleParserTest { | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
| @ -100,7 +96,7 @@ public class CssInlineStyleParserTest { | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
| @ -116,7 +112,7 @@ public class CssInlineStyleParserTest { | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
| @ -124,7 +120,7 @@ public class CssInlineStyleParserTest { | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(1), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key2", cssProperty.key()); | ||||
| @ -149,7 +145,7 @@ public class CssInlineStyleParserTest { | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key4", cssProperty.key()); | ||||
| @ -174,7 +170,7 @@ public class CssInlineStyleParserTest { | ||||
| 
 | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(0), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
| @ -182,7 +178,7 @@ public class CssInlineStyleParserTest { | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|         with(list.get(1), new Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key3", cssProperty.key()); | ||||
| @ -211,14 +207,14 @@ public class CssInlineStyleParserTest { | ||||
|         }}; | ||||
| 
 | ||||
|         final StringBuilder builder = new StringBuilder(); | ||||
|         for (Map.Entry<String, String> entry: map.entrySet()) { | ||||
|         for (Map.Entry<String, String> entry : map.entrySet()) { | ||||
|             builder.append(entry.getKey()) | ||||
|                     .append(':') | ||||
|                     .append(entry.getValue()) | ||||
|                     .append(';'); | ||||
|         } | ||||
| 
 | ||||
|         for (CssProperty cssProperty: impl.parse(builder.toString())) { | ||||
|         for (CssProperty cssProperty : impl.parse(builder.toString())) { | ||||
|             final String value = map.remove(cssProperty.key()); | ||||
|             assertNotNull(cssProperty.key(), value); | ||||
|             assertEquals(cssProperty.key(), value, cssProperty.value()); | ||||
| @ -238,4 +234,13 @@ public class CssInlineStyleParserTest { | ||||
|                 }) | ||||
|                 .toList(); | ||||
|     } | ||||
| 
 | ||||
|     public interface Action<T> { | ||||
|         void apply(@NonNull T t); | ||||
|     } | ||||
| 
 | ||||
|     private static <T> void with(@NonNull T t, @NonNull Action<T> action) { | ||||
|         action.apply(t); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,12 +1,10 @@ | ||||
| package ru.noties.markwon.html.impl; | ||||
| package ru.noties.markwon.html; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
| 
 | ||||
| import ru.noties.markwon.html.HtmlEmptyTagReplacement; | ||||
| import ru.noties.markwon.html.api.HtmlTag; | ||||
| import ru.noties.markwon.html.HtmlTagImpl.InlineImpl; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.html.impl; | ||||
| package ru.noties.markwon.html; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| @ -15,11 +15,6 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import ru.noties.markwon.html.HtmlEmptyTagReplacement; | ||||
| import ru.noties.markwon.html.MarkwonHtmlParserImpl; | ||||
| import ru.noties.markwon.html.api.HtmlTag; | ||||
| import ru.noties.markwon.html.api.MarkwonHtmlParser; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| @ -847,7 +842,7 @@ public class MarkwonHtmlParserImplTest { | ||||
|                 "<h3>head #3</h3><custom-tag>in custom-tag</custom-tag>" | ||||
|         }; | ||||
| 
 | ||||
|         for (String fragment: fragments) { | ||||
|         for (String fragment : fragments) { | ||||
|             impl.processFragment(output, fragment); | ||||
|         } | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.html.impl; | ||||
| package ru.noties.markwon.html; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| @ -1,24 +1,20 @@ | ||||
| package ru.noties.markwon.html.impl.jsoup.nodes; | ||||
| package ru.noties.markwon.html.jsoup.nodes; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import ru.noties.markwon.html.jsoup.nodes.CommonMarkEntities; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| public class CommonMarkEntitiesTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void can_access_field() { | ||||
|         assertTrue("&", CommonMarkEntities.isNamedEntity("amp")); | ||||
|         Assert.assertTrue("&", CommonMarkEntities.isNamedEntity("amp")); | ||||
|         final int[] codepoints = new int[1]; | ||||
|         CommonMarkEntities.codepointsForName("amp", codepoints); | ||||
|         assertEquals('&', codepoints[0]); | ||||
|         Assert.assertEquals('&', codepoints[0]); | ||||
|     } | ||||
| } | ||||
| @ -1,8 +1,9 @@ | ||||
| package ru.noties.markwon.html.impl.tag; | ||||
| package ru.noties.markwon.html.tag; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| @ -13,13 +14,8 @@ import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ru.noties.markwon.html.tag.ImageSizeParserImpl; | ||||
| import ru.noties.markwon.html.CssInlineStyleParser; | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.renderer.html2.CssInlineStyleParser; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertNull; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| @ -36,7 +32,7 @@ public class ImageSizeParserImplTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void nothing() { | ||||
|         assertNull(impl.parse(Collections.<String, String>emptyMap())); | ||||
|         Assert.assertNull(impl.parse(Collections.<String, String>emptyMap())); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
| @ -153,15 +149,15 @@ public class ImageSizeParserImplTest { | ||||
|         }; | ||||
| 
 | ||||
|         for (String dimension : dimensions) { | ||||
|             assertNull(dimension, impl.dimension(dimension)); | ||||
|             Assert.assertNull(dimension, impl.dimension(dimension)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static void assertImageSize(@Nullable ImageSize expected, @Nullable ImageSize actual) { | ||||
|         if (expected == null) { | ||||
|             assertNull(actual); | ||||
|             Assert.assertNull(actual); | ||||
|         } else { | ||||
|             assertNotNull(actual); | ||||
|             Assert.assertNotNull(actual); | ||||
|             assertDimension("width", expected.width, actual.width); | ||||
|             assertDimension("height", expected.height, actual.height); | ||||
|         } | ||||
| @ -172,11 +168,11 @@ public class ImageSizeParserImplTest { | ||||
|             @Nullable ImageSize.Dimension expected, | ||||
|             @Nullable ImageSize.Dimension actual) { | ||||
|         if (expected == null) { | ||||
|             assertNull(name, actual); | ||||
|             Assert.assertNull(name, actual); | ||||
|         } else { | ||||
|             assertNotNull(name, actual); | ||||
|             assertEquals(name, expected.value, actual.value, DELTA); | ||||
|             assertEquals(name, expected.unit, actual.unit); | ||||
|             Assert.assertNotNull(name, actual); | ||||
|             Assert.assertEquals(name, expected.value, actual.value, DELTA); | ||||
|             Assert.assertEquals(name, expected.unit, actual.unit); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -1,17 +0,0 @@ | ||||
| package ru.noties.markwon.test; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| public abstract class TestUtils { | ||||
| 
 | ||||
|     public interface Action<T> { | ||||
|         void apply(@NonNull T t); | ||||
|     } | ||||
| 
 | ||||
|     public static <T> void with(@NonNull T t, @NonNull Action<T> action) { | ||||
|         action.apply(t); | ||||
|     } | ||||
| 
 | ||||
|     private TestUtils() { | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov