diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiColorHelper.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiColorHelper.java index 3321a14f01f..8a800b82fbf 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiColorHelper.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiColorHelper.java @@ -36,6 +36,8 @@ public class TiColorHelper "rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*(\\d\\.\\d+)\\s*\\)"); static Pattern floatsPattern = Pattern.compile( "rgba\\(\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*\\)"); + static Pattern rgbaPatternFallback = + Pattern.compile("rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)"); private static final String TAG = "TiColorHelper"; private static HashMap colorTable; @@ -72,13 +74,17 @@ public static int parseColor(String value) } // rgba(int, int, int, int) if ((m = argbPattern.matcher(lowval)).matches()) { - return Color.argb(Integer.valueOf(m.group(4)), Integer.valueOf(m.group(1)), - Integer.valueOf(m.group(2)), Integer.valueOf(m.group(3))); + return Color.argb(Integer.valueOf(m.group(4)), Integer.valueOf(m.group(1)), Integer.valueOf(m.group(2)), + Integer.valueOf(m.group(3))); } // rgba(int, int, int, float) if ((m = rgbaPattern.matcher(lowval)).matches()) { return Color.argb(Math.round(Float.valueOf(m.group(4)) * 255f), Integer.valueOf(m.group(1)), - Integer.valueOf(m.group(2)), Integer.valueOf(m.group(3))); + Integer.valueOf(m.group(2)), Integer.valueOf(m.group(3))); + } + // rgba(int, int, int) with missing alpha value + if ((m = rgbaPatternFallback.matcher(lowval)).matches()) { + return Color.rgb(Integer.valueOf(m.group(1)), Integer.valueOf(m.group(2)), Integer.valueOf(m.group(3))); } // rgba(float, float, float, float) if ((m = floatsPattern.matcher(lowval)).matches()) { diff --git a/build/lib/test/test.js b/build/lib/test/test.js index c0563f994fe..5f18301a2d9 100644 --- a/build/lib/test/test.js +++ b/build/lib/test/test.js @@ -77,7 +77,19 @@ async function test(platforms, target, deviceId, deployType, deviceFamily, snaps // If we're gathering images, make sure we get them all before we move on if (snapshotPromises.length !== 0) { - await Promise.all(snapshotPromises); + try { + await Promise.all(snapshotPromises); + } catch (err) { + // If grabbing an image fails, can we report more details about why? + // The rejected error should have stdout/stderr properties + if (err.stderr) { + console.error(err.stderr); + } + if (err.stdout) { + console.log(err.stdout); + } + throw err; + } } return results; diff --git a/tests/Resources/android/snapshots/rgbView_green_200x200@2x.png b/tests/Resources/android/snapshots/rgbView_green_200x200@2x.png new file mode 100644 index 00000000000..68715e49f9b Binary files /dev/null and b/tests/Resources/android/snapshots/rgbView_green_200x200@2x.png differ diff --git a/tests/Resources/android/snapshots/rgbaView_red_200x200@2x.png b/tests/Resources/android/snapshots/rgbaView_red_200x200@2x.png new file mode 100644 index 00000000000..54c75fab6d7 Binary files /dev/null and b/tests/Resources/android/snapshots/rgbaView_red_200x200@2x.png differ diff --git a/tests/Resources/ios/snapshots/rgbView_green_200x200@2x.png b/tests/Resources/ios/snapshots/rgbView_green_200x200@2x.png new file mode 100644 index 00000000000..c3a6b5bb1ef Binary files /dev/null and b/tests/Resources/ios/snapshots/rgbView_green_200x200@2x.png differ diff --git a/tests/Resources/ios/snapshots/rgbView_green_300x300@3x.png b/tests/Resources/ios/snapshots/rgbView_green_300x300@3x.png new file mode 100644 index 00000000000..8f7fb726c3c Binary files /dev/null and b/tests/Resources/ios/snapshots/rgbView_green_300x300@3x.png differ diff --git a/tests/Resources/ios/snapshots/rgbaView_red_200x200@2x.png b/tests/Resources/ios/snapshots/rgbaView_red_200x200@2x.png new file mode 100644 index 00000000000..77cf9afb66e Binary files /dev/null and b/tests/Resources/ios/snapshots/rgbaView_red_200x200@2x.png differ diff --git a/tests/Resources/ios/snapshots/rgbaView_red_300x300@3x.png b/tests/Resources/ios/snapshots/rgbaView_red_300x300@3x.png new file mode 100644 index 00000000000..492b96df626 Binary files /dev/null and b/tests/Resources/ios/snapshots/rgbaView_red_300x300@3x.png differ diff --git a/tests/Resources/ti.ui.view.test.js b/tests/Resources/ti.ui.view.test.js index 53c7d7837a4..abb6a9f65d4 100644 --- a/tests/Resources/ti.ui.view.test.js +++ b/tests/Resources/ti.ui.view.test.js @@ -1300,4 +1300,37 @@ describe('Titanium.UI.View', function () { const view2 = Ti.UI.createView({ filterTouchesWhenObscured: true }); should(view2.filterTouchesWhenObscured).be.true(); }); + + it('rgba fallback', finish => { + if (isCI && utilities.isMacOS()) { // some of the CI mac nodes lie about their scale, which makes the image comparison fail + return finish(); // FIXME: skip when we move to official mocha package + } + win = Ti.UI.createWindow({ backgroundColor: '#fff' }); + const rgbaView = Ti.UI.createView({ + width: 100, + height: 100, + backgroundColor: 'rgba(255,0,0)', + left: 0 + }); + const rgbView = Ti.UI.createView({ + width: 100, + height: 100, + backgroundColor: 'rgb(0,255,0)', + left: 100 + }); + + win.addEventListener('postlayout', function postlayout() { // FIXME: Support once! + win.removeEventListener('postlayout', postlayout); // only run once + try { + should(rgbaView).matchImage('snapshots/rgbaView_red.png'); + should(rgbView).matchImage('snapshots/rgbView_green.png'); + } catch (err) { + return finish(err); + } + finish(); + }); + win.add(rgbaView); + win.add(rgbView); + win.open(); + }); });