Skip to content

Commit

Permalink
Merge pull request #29 from iZettle/feature/bump_dependencies
Browse files Browse the repository at this point in the history
Bump dependencies
  • Loading branch information
erikeelde authored Feb 27, 2019
2 parents bb9b6df + 84ee722 commit 7ee1d92
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Height will be calculated using WebView.getContentHeight()
### Usage:
```
dependencies {
implementation 'com.izettle:html2bitmap:1.6'
implementation 'com.izettle:html2bitmap:1.9'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'

}
}
Expand Down
10 changes: 6 additions & 4 deletions html2bitmap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ android {
}

dependencies {
implementation 'androidx.annotation:annotation:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-beta02'
implementation 'androidx.annotation:annotation:1.0.2'
testImplementation 'androidx.test.ext:junit:1.1.1-alpha01'
androidTestImplementation 'androidx.test.ext:junit:1.1.1-alpha01'
androidTestImplementation 'androidx.test:core:1.1.1-alpha01'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.izettle.html2bitmap.R;
import com.izettle.html2bitmap.content.WebViewContent;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -15,8 +16,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
Expand All @@ -27,11 +28,16 @@

@RunWith(AndroidJUnit4.class)
public class TestBitmapCSS {
private Context appContext;

@Before
public void setUp() {
appContext = ApplicationProvider.getApplicationContext();
}

@Test
public void testBitmap() throws Exception {
Context appContext = InstrumentationRegistry.getTargetContext();

InputStream inputStream = InstrumentationRegistry.getContext().getResources().openRawResource(R.raw.csstest);
InputStream inputStream = appContext.getResources().openRawResource(R.raw.csstest);

String html = stringFromStream(inputStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import com.izettle.html2bitmap.Html2Bitmap;
import com.izettle.html2bitmap.content.WebViewContent;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
Expand All @@ -22,9 +23,15 @@
@RunWith(AndroidJUnit4.class)
public class TestBitmapSize {

private Context appContext;

@Before
public void setUp() {
appContext = ApplicationProvider.getApplicationContext();
}

@Test
public void testBitmap() {
Context appContext = InstrumentationRegistry.getTargetContext();

Bitmap bitmap = new Html2Bitmap.Builder()
.setContext(appContext)
Expand All @@ -41,8 +48,6 @@ public void testBitmap() {

@Test
public void testWideBitmap() {
Context appContext = InstrumentationRegistry.getTargetContext();

Bitmap bitmap = new Html2Bitmap.Builder()
.setContext(appContext)
.setContent(WebViewContent.html("<html><body><h1>Hello world</h1><p>foo <strong>bar</strong></p></body</html>"))
Expand All @@ -56,8 +61,6 @@ public void testWideBitmap() {

@Test
public void testLongBitmap() {
Context appContext = InstrumentationRegistry.getTargetContext();

StringBuilder sb = new StringBuilder();
for (int i = 0; i < 20; i++) {
sb.append("<p>i</p>");
Expand All @@ -76,8 +79,6 @@ public void testLongBitmap() {

@Test
public void testExtraLongBitmap() {
Context appContext = InstrumentationRegistry.getTargetContext();

StringBuilder sb = new StringBuilder();
for (int i = 0; i < 500; i++) {
sb.append("<p>i</p>");
Expand All @@ -93,6 +94,6 @@ public void testExtraLongBitmap() {
assertNotNull(bitmap);
assertEquals(100, bitmap.getWidth());

assertThat(bitmap.getHeight(), allOf(greaterThan(17600), lessThan(18200)));
assertThat(bitmap.getHeight(), allOf(greaterThan(17400), lessThan(18200)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.izettle.html2bitmap.content.WebViewContent;
import com.izettle.html2bitmap.content.WebViewResource;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -18,18 +19,24 @@
import java.io.InputStreamReader;
import java.util.List;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class TestLoadRelativeLocalFiles {

private Context appContext;

@Before
public void setUp() {
appContext = ApplicationProvider.getApplicationContext();
}

@Test
public void testLoadRelativeImage() {
Context appContext = InstrumentationRegistry.getTargetContext();

Html2Bitmap html2Bitmap = new Html2Bitmap.Builder()
.setContext(appContext)
.setContent(WebViewContent.html("<html><body><h1>Hello world</h1><img src='faces_200_400.png'></body</html>"))
Expand All @@ -47,9 +54,7 @@ public void testLoadRelativeImage() {

@Test
public void testLoadRemoteFontFilesFromGoogle() throws IOException {
Context appContext = InstrumentationRegistry.getTargetContext();

InputStream inputStream = InstrumentationRegistry.getContext().getResources().openRawResource(R.raw.remotefonttest);
InputStream inputStream = appContext.getResources().openRawResource(R.raw.remotefonttest);

String html = stringFromStream(inputStream);

Expand All @@ -65,14 +70,12 @@ public void testLoadRemoteFontFilesFromGoogle() throws IOException {

assertEquals(3, webViewResources.size());
assertEquals(Uri.parse("https://fonts.googleapis.com/css?family=Hanalei+Fill"), webViewResources.get(1).getUri());
assertEquals(Uri.parse("https://fonts.gstatic.com/s/hanaleifill/v6/fC1mPYtObGbfyQznIaQzPQi8UAjFhFqtag.ttf"), webViewResources.get(2).getUri());
assertEquals(Uri.parse("https://fonts.gstatic.com/s/hanaleifill/v7/fC1mPYtObGbfyQznIaQzPQi8UAjFhFqtag.ttf"), webViewResources.get(2).getUri());
}

@Test
public void testLoadLocalFontFiles() throws IOException {
Context appContext = InstrumentationRegistry.getTargetContext();

InputStream inputStream = InstrumentationRegistry.getContext().getResources().openRawResource(R.raw.localfonttest);
InputStream inputStream = appContext.getResources().openRawResource(R.raw.localfonttest);

String html = stringFromStream(inputStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,29 @@
import com.izettle.html2bitmap.Html2Bitmap;
import com.izettle.html2bitmap.content.WebViewContent;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.net.URL;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import static org.junit.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class TestRemote {

private Context appContext;

@Before
public void setUp() {
appContext = ApplicationProvider.getApplicationContext();
}

@Test
public void restRemote() throws Exception {
Context appContext = InstrumentationRegistry.getTargetContext();

String url = "https://raw.githubusercontent.com/iZettle/android-html2bitmap/develop/html2bitmap/src/debug/res/raw/simple.html";
Html2Bitmap html2Bitmap = new Html2Bitmap.Builder(appContext, WebViewContent.url(new URL(url)))
.setTimeout(5)
Expand Down
4 changes: 2 additions & 2 deletions html2bitmapdemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ dependencies {
//implementation 'com.izettle:html2bitmap:1.8'
implementation project(":html2bitmap")

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
}

0 comments on commit 7ee1d92

Please sign in to comment.