mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00

* chore: move tns-core-modules to nativescript-core * chore: preparing compat generate script * chore: add missing definitions * chore: no need for http-request to be private * chore: packages chore * test: generate tests for tns-core-modules * chore: add anroid module for consistency * chore: add .npmignore * chore: added privateModulesWhitelist * chore(webpack): added bundle-entry-points * chore: scripts * chore: tests changed to use @ns/core * test: add scoped-packages test project * test: fix types * test: update test project * chore: build scripts * chore: update build script * chore: npm scripts cleanup * chore: make the compat pgk work with old wp config * test: generate diff friendly tests * chore: create barrel exports * chore: move files after rebase * chore: typedoc config * chore: compat mode * chore: review of barrels * chore: remove tns-core-modules import after rebase * chore: dev workflow setup * chore: update developer-workflow * docs: experiment with API extractor * chore: api-extractor and barrel exports * chore: api-extractor configs * chore: generate d.ts rollup with api-extractor * refactor: move methods inside Frame * chore: fic tests to use Frame static methods * refactor: create Builder class * refactor: use Builder class in tests * refactor: include Style in ui barrel * chore: separate compat build script * chore: fix tslint errors * chore: update NATIVESCRIPT_CORE_ARGS * chore: fix compat pack * chore: fix ui-test-app build with linked modules * chore: Application, ApplicationSettings, Connectivity and Http * chore: export Trace, Profiling and Utils * refactor: Static create methods for ImageSource * chore: fix deprecated usages of ImageSource * chore: move Span and FormattedString to ui * chore: add events-args and ImageSource to index files * chore: check for CLI >= 6.2 when building for IOS * chore: update travis build * chore: copy Pod file to compat package * chore: update error msg ui-tests-app * refactor: Apply suggestions from code review Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com> * chore: typings and refs * chore: add missing d.ts files for public API * chore: adress code review FB * chore: update api-report * chore: dev-workflow for other apps * chore: api update * chore: update api-report
92 lines
3.2 KiB
TypeScript
92 lines
3.2 KiB
TypeScript
import { View } from "@nativescript/core/ui/core/view";
|
|
import { Button } from "@nativescript/core/ui/button";
|
|
import { GridLayout } from "@nativescript/core/ui/layouts/grid-layout";
|
|
import { Color } from "@nativescript/core/color";
|
|
import * as helper from "../../ui-helper";
|
|
import * as TKUnit from "../../tk-unit";
|
|
import * as utils from "@nativescript/core/utils/utils";
|
|
|
|
export * from "./view-tests-common";
|
|
|
|
class MyGrid extends GridLayout {
|
|
public backgroundDrawCount: number = 0;
|
|
|
|
_redrawNativeBackground(background: any) {
|
|
this.backgroundDrawCount++;
|
|
super._redrawNativeBackground(background);
|
|
}
|
|
}
|
|
|
|
export function getUniformNativeBorderWidth(v: View): number {
|
|
return utils.layout.toDevicePixels((<UIView>v.ios).layer.borderWidth);
|
|
}
|
|
|
|
export function checkUniformNativeBorderColor(v: View): boolean {
|
|
if (v.borderColor instanceof Color) {
|
|
return (<UIView>v.ios).layer.borderColor === (<Color>v.borderColor).ios.CGColor;
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
|
|
export function getUniformNativeCornerRadius(v: View): number {
|
|
return utils.layout.toDevicePixels((<UIView>v.ios).layer.cornerRadius);
|
|
}
|
|
|
|
export function checkNativeBackgroundColor(v: View): boolean {
|
|
if (v.ios instanceof UILabel) {
|
|
var cgColor1 = (<UILabel>v.ios).layer.backgroundColor;
|
|
var cgColor2 = (<UIColor>(<Color>v.backgroundColor).ios).CGColor;
|
|
|
|
return v.backgroundColor && !!CGColorEqualToColor(cgColor1, cgColor2);
|
|
}
|
|
|
|
return v.backgroundColor && (<UIView>v.ios).backgroundColor.isEqual((<Color>v.backgroundColor).ios);
|
|
}
|
|
|
|
export function checkNativeBackgroundImage(v: View): boolean {
|
|
return (<UIView>v.ios).backgroundColor !== undefined;
|
|
}
|
|
|
|
export function testBackgroundInternalChangedOnceOnResize() {
|
|
|
|
let root = helper.getCurrentPage();
|
|
let layout = new MyGrid();
|
|
layout.className = "myClass";
|
|
layout.backgroundColor = new Color(255, 255, 0, 0);
|
|
|
|
root.css = ".myClass { background-image: url('~/assets/logo.png') }";
|
|
root.content = layout;
|
|
|
|
function trackCount() {
|
|
let result = layout.backgroundDrawCount;
|
|
layout.backgroundDrawCount = 0;
|
|
|
|
return result;
|
|
}
|
|
|
|
trackCount();
|
|
layout.requestLayout();
|
|
layout.layout(0, 0, 200, 200);
|
|
|
|
TKUnit.assertEqual(trackCount(), 1, "Expected background to be re-applied at most once when the view is layed-out on 0 0 200 200.");
|
|
|
|
layout.requestLayout();
|
|
layout.layout(50, 50, 250, 250);
|
|
|
|
TKUnit.assertEqual(trackCount(), 0, "Expected background to NOT change when view is layed-out from 0 0 200 200 to 50 50 250 250.");
|
|
|
|
layout.requestLayout();
|
|
layout.layout(0, 0, 250, 250);
|
|
|
|
TKUnit.assertEqual(trackCount(), 1, "Expected background to be re-applied at most once when the view is layed-out from 50 50 250 250 to 0 0 250 250.");
|
|
}
|
|
|
|
export function test_automation_text_set_to_native() {
|
|
var newButton = new Button();
|
|
newButton.automationText = "Button1";
|
|
helper.getCurrentPage().content = newButton;
|
|
TKUnit.assertEqual((<UIView>newButton.ios).accessibilityIdentifier, "Button1", "accessibilityIdentifier not set to native view.");
|
|
TKUnit.assertEqual((<UIView>newButton.ios).accessibilityLabel, "Button1", "accessibilityIdentifier not set to native view.");
|
|
}
|