Skip to content

Commit d911b24

Browse files
authored
Cleaned up test execution and made it more sensible (#4163)
iOS and Android pipelines didn't correctly generate all 7 screenshots. As part of that work also added the ability to get a stack trace as a string for Android applications.
1 parent a7dbab5 commit d911b24

35 files changed

+357
-305
lines changed

.github/workflows/scripts-android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ name: Test Android build scripts
1313
- 'scripts/android/lib/**/*.java'
1414
- 'scripts/android/tests/**/*.java'
1515
- 'scripts/device-runner-app/**/*.java'
16+
- 'scripts/hellocodenameone/**'
1617
- 'scripts/android/screenshots/**'
1718
- '!scripts/android/screenshots/**/*.md'
1819
- 'scripts/templates/**'
@@ -39,6 +40,7 @@ name: Test Android build scripts
3940
- 'scripts/android/lib/**/*.java'
4041
- 'scripts/android/tests/**/*.java'
4142
- 'scripts/device-runner-app/**/*.java'
43+
- 'scripts/hellocodenameone/**'
4244
- 'scripts/android/screenshots/**'
4345
- '!scripts/android/screenshots/**/*.md'
4446
- 'scripts/templates/**'

.github/workflows/scripts-ios.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- 'scripts/build-ios-port.sh'
99
- 'scripts/build-ios-app.sh'
1010
- 'scripts/run-ios-ui-tests.sh'
11-
- 'scripts/device-runner-app/**/*.java'
11+
- 'scripts/hellocodenameone/**'
1212
- 'scripts/ios/tests/**'
1313
- 'scripts/ios/screenshots/**'
1414
- 'scripts/templates/**'
@@ -30,7 +30,7 @@ on:
3030
- 'scripts/build-ios-port.sh'
3131
- 'scripts/build-ios-app.sh'
3232
- 'scripts/run-ios-ui-tests.sh'
33-
- 'scripts/device-runner-app/**/*.java'
33+
- 'scripts/hellocodenameone/**'
3434
- 'scripts/ios/tests/**'
3535
- 'scripts/ios/screenshots/**'
3636
- 'scripts/templates/**'

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8773,6 +8773,23 @@ public void announceForAccessibility(Component cmp, String text) {
87738773
// should override this method.
87748774
}
87758775

8776+
/**
8777+
* Returns the stack trace from the exception on the given
8778+
* thread. This API isn't supported on all platforms and may
8779+
* return a blank string when unavailable.
8780+
*
8781+
* @param parentThread the thread in which the exception was thrown
8782+
* @param t the exception
8783+
* @return a stack trace string that might be blank
8784+
*/
8785+
public String getStackTrace(Thread parentThread, Throwable t) {
8786+
System.out.println("CN1SS:ERR:Invoking getStackTrace in CodenameOneImplementation");
8787+
if (parentThread instanceof CodenameOneThread && ((CodenameOneThread) parentThread).hasStackFrame()) {
8788+
return ((CodenameOneThread) parentThread).getStack(t);
8789+
}
8790+
return "";
8791+
}
8792+
87768793
class RPush implements Runnable {
87778794
public void run() {
87788795
final long pushId = Preferences.get("push_id", (long) -1);

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,20 @@ void mainEDTLoop() {
11311131
INSTANCE.edt = null;
11321132
}
11331133

1134+
/**
1135+
* Returns the stack trace from the exception on the given
1136+
* thread. This API isn't supported on all platforms and may
1137+
* return a blank string when unavailable.
1138+
*
1139+
* @param parentThread the thread in which the exception was thrown
1140+
* @param t the exception
1141+
* @return a stack trace string that might be blank
1142+
*/
1143+
public String getStackTrace(Thread parentThread, Throwable t) {
1144+
System.out.println("CN1SS:ERR:Invoking getStackTrace in Display");
1145+
return impl.getStackTrace(parentThread, t);
1146+
}
1147+
11341148
/**
11351149
* Implementation of the event dispatch loop content
11361150
*/

CodenameOne/src/com/codename1/ui/Graphics.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ public void fillRect(int x, int y, int width, int height) {
383383
impl.fillRect(nativeGraphics, xTranslate + x, yTranslate + y, width, height);
384384
}
385385

386+
/**
387+
* @deprecated this method should have been internals
388+
*/
386389
public void drawShadow(Image img, int x, int y, int offsetX, int offsetY, int blurRadius, int spreadRadius, int color, float opacity) {
387390
impl.drawShadow(nativeGraphics, img.getImage(), xTranslate + x, yTranslate + y, offsetX, offsetY, blurRadius, spreadRadius, color, opacity);
388391
}

Ports/Android/src/com/codename1/impl/android/AndroidGraphics.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009 Pader-Sync Ltd. & Co. KG. All Rights Reserved.
2+
* Copyright 2009 Pader-Sync Ltd. & Co. KG. All Rights Reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -144,18 +144,18 @@ public void drawImage(Object img, int x, int y) {
144144
}
145145

146146
public void drawShadow(Object image, int x, int y, int offsetX, int offsetY, int blurRadius, int spreadRadius, int color, float opacity) {
147-
if (image == null) return;
147+
if (image == null || canvas == null) {
148+
return;
149+
}
148150
Bitmap bmp = (Bitmap)image;
149151
float bmpW = bmp.getWidth();
150152
float bmpH = bmp.getHeight();
151-
if (bmpW == 0 || bmpH == 0) return;
152-
153-
153+
if (bmpW == 0 || bmpH == 0) {
154+
return;
155+
}
154156

155157
Bitmap scaledBmp = Bitmap.createScaledBitmap(bmp, bmp.getWidth() + 2 * spreadRadius, bmp.getHeight() + 2 * spreadRadius, false);
156-
157158
Paint alphaPaint = new Paint();
158-
159159
alphaPaint.setMaskFilter(new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL));
160160
int[] offsetXY = new int[2];
161161
Bitmap bmAlpha = scaledBmp.extractAlpha(alphaPaint, offsetXY);
@@ -164,13 +164,11 @@ public void drawShadow(Object image, int x, int y, int offsetX, int offsetY, int
164164
applyTransform();
165165
Paint shadowPaint = new Paint();
166166
int alpha = (int)Math.floor(opacity * 255);
167-
shadowPaint.setColor((0xff000000 | color));
168-
shadowPaint.setAlpha((int)Math.floor(opacity * 255));
169-
167+
shadowPaint.setColor(0xff000000 | color);
168+
shadowPaint.setAlpha(alpha);
170169
canvas.drawBitmap(bmAlpha, x + offsetXY[0] - spreadRadius + offsetX, y + offsetXY[1] - spreadRadius + offsetY, shadowPaint);
171170
bmAlpha.recycle();
172171

173-
174172
unapplyTransform();
175173
canvas.restore();
176174
}

0 commit comments

Comments
 (0)