Skip to content

Commit 4945702

Browse files
authored
ci: run apps/automated on CI (NativeScript#9196)
1 parent abc7880 commit 4945702

File tree

13 files changed

+182
-97
lines changed

13 files changed

+182
-97
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'apps/automated'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Install Python
18+
uses: actions/setup-python@v1
19+
20+
- name: Install NativeScript
21+
run: |
22+
python -m pip install --upgrade pip six
23+
npm i -g nativescript --ignore-scripts
24+
ns usage-reporting disable
25+
ns error-reporting disable
26+
ns doctor
27+
28+
- name: Setup
29+
run: npm run setup
30+
31+
- name: Create Emulator
32+
uses: rigor789/action-create-emulator@master
33+
34+
- name: Test (Android)
35+
run: node tools/scripts/run-automated.js android
36+
37+
- name: Test (iOS)
38+
if: always() # run iOS tests even if Android tests failed
39+
run: node tools/scripts/run-automated.js ios

apps/automated/src/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare var __CI__;

apps/automated/src/test-runner.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,18 @@ allTests['PLATFORM'] = platformTests;
4141
import * as fsTests from './file-system/file-system-tests';
4242
allTests['FILE-SYSTEM'] = fsTests;
4343

44-
// Disabled tests as they have external dependencies
45-
// TODO: find a way to run these tests locally, but don't run them on the CI as they are flaky
46-
// import * as httpTests from "./http/http-tests";
47-
// allTests["HTTP"] = httpTests;
48-
49-
// import * as xhrTests from "./xhr/xhr-tests";
50-
// allTests["XHR"] = xhrTests;
44+
import * as httpTests from './http/http-tests';
45+
import * as xhrTests from './xhr/xhr-tests';
46+
import * as fetchTests from './fetch/fetch-tests';
47+
import * as timerTests from './timer/timer-tests';
5148

52-
// import * as fetchTests from "./fetch/fetch-tests";
53-
// allTests["FETCH"] = fetchTests;
49+
// don't run these on CI as they are flaky
50+
if (!__CI__) {
51+
allTests['HTTP'] = httpTests;
52+
allTests['XHR'] = xhrTests;
53+
allTests['FETCH'] = fetchTests;
54+
allTests['TIMER'] = timerTests;
55+
}
5456

5557
import * as appSettingsTests from './application-settings/application-settings-tests';
5658
allTests['APPLICATION-SETTINGS'] = appSettingsTests;
@@ -70,9 +72,6 @@ allTests['VIRTUAL-ARRAY'] = virtualArrayTests;
7072
import * as observableTests from './data/observable-tests';
7173
allTests['OBSERVABLE'] = observableTests;
7274

73-
import * as timerTests from './timer/timer-tests';
74-
allTests['TIMER'] = timerTests;
75-
7675
import * as animationFrameTests from './animation-frame/animation-frame';
7776
allTests['ANIMATION-FRAME'] = animationFrameTests;
7877

apps/automated/src/timer/timer-tests.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export function test_setInterval_callbackCalledDuringPeriod(done) {
155155
export function test_setInterval_callbackCalledWithExtraArgs(done) {
156156
let counter: number = 0;
157157
const rnd: number = Math.random();
158+
const threshold = 100;
158159

159160
const start = TKUnit.time();
160161
const id = timer.setInterval(
@@ -163,10 +164,10 @@ export function test_setInterval_callbackCalledWithExtraArgs(done) {
163164
if (counter === 4) {
164165
const end = TKUnit.time();
165166
timer.clearInterval(id);
166-
done(end - start > 250 ? new Error('setInterval too slow.') : null);
167+
done(end - start > 1000 + threshold ? new Error('setInterval too slow.') : null);
167168
}
168169
},
169-
50,
170+
250,
170171
rnd
171172
);
172173
}
@@ -179,11 +180,11 @@ export function test_setInterval_callbackNotDelayedByBusyWork() {
179180
calls++;
180181
if (firstCall) {
181182
firstCall = false;
182-
TKUnit.wait(0.025);
183+
TKUnit.wait(0.125);
183184
}
184-
}, 50);
185+
}, 250);
185186

186-
TKUnit.wait(0.11);
187+
TKUnit.wait(0.55);
187188
timer.clearInterval(id);
188189
TKUnit.assertEqual(calls, 2, 'Callback should be called multiple times with busy wait');
189190
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
import * as buttonModule from '@nativescript/core/ui/button';
2-
import * as colorModule from '@nativescript/core/color';
3-
import * as utilsModule from '@nativescript/core/utils/utils';
4-
import * as enums from '@nativescript/core/ui/enums';
1+
import { Color, Button, Utils, Enums } from '@nativescript/core';
52

6-
export function getNativeText(button: buttonModule.Button): string {
3+
export function getNativeText(button: Button): string {
74
return button.android.getText();
85
}
96

10-
export function getNativeTextWrap(button: buttonModule.Button): boolean {
7+
export function getNativeTextWrap(button: Button): boolean {
118
return (<android.widget.Button>button.android).getLineCount() === 1;
129
}
1310

14-
export function getNativeFontSize(button: buttonModule.Button): number {
15-
var density = utilsModule.layout.getDisplayDensity();
11+
export function getNativeFontSize(button: Button): number {
12+
let density = Utils.layout.getDisplayDensity();
1613

1714
return button.android.getTextSize() / density;
1815
}
1916

20-
export function getNativeColor(button: buttonModule.Button): colorModule.Color {
21-
return new colorModule.Color(button.android.getTextColors().getDefaultColor());
17+
export function getNativeColor(button: Button): Color {
18+
return new Color(button.android.getTextColors().getDefaultColor());
2219
}
2320

24-
export function getNativeBackgroundColor(button: buttonModule.Button): colorModule.Color {
25-
var bkg = <any>button.android.getBackground();
26-
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
27-
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
21+
export function getNativeBackgroundColor(button: Button): Color {
22+
let bg = <any>button.android.getBackground();
23+
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
24+
return new Color(bg.getBackgroundColor());
25+
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
26+
console.log(bg);
27+
return new Color(bg.getColor());
2828
} else {
29-
return new colorModule.Color(bkg.backgroundColor);
29+
return new Color(bg.backgroundColor);
3030
}
3131
}
3232

33-
export function getNativeTextAlignment(button: buttonModule.Button): string {
34-
var gravity = button.android.getGravity();
33+
export function getNativeTextAlignment(button: Button): string {
34+
let gravity = button.android.getGravity();
3535

3636
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
37-
return enums.TextAlignment.left;
37+
return Enums.TextAlignment.left;
3838
}
3939

4040
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
41-
return enums.TextAlignment.center;
41+
return Enums.TextAlignment.center;
4242
}
4343

4444
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
45-
return enums.TextAlignment.right;
45+
return Enums.TextAlignment.right;
4646
}
4747

4848
return 'unexpected value';
4949
}
5050

51-
export function performNativeClick(button: buttonModule.Button): void {
51+
export function performNativeClick(button: Button): void {
5252
button.android.performClick();
5353
}

apps/automated/src/ui/label/label-tests-native.android.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as enums from '@nativescript/core/ui/enums';
33
import * as colorModule from '@nativescript/core/color';
44

55
export function getNativeTextAlignment(label: labelModule.Label): string {
6-
var gravity = label.android.getGravity();
6+
let gravity = label.android.getGravity();
77

88
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
99
return enums.TextAlignment.left;
@@ -21,10 +21,12 @@ export function getNativeTextAlignment(label: labelModule.Label): string {
2121
}
2222

2323
export function getNativeBackgroundColor(label: labelModule.Label): colorModule.Color {
24-
var bkg = <any>label.android.getBackground();
25-
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
26-
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
24+
let bg = <any>label.android.getBackground();
25+
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
26+
return new colorModule.Color(bg.getBackgroundColor());
27+
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
28+
return new colorModule.Color(bg.getColor());
2729
} else {
28-
return new colorModule.Color(bkg.backgroundColor);
30+
return new colorModule.Color(bg.backgroundColor);
2931
}
3032
}

apps/automated/src/ui/label/label-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
330330
normalColor = actualColors.getDefaultColor();
331331
TKUnit.assert(normalColor, 'Expected: ' + expColor + ', Actual: ' + normalColor);
332332

333-
const bkg = <org.nativescript.widgets.BorderDrawable>testLabel.android.getBackground();
334-
actualBackgroundColor = bkg.getBackgroundColor();
333+
const bg = testLabel.android.getBackground();
334+
actualBackgroundColor = bg['getBackgroundColor'] ? bg.getBackgroundColor() : bg.getColor();
335335
expBackgroundColor = android.graphics.Color.parseColor(backgroundColor);
336336
TKUnit.assertEqual(actualBackgroundColor, expBackgroundColor);
337337
} else {
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
import * as textFieldModule from '@nativescript/core/ui/text-field';
2-
import * as colorModule from '@nativescript/core/color';
3-
import * as utilsModule from '@nativescript/core/utils/utils';
4-
import * as enums from '@nativescript/core/ui/enums';
1+
import { TextField, Color, Utils, Enums } from '@nativescript/core';
52

6-
export function getNativeText(textField: textFieldModule.TextField): string {
3+
export function getNativeText(textField: TextField): string {
74
return textField.android.getText().toString();
85
}
96

10-
export function getNativeHint(textField: textFieldModule.TextField): string {
7+
export function getNativeHint(textField: TextField): string {
118
return textField.android.getHint();
129
}
1310

14-
export function getNativeSecure(textField: textFieldModule.TextField): boolean {
15-
var inputType = textField.android.getInputType();
11+
export function getNativeSecure(textField: TextField): boolean {
12+
let inputType = textField.android.getInputType();
1613

1714
return (inputType & android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD) === android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD || (inputType & android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD) === android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD;
1815
}
1916

20-
export function getNativeFontSize(textField: textFieldModule.TextField): number {
21-
var density = utilsModule.layout.getDisplayDensity();
17+
export function getNativeFontSize(textField: TextField): number {
18+
let density = Utils.layout.getDisplayDensity();
2219

2320
return textField.android.getTextSize() / density;
2421
}
2522

26-
export function getNativeColor(textField: textFieldModule.TextField): colorModule.Color {
27-
return new colorModule.Color(textField.android.getTextColors().getDefaultColor());
23+
export function getNativeColor(textField: TextField): Color {
24+
return new Color(textField.android.getTextColors().getDefaultColor());
2825
}
2926

30-
export function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color {
31-
return new colorModule.Color(textField.android.getHintTextColors().getDefaultColor());
27+
export function getNativePlaceholderColor(textField: TextField): Color {
28+
return new Color(textField.android.getHintTextColors().getDefaultColor());
3229
}
3330

34-
export function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color {
35-
var bkg = <any>textField.android.getBackground();
36-
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
37-
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
31+
export function getNativeBackgroundColor(textField: TextField): Color {
32+
let bg = <any>textField.android.getBackground();
33+
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
34+
return new Color(bg.getBackgroundColor());
35+
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
36+
console.log(bg);
37+
return new Color(bg.getColor());
3838
} else {
39-
return new colorModule.Color(bkg.backgroundColor);
39+
return new Color(bg.backgroundColor);
4040
}
4141
}
4242

43-
export function getNativeTextAlignment(textField: textFieldModule.TextField): string {
43+
export function getNativeTextAlignment(textField: TextField): string {
4444
var gravity = textField.android.getGravity();
4545

4646
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
47-
return enums.TextAlignment.left;
47+
return Enums.TextAlignment.left;
4848
}
4949

5050
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
51-
return enums.TextAlignment.center;
51+
return Enums.TextAlignment.center;
5252
}
5353

5454
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
55-
return enums.TextAlignment.right;
55+
return Enums.TextAlignment.right;
5656
}
5757

5858
return 'unexpected value';
5959
}
6060

61-
export function getNativeFocus(textField: textFieldModule.TextField): boolean {
61+
export function getNativeFocus(textField: TextField): boolean {
6262
//
6363
return true;
6464
}
6565

66-
export function typeTextNatively(textField: textFieldModule.TextField, text: string): void {
66+
export function typeTextNatively(textField: TextField, text: string): void {
6767
textField.android.requestFocus();
6868
textField.android.setText(text);
6969
textField.android.clearFocus();
7070
}
7171

72-
export function typeTextNativelyWithReturn(textField: textFieldModule.TextField, text: string): void {
72+
export function typeTextNativelyWithReturn(textField: TextField, text: string): void {
7373
//
7474
}

0 commit comments

Comments
 (0)