mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
ci: run apps/automated on CI (#9196)
This commit is contained in:
1
apps/automated/src/globals.d.ts
vendored
Normal file
1
apps/automated/src/globals.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare var __CI__;
|
||||
@@ -41,16 +41,18 @@ allTests['PLATFORM'] = platformTests;
|
||||
import * as fsTests from './file-system/file-system-tests';
|
||||
allTests['FILE-SYSTEM'] = fsTests;
|
||||
|
||||
// Disabled tests as they have external dependencies
|
||||
// TODO: find a way to run these tests locally, but don't run them on the CI as they are flaky
|
||||
// import * as httpTests from "./http/http-tests";
|
||||
// allTests["HTTP"] = httpTests;
|
||||
import * as httpTests from './http/http-tests';
|
||||
import * as xhrTests from './xhr/xhr-tests';
|
||||
import * as fetchTests from './fetch/fetch-tests';
|
||||
import * as timerTests from './timer/timer-tests';
|
||||
|
||||
// import * as xhrTests from "./xhr/xhr-tests";
|
||||
// allTests["XHR"] = xhrTests;
|
||||
|
||||
// import * as fetchTests from "./fetch/fetch-tests";
|
||||
// allTests["FETCH"] = fetchTests;
|
||||
// don't run these on CI as they are flaky
|
||||
if (!__CI__) {
|
||||
allTests['HTTP'] = httpTests;
|
||||
allTests['XHR'] = xhrTests;
|
||||
allTests['FETCH'] = fetchTests;
|
||||
allTests['TIMER'] = timerTests;
|
||||
}
|
||||
|
||||
import * as appSettingsTests from './application-settings/application-settings-tests';
|
||||
allTests['APPLICATION-SETTINGS'] = appSettingsTests;
|
||||
@@ -70,9 +72,6 @@ allTests['VIRTUAL-ARRAY'] = virtualArrayTests;
|
||||
import * as observableTests from './data/observable-tests';
|
||||
allTests['OBSERVABLE'] = observableTests;
|
||||
|
||||
import * as timerTests from './timer/timer-tests';
|
||||
allTests['TIMER'] = timerTests;
|
||||
|
||||
import * as animationFrameTests from './animation-frame/animation-frame';
|
||||
allTests['ANIMATION-FRAME'] = animationFrameTests;
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ export function test_setInterval_callbackCalledDuringPeriod(done) {
|
||||
export function test_setInterval_callbackCalledWithExtraArgs(done) {
|
||||
let counter: number = 0;
|
||||
const rnd: number = Math.random();
|
||||
const threshold = 100;
|
||||
|
||||
const start = TKUnit.time();
|
||||
const id = timer.setInterval(
|
||||
@@ -163,10 +164,10 @@ export function test_setInterval_callbackCalledWithExtraArgs(done) {
|
||||
if (counter === 4) {
|
||||
const end = TKUnit.time();
|
||||
timer.clearInterval(id);
|
||||
done(end - start > 250 ? new Error('setInterval too slow.') : null);
|
||||
done(end - start > 1000 + threshold ? new Error('setInterval too slow.') : null);
|
||||
}
|
||||
},
|
||||
50,
|
||||
250,
|
||||
rnd
|
||||
);
|
||||
}
|
||||
@@ -179,11 +180,11 @@ export function test_setInterval_callbackNotDelayedByBusyWork() {
|
||||
calls++;
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
TKUnit.wait(0.025);
|
||||
TKUnit.wait(0.125);
|
||||
}
|
||||
}, 50);
|
||||
}, 250);
|
||||
|
||||
TKUnit.wait(0.11);
|
||||
TKUnit.wait(0.55);
|
||||
timer.clearInterval(id);
|
||||
TKUnit.assertEqual(calls, 2, 'Callback should be called multiple times with busy wait');
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
import * as buttonModule from '@nativescript/core/ui/button';
|
||||
import * as colorModule from '@nativescript/core/color';
|
||||
import * as utilsModule from '@nativescript/core/utils/utils';
|
||||
import * as enums from '@nativescript/core/ui/enums';
|
||||
import { Color, Button, Utils, Enums } from '@nativescript/core';
|
||||
|
||||
export function getNativeText(button: buttonModule.Button): string {
|
||||
export function getNativeText(button: Button): string {
|
||||
return button.android.getText();
|
||||
}
|
||||
|
||||
export function getNativeTextWrap(button: buttonModule.Button): boolean {
|
||||
export function getNativeTextWrap(button: Button): boolean {
|
||||
return (<android.widget.Button>button.android).getLineCount() === 1;
|
||||
}
|
||||
|
||||
export function getNativeFontSize(button: buttonModule.Button): number {
|
||||
var density = utilsModule.layout.getDisplayDensity();
|
||||
export function getNativeFontSize(button: Button): number {
|
||||
let density = Utils.layout.getDisplayDensity();
|
||||
|
||||
return button.android.getTextSize() / density;
|
||||
}
|
||||
|
||||
export function getNativeColor(button: buttonModule.Button): colorModule.Color {
|
||||
return new colorModule.Color(button.android.getTextColors().getDefaultColor());
|
||||
export function getNativeColor(button: Button): Color {
|
||||
return new Color(button.android.getTextColors().getDefaultColor());
|
||||
}
|
||||
|
||||
export function getNativeBackgroundColor(button: buttonModule.Button): colorModule.Color {
|
||||
var bkg = <any>button.android.getBackground();
|
||||
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
|
||||
export function getNativeBackgroundColor(button: Button): Color {
|
||||
let bg = <any>button.android.getBackground();
|
||||
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new Color(bg.getBackgroundColor());
|
||||
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
|
||||
console.log(bg);
|
||||
return new Color(bg.getColor());
|
||||
} else {
|
||||
return new colorModule.Color(bkg.backgroundColor);
|
||||
return new Color(bg.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
export function getNativeTextAlignment(button: buttonModule.Button): string {
|
||||
var gravity = button.android.getGravity();
|
||||
export function getNativeTextAlignment(button: Button): string {
|
||||
let gravity = button.android.getGravity();
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
|
||||
return enums.TextAlignment.left;
|
||||
return Enums.TextAlignment.left;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
|
||||
return enums.TextAlignment.center;
|
||||
return Enums.TextAlignment.center;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
|
||||
return enums.TextAlignment.right;
|
||||
return Enums.TextAlignment.right;
|
||||
}
|
||||
|
||||
return 'unexpected value';
|
||||
}
|
||||
|
||||
export function performNativeClick(button: buttonModule.Button): void {
|
||||
export function performNativeClick(button: Button): void {
|
||||
button.android.performClick();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as enums from '@nativescript/core/ui/enums';
|
||||
import * as colorModule from '@nativescript/core/color';
|
||||
|
||||
export function getNativeTextAlignment(label: labelModule.Label): string {
|
||||
var gravity = label.android.getGravity();
|
||||
let gravity = label.android.getGravity();
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
|
||||
return enums.TextAlignment.left;
|
||||
@@ -21,10 +21,12 @@ export function getNativeTextAlignment(label: labelModule.Label): string {
|
||||
}
|
||||
|
||||
export function getNativeBackgroundColor(label: labelModule.Label): colorModule.Color {
|
||||
var bkg = <any>label.android.getBackground();
|
||||
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
|
||||
let bg = <any>label.android.getBackground();
|
||||
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new colorModule.Color(bg.getBackgroundColor());
|
||||
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
|
||||
return new colorModule.Color(bg.getColor());
|
||||
} else {
|
||||
return new colorModule.Color(bkg.backgroundColor);
|
||||
return new colorModule.Color(bg.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
normalColor = actualColors.getDefaultColor();
|
||||
TKUnit.assert(normalColor, 'Expected: ' + expColor + ', Actual: ' + normalColor);
|
||||
|
||||
const bkg = <org.nativescript.widgets.BorderDrawable>testLabel.android.getBackground();
|
||||
actualBackgroundColor = bkg.getBackgroundColor();
|
||||
const bg = testLabel.android.getBackground();
|
||||
actualBackgroundColor = bg['getBackgroundColor'] ? bg.getBackgroundColor() : bg.getColor();
|
||||
expBackgroundColor = android.graphics.Color.parseColor(backgroundColor);
|
||||
TKUnit.assertEqual(actualBackgroundColor, expBackgroundColor);
|
||||
} else {
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
import * as textFieldModule from '@nativescript/core/ui/text-field';
|
||||
import * as colorModule from '@nativescript/core/color';
|
||||
import * as utilsModule from '@nativescript/core/utils/utils';
|
||||
import * as enums from '@nativescript/core/ui/enums';
|
||||
import { TextField, Color, Utils, Enums } from '@nativescript/core';
|
||||
|
||||
export function getNativeText(textField: textFieldModule.TextField): string {
|
||||
export function getNativeText(textField: TextField): string {
|
||||
return textField.android.getText().toString();
|
||||
}
|
||||
|
||||
export function getNativeHint(textField: textFieldModule.TextField): string {
|
||||
export function getNativeHint(textField: TextField): string {
|
||||
return textField.android.getHint();
|
||||
}
|
||||
|
||||
export function getNativeSecure(textField: textFieldModule.TextField): boolean {
|
||||
var inputType = textField.android.getInputType();
|
||||
export function getNativeSecure(textField: TextField): boolean {
|
||||
let inputType = textField.android.getInputType();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export function getNativeFontSize(textField: textFieldModule.TextField): number {
|
||||
var density = utilsModule.layout.getDisplayDensity();
|
||||
export function getNativeFontSize(textField: TextField): number {
|
||||
let density = Utils.layout.getDisplayDensity();
|
||||
|
||||
return textField.android.getTextSize() / density;
|
||||
}
|
||||
|
||||
export function getNativeColor(textField: textFieldModule.TextField): colorModule.Color {
|
||||
return new colorModule.Color(textField.android.getTextColors().getDefaultColor());
|
||||
export function getNativeColor(textField: TextField): Color {
|
||||
return new Color(textField.android.getTextColors().getDefaultColor());
|
||||
}
|
||||
|
||||
export function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color {
|
||||
return new colorModule.Color(textField.android.getHintTextColors().getDefaultColor());
|
||||
export function getNativePlaceholderColor(textField: TextField): Color {
|
||||
return new Color(textField.android.getHintTextColors().getDefaultColor());
|
||||
}
|
||||
|
||||
export function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color {
|
||||
var bkg = <any>textField.android.getBackground();
|
||||
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
|
||||
export function getNativeBackgroundColor(textField: TextField): Color {
|
||||
let bg = <any>textField.android.getBackground();
|
||||
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new Color(bg.getBackgroundColor());
|
||||
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
|
||||
console.log(bg);
|
||||
return new Color(bg.getColor());
|
||||
} else {
|
||||
return new colorModule.Color(bkg.backgroundColor);
|
||||
return new Color(bg.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
export function getNativeTextAlignment(textField: textFieldModule.TextField): string {
|
||||
export function getNativeTextAlignment(textField: TextField): string {
|
||||
var gravity = textField.android.getGravity();
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
|
||||
return enums.TextAlignment.left;
|
||||
return Enums.TextAlignment.left;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
|
||||
return enums.TextAlignment.center;
|
||||
return Enums.TextAlignment.center;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
|
||||
return enums.TextAlignment.right;
|
||||
return Enums.TextAlignment.right;
|
||||
}
|
||||
|
||||
return 'unexpected value';
|
||||
}
|
||||
|
||||
export function getNativeFocus(textField: textFieldModule.TextField): boolean {
|
||||
export function getNativeFocus(textField: TextField): boolean {
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
export function typeTextNatively(textField: textFieldModule.TextField, text: string): void {
|
||||
export function typeTextNatively(textField: TextField, text: string): void {
|
||||
textField.android.requestFocus();
|
||||
textField.android.setText(text);
|
||||
textField.android.clearFocus();
|
||||
}
|
||||
|
||||
export function typeTextNativelyWithReturn(textField: textFieldModule.TextField, text: string): void {
|
||||
export function typeTextNativelyWithReturn(textField: TextField, text: string): void {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import * as textViewModule from '@nativescript/core/ui/text-view';
|
||||
import * as colorModule from '@nativescript/core/color';
|
||||
import * as utilsModule from '@nativescript/core/utils/utils';
|
||||
import * as enums from '@nativescript/core/ui/enums';
|
||||
import { TextView, Color, Utils, Enums } from '@nativescript/core';
|
||||
|
||||
export function getNativeText(textView: textViewModule.TextView): string {
|
||||
export function getNativeText(textView: TextView): string {
|
||||
return textView.android.getText().toString();
|
||||
}
|
||||
|
||||
export function getNativeEditable(textView: textViewModule.TextView): boolean {
|
||||
export function getNativeEditable(textView: TextView): boolean {
|
||||
if (textView.android.getKeyListener()) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -15,53 +12,55 @@ export function getNativeEditable(textView: textViewModule.TextView): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function getNativeHint(textView: textViewModule.TextView): string {
|
||||
export function getNativeHint(textView: TextView): string {
|
||||
return textView.android.getHint();
|
||||
}
|
||||
|
||||
export function getNativeFontSize(textView: textViewModule.TextView): number {
|
||||
var density = utilsModule.layout.getDisplayDensity();
|
||||
export function getNativeFontSize(textView: TextView): number {
|
||||
let density = Utils.layout.getDisplayDensity();
|
||||
|
||||
return textView.android.getTextSize() / density;
|
||||
}
|
||||
|
||||
export function getNativeColor(textView: textViewModule.TextView): colorModule.Color {
|
||||
return new colorModule.Color(textView.android.getTextColors().getDefaultColor());
|
||||
export function getNativeColor(textView: TextView): Color {
|
||||
return new Color(textView.android.getTextColors().getDefaultColor());
|
||||
}
|
||||
|
||||
export function getNativeBackgroundColor(textView: textViewModule.TextView): colorModule.Color {
|
||||
var bkg = <any>textView.android.getBackground();
|
||||
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
|
||||
export function getNativeBackgroundColor(textView: TextView): Color {
|
||||
let bg = <any>textView.android.getBackground();
|
||||
if (bg instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
return new Color(bg.getBackgroundColor());
|
||||
} else if (bg instanceof android.graphics.drawable.ColorDrawable) {
|
||||
return new Color(bg.getColor());
|
||||
} else {
|
||||
return new colorModule.Color(bkg.backgroundColor);
|
||||
return new Color(bg.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
export function getNativeTextAlignment(textView: textViewModule.TextView): string {
|
||||
var gravity = textView.android.getGravity();
|
||||
export function getNativeTextAlignment(textView: TextView): string {
|
||||
let gravity = textView.android.getGravity();
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
|
||||
return enums.TextAlignment.left;
|
||||
return Enums.TextAlignment.left;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
|
||||
return enums.TextAlignment.center;
|
||||
return Enums.TextAlignment.center;
|
||||
}
|
||||
|
||||
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
|
||||
return enums.TextAlignment.right;
|
||||
return Enums.TextAlignment.right;
|
||||
}
|
||||
|
||||
return 'unexpected value';
|
||||
}
|
||||
|
||||
export function typeTextNatively(textView: textViewModule.TextView, text: string): void {
|
||||
export function typeTextNatively(textView: TextView, text: string): void {
|
||||
textView.android.requestFocus();
|
||||
textView.android.setText(text);
|
||||
textView.android.clearFocus();
|
||||
}
|
||||
|
||||
export function getNativeMaxLines(textView: textViewModule.TextView): number {
|
||||
export function getNativeMaxLines(textView: TextView): number {
|
||||
return textView.android.getMaxLines();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user