diff --git a/packages/core/ui/action-bar/index.android.ts b/packages/core/ui/action-bar/index.android.ts index e8faf9c0c..96c0e7df4 100644 --- a/packages/core/ui/action-bar/index.android.ts +++ b/packages/core/ui/action-bar/index.android.ts @@ -225,7 +225,15 @@ export class ActionBar extends ActionBarBase { const nativeView = this.nativeViewProtected; if (backgroundDrawable && onlyColor && sdkVersion() >= 21) { if (isBorderDrawable && (nativeView)._cachedDrawable) { - backgroundDrawable = (nativeView)._cachedDrawable.newDrawable(nativeView.getResources()); + backgroundDrawable = (nativeView)._cachedDrawable; + // we need to duplicate the drawable or we lose the "default" cached drawable + const constantState = backgroundDrawable.getConstantState(); + if (constantState) { + try { + backgroundDrawable = constantState.newDrawable(nativeView.getResources()); + // eslint-disable-next-line no-empty + } catch {} + } nativeView.setBackground(backgroundDrawable); } diff --git a/packages/core/ui/button/index.android.ts b/packages/core/ui/button/index.android.ts index 036737b3d..9b9092a09 100644 --- a/packages/core/ui/button/index.android.ts +++ b/packages/core/ui/button/index.android.ts @@ -62,10 +62,17 @@ export class Button extends ButtonBase { public _applyBackground(background: Background, isBorderDrawable, onlyColor: boolean, backgroundDrawable: any) { const nativeView = this.nativeViewProtected; - console.log('_applyBackground', nativeView, backgroundDrawable, onlyColor, isBorderDrawable); if (backgroundDrawable && onlyColor) { if (isBorderDrawable && (nativeView)._cachedDrawable) { - backgroundDrawable = (nativeView)._cachedDrawable.newDrawable(nativeView.getResources()); + backgroundDrawable = (nativeView)._cachedDrawable; + // we need to duplicate the drawable or we lose the "default" cached drawable + const constantState = backgroundDrawable.getConstantState(); + if (constantState) { + try { + backgroundDrawable = constantState.newDrawable(nativeView.getResources()); + // eslint-disable-next-line no-empty + } catch {} + } nativeView.setBackground(backgroundDrawable); } diff --git a/packages/core/ui/core/view/index.android.ts b/packages/core/ui/core/view/index.android.ts index cd1ee6d74..25c36ca31 100644 --- a/packages/core/ui/core/view/index.android.ts +++ b/packages/core/ui/core/view/index.android.ts @@ -1009,7 +1009,7 @@ export class View extends ViewCommon { if (constantState) { try { drawable = constantState.newDrawable(nativeView.getResources()); - // eslint-disable-next-line no-empty + // eslint-disable-next-line no-empty } catch {} } } diff --git a/tools/scripts/run-automated.js b/tools/scripts/run-automated.js index 8c67329a1..75b544d90 100644 --- a/tools/scripts/run-automated.js +++ b/tools/scripts/run-automated.js @@ -7,18 +7,36 @@ const spawn = require('child_process').spawn const kill = require('tree-kill'); +const TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes + const spawned_process = spawn('npm', ['start', `apps.automated.${process.argv[2]}`], { stdio: ['inherit', 'pipe', 'pipe'] }) - const {stdout, stderr} = spawned_process stdout.pipe(process.stdout) stderr.pipe(process.stderr) let lineBuffer = [] +let timeout_id; + +function exit(code) { + kill(spawned_process.pid) + process.exit(code) +} + +function onTimeout() { + console.log(`Tests TIMEOUT (${TIMEOUT_MS}ms)`) + exit(1) +} + +function healthCheck() { + clearTimeout(timeout_id) + timeout_id = setTimeout(onTimeout, TIMEOUT_MS) +} stdout.on('data', data => { + healthCheck(); const line = data.toString(); // start buffering lines when tests are complete @@ -29,8 +47,6 @@ stdout.on('data', data => { if(line.includes('Tests EOF!')) { let ok = lineBuffer.join('\n').includes('OK, 0 failed') console.log(ok ? 'Tests PASSED' : 'Tests FAILED'); - kill(spawned_process.pid) - process.exit(ok ? 0 : 1) + exit(ok ? 0 : 1) } }) -