mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Page tests fix.
This commit is contained in:
@ -81,7 +81,7 @@ allTests["SLIDER"] = require("./ui/slider/slider-tests");
|
|||||||
allTests["SWITCH"] = require("./ui/switch/switch-tests");
|
allTests["SWITCH"] = require("./ui/switch/switch-tests");
|
||||||
allTests["PROGRESS"] = require("./ui/progress/progress-tests");
|
allTests["PROGRESS"] = require("./ui/progress/progress-tests");
|
||||||
allTests["PLACEHOLDER"] = require("./ui/placeholder/placeholder-tests");
|
allTests["PLACEHOLDER"] = require("./ui/placeholder/placeholder-tests");
|
||||||
// allTests["PAGE"] = require("./ui/page/page-tests");
|
allTests["PAGE"] = require("./ui/page/page-tests");
|
||||||
allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests");
|
allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests");
|
||||||
allTests["ACTIVITY-INDICATOR"] = require("./ui/activity-indicator/activity-indicator-tests");
|
allTests["ACTIVITY-INDICATOR"] = require("./ui/activity-indicator/activity-indicator-tests");
|
||||||
allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests");
|
allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests");
|
||||||
|
@ -23,6 +23,7 @@ import { EventData } from "data/observable";
|
|||||||
import { PercentLength } from "ui/core/view";
|
import { PercentLength } from "ui/core/view";
|
||||||
import * as platform from "platform";
|
import * as platform from "platform";
|
||||||
import {unsetValue} from "ui/core/view";
|
import {unsetValue} from "ui/core/view";
|
||||||
|
import { Color } from "color";
|
||||||
|
|
||||||
export function addLabelToPage(page: Page, text?: string) {
|
export function addLabelToPage(page: Page, text?: string) {
|
||||||
let label = new Label();
|
let label = new Label();
|
||||||
@ -122,7 +123,7 @@ export function test_NavigateToNewPage() {
|
|||||||
|
|
||||||
TKUnit.waitUntilReady(() => { return topFrame.currentPage !== null && topFrame.currentPage === currentPage });
|
TKUnit.waitUntilReady(() => { return topFrame.currentPage !== null && topFrame.currentPage === currentPage });
|
||||||
TKUnit.assert(testPage.parent === undefined, "Page.parent should become undefined after navigating back");
|
TKUnit.assert(testPage.parent === undefined, "Page.parent should become undefined after navigating back");
|
||||||
TKUnit.assert(testPage._context === undefined, "Page._context should become undefined after navigating back");
|
TKUnit.assert(testPage._context === null, "Page._context should become undefined after navigating back");
|
||||||
TKUnit.assert(testPage.isLoaded === false, "Page.isLoaded should become false after navigating back");
|
TKUnit.assert(testPage.isLoaded === false, "Page.isLoaded should become false after navigating back");
|
||||||
TKUnit.assert(testPage.frame === undefined, "Page.frame should become undefined after navigating back");
|
TKUnit.assert(testPage.frame === undefined, "Page.frame should become undefined after navigating back");
|
||||||
TKUnit.assert(testPage._isAddedToNativeVisualTree === false, "Page._isAddedToNativeVisualTree should become false after navigating back");
|
TKUnit.assert(testPage._isAddedToNativeVisualTree === false, "Page._isAddedToNativeVisualTree should become false after navigating back");
|
||||||
@ -376,7 +377,12 @@ export function test_page_backgroundColor_is_white() {
|
|||||||
page.id = "page_test_page_backgroundColor_is_white";
|
page.id = "page_test_page_backgroundColor_is_white";
|
||||||
let factory = () => page;
|
let factory = () => page;
|
||||||
helper.navigate(factory);
|
helper.navigate(factory);
|
||||||
TKUnit.assertEqual(page.style.backgroundColor.hex.toLowerCase(), "#ffffff", "page background-color");
|
let whiteColor = new Color("white");
|
||||||
|
if (platform.isIOS) {
|
||||||
|
TKUnit.assertTrue(whiteColor.ios.CGColor.isEqual(page.nativeView.backgroundColor.CGColor), "page default backgroundColor should be white");
|
||||||
|
} else {
|
||||||
|
TKUnit.assertEqual(page.nativeView.getBackground().getColor(), whiteColor.android, "page default backgroundColor should be white");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_WhenPageIsLoadedFrameCurrentPageIsNotYetTheSameAsThePage() {
|
export function test_WhenPageIsLoadedFrameCurrentPageIsNotYetTheSameAsThePage() {
|
||||||
|
@ -48,7 +48,7 @@ export function test_NavigateToNewPage_WithAndroidCache() {
|
|||||||
TKUnit.assert(testPage.frame === undefined, "Page.frame should become undefined after navigating back");
|
TKUnit.assert(testPage.frame === undefined, "Page.frame should become undefined after navigating back");
|
||||||
TKUnit.assert(testPage._isAddedToNativeVisualTree === false, "Page._isAddedToNativeVisualTree should become false after navigating back");
|
TKUnit.assert(testPage._isAddedToNativeVisualTree === false, "Page._isAddedToNativeVisualTree should become false after navigating back");
|
||||||
|
|
||||||
TKUnit.assert(label._context === undefined, "InnerControl._context should not be set after navigate back.");
|
TKUnit.assert(label._context === null, "InnerControl._context should not be set after navigate back.");
|
||||||
TKUnit.assert(label.android === undefined, "InnerControl.android should not be set after navigate back.");
|
TKUnit.assert(label.android === undefined, "InnerControl.android should not be set after navigate back.");
|
||||||
TKUnit.assert(label._nativeView === undefined, "InnerControl._nativeView hould not be set after navigate back.");
|
TKUnit.assert(label._nativeView === undefined, "InnerControl._nativeView hould not be set after navigate back.");
|
||||||
TKUnit.assert(label.isLoaded === false, "InnerControl.isLoaded should become false after navigating back");
|
TKUnit.assert(label.isLoaded === false, "InnerControl.isLoaded should become false after navigating back");
|
||||||
@ -69,7 +69,7 @@ export var test_NavigateToNewPage_InnerControl = function () {
|
|||||||
|
|
||||||
var label = <LabelModule.Label>testPage.content;
|
var label = <LabelModule.Label>testPage.content;
|
||||||
|
|
||||||
TKUnit.assert(label._context === undefined, "InnerControl._context should be undefined after navigate back.");
|
TKUnit.assert(label._context === null, "InnerControl._context should be undefined after navigate back.");
|
||||||
TKUnit.assert(label.android === undefined, "InnerControl.android should be undefined after navigate back.");
|
TKUnit.assert(label.android === undefined, "InnerControl.android should be undefined after navigate back.");
|
||||||
TKUnit.assert(label._nativeView === undefined, "InnerControl._nativeView should be undefined after navigate back.");
|
TKUnit.assert(label._nativeView === undefined, "InnerControl._nativeView should be undefined after navigate back.");
|
||||||
TKUnit.assert(label.isLoaded === false, "InnerControl.isLoaded should become false after navigating back");
|
TKUnit.assert(label.isLoaded === false, "InnerControl.isLoaded should become false after navigating back");
|
||||||
|
@ -23,7 +23,7 @@ export function test_NavigateToNewPage_InnerControl() {
|
|||||||
|
|
||||||
helper.goBack();
|
helper.goBack();
|
||||||
|
|
||||||
TKUnit.assertEqual(label._context, undefined, "label._context should be undefined after navigate back.");
|
TKUnit.assertEqual(label._context, null, "label._context should be undefined after navigate back.");
|
||||||
TKUnit.assertEqual(label.android, undefined, "label.android should be undefined after navigate back.");
|
TKUnit.assertEqual(label.android, undefined, "label.android should be undefined after navigate back.");
|
||||||
TKUnit.assertFalse(label.isLoaded, "label.isLoaded should become false after navigating back");
|
TKUnit.assertFalse(label.isLoaded, "label.isLoaded should become false after navigating back");
|
||||||
}
|
}
|
||||||
|
@ -1485,7 +1485,11 @@ function convertToTransform(value: string): [CssProperty<any, any>, any][] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Background properties.
|
// Background properties.
|
||||||
export const backgroundInternalProperty = new CssProperty<Style, Background>({ name: "backgroundInternal", cssName: "_backgroundInternal", defaultValue: Background.default });
|
export const backgroundInternalProperty = new CssProperty<Style, Background>({
|
||||||
|
name: "backgroundInternal",
|
||||||
|
cssName: "_backgroundInternal",
|
||||||
|
defaultValue: Background.default
|
||||||
|
});
|
||||||
backgroundInternalProperty.register(Style);
|
backgroundInternalProperty.register(Style);
|
||||||
|
|
||||||
let pattern: RegExp = /url\(('|")(.*?)\1\)/;
|
let pattern: RegExp = /url\(('|")(.*?)\1\)/;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Page as PageDefinition, NavigatedData, ShownModallyData } from "ui/page";
|
import { Page as PageDefinition, NavigatedData, ShownModallyData } from "ui/page";
|
||||||
import {
|
import {
|
||||||
ContentView, View, backgroundColorProperty,
|
ContentView, View, eachDescendant, Property, Color, isIOS, booleanConverter, resetCSSProperties
|
||||||
eachDescendant, Property, Color, isIOS, booleanConverter, resetCSSProperties
|
|
||||||
} from "ui/content-view";
|
} from "ui/content-view";
|
||||||
import { Frame, topmost as topmostFrame, resolvePageFromEntry } from "ui/frame";
|
import { Frame, topmost as topmostFrame, resolvePageFromEntry } from "ui/frame";
|
||||||
import { ActionBar } from "ui/action-bar";
|
import { ActionBar } from "ui/action-bar";
|
||||||
@ -41,9 +40,6 @@ export class PageBase extends ContentView implements PageDefinition {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.actionBar = new ActionBar();
|
this.actionBar = new ActionBar();
|
||||||
|
|
||||||
// The default style of the page should be white background
|
|
||||||
this.style[backgroundColorProperty.cssName] = new Color("white");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public onLoaded() {
|
// public onLoaded() {
|
||||||
|
@ -92,10 +92,15 @@ export class Page extends PageBase {
|
|||||||
return this._grid;
|
return this._grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get nativeView(): android.view.ViewGroup {
|
||||||
|
return this._grid;
|
||||||
|
}
|
||||||
|
|
||||||
public _createNativeView() {
|
public _createNativeView() {
|
||||||
this._grid = new org.nativescript.widgets.GridLayout(this._context);
|
this._grid = new org.nativescript.widgets.GridLayout(this._context);
|
||||||
this._grid.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));
|
this._grid.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));
|
||||||
this._grid.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star));
|
this._grid.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star));
|
||||||
|
this.nativeView.setBackgroundColor(new Color("white").android);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean {
|
public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean {
|
||||||
@ -126,6 +131,7 @@ export class Page extends PageBase {
|
|||||||
|
|
||||||
if (!skipDetached) {
|
if (!skipDetached) {
|
||||||
super._tearDownUI();
|
super._tearDownUI();
|
||||||
|
this._isAddedToNativeVisualTree = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
} from "./page-common";
|
} from "./page-common";
|
||||||
import { ios as iosApp } from "application";
|
import { ios as iosApp } from "application";
|
||||||
import { device } from "platform";
|
import { device } from "platform";
|
||||||
|
import { Color } from "color";
|
||||||
import * as uiUtils from "ui/utils";
|
import * as uiUtils from "ui/utils";
|
||||||
|
|
||||||
export * from "./page-common";
|
export * from "./page-common";
|
||||||
@ -115,9 +116,9 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
let widthSpec = layout.makeMeasureSpec(width, mode);
|
let widthSpec = layout.makeMeasureSpec(width, mode);
|
||||||
let heightSpec = layout.makeMeasureSpec(height, mode);
|
let heightSpec = layout.makeMeasureSpec(height, mode);
|
||||||
|
|
||||||
View.measureChild(null, owner, widthSpec, heightSpec);
|
View.measureChild(owner._modalParent, owner, widthSpec, heightSpec);
|
||||||
let top = ((backgroundSpanUnderStatusBar && isFullScreen) || ios.MajorVersion < 8 || !isFullScreen) ? 0 : statusBarHeight;
|
let top = ((backgroundSpanUnderStatusBar && isFullScreen) || ios.MajorVersion < 8 || !isFullScreen) ? 0 : statusBarHeight;
|
||||||
View.layoutChild(null, owner, 0, top, width, bottom);
|
View.layoutChild(owner._modalParent, owner, 0, top, width, bottom);
|
||||||
|
|
||||||
if (ios.MajorVersion < 8) {
|
if (ios.MajorVersion < 8) {
|
||||||
if (!backgroundSpanUnderStatusBar && (!isTablet || isFullScreen)) {
|
if (!backgroundSpanUnderStatusBar && (!isTablet || isFullScreen)) {
|
||||||
@ -339,6 +340,7 @@ export class Page extends PageBase {
|
|||||||
super();
|
super();
|
||||||
this._ios = UIViewControllerImpl.initWithOwner(new WeakRef(this));
|
this._ios = UIViewControllerImpl.initWithOwner(new WeakRef(this));
|
||||||
this.nativeView = this._ios.view;
|
this.nativeView = this._ios.view;
|
||||||
|
this.nativeView.backgroundColor = new Color("white").ios;
|
||||||
}
|
}
|
||||||
|
|
||||||
public requestLayout(): void {
|
public requestLayout(): void {
|
||||||
@ -582,6 +584,9 @@ export class Page extends PageBase {
|
|||||||
}
|
}
|
||||||
set [actionBarHiddenProperty.native](value: boolean) {
|
set [actionBarHiddenProperty.native](value: boolean) {
|
||||||
this._updateEnableSwipeBackNavigation(value);
|
this._updateEnableSwipeBackNavigation(value);
|
||||||
|
if (this.isLoaded) {
|
||||||
|
this.updateActionBar(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get [statusBarStyleProperty.native](): UIBarStyle {
|
get [statusBarStyleProperty.native](): UIBarStyle {
|
||||||
|
Reference in New Issue
Block a user