mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #620 from NathanaelA/createPage_autoload_page_css
frame-common.ts is missing the code to automagically load the page.css
This commit is contained in:
@ -247,7 +247,7 @@ export function test_LoadPageFromModule() {
|
|||||||
try {
|
try {
|
||||||
var topFrame = FrameModule.topmost();
|
var topFrame = FrameModule.topmost();
|
||||||
TKUnit.assert(topFrame.currentPage.content instanceof LabelModule.Label, "Content of the test page should be a Label created within test-page-module.");
|
TKUnit.assert(topFrame.currentPage.content instanceof LabelModule.Label, "Content of the test page should be a Label created within test-page-module.");
|
||||||
var testLabel = <LabelModule.Label>topFrame.currentPage.content
|
var testLabel = <LabelModule.Label>topFrame.currentPage.content;
|
||||||
TKUnit.assert(testLabel.text === "Label created within a page module.");
|
TKUnit.assert(testLabel.text === "Label created within a page module.");
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@ -255,6 +255,35 @@ export function test_LoadPageFromModule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_LoadPageFromDeclarativeWithCSS() {
|
||||||
|
helper.navigateToModule("ui/page/test-page-declarative-css");
|
||||||
|
try {
|
||||||
|
var topFrame = FrameModule.topmost();
|
||||||
|
TKUnit.assert(topFrame.currentPage.content instanceof LabelModule.Label, "Content of the test page should be a Label created within test-page-module-css.");
|
||||||
|
var testLabel = <LabelModule.Label>topFrame.currentPage.content;
|
||||||
|
TKUnit.assert(testLabel.text === "Label created within a page declarative file with css.");
|
||||||
|
TKUnit.assert(testLabel.style.backgroundColor.hex === "#ff00ff00", "Expected: #ff00ff00, Actual: " + testLabel.style.backgroundColor.hex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
helper.goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_LoadPageFromModuleWithCSS() {
|
||||||
|
helper.navigateToModule("ui/page/test-page-module-css");
|
||||||
|
try {
|
||||||
|
var topFrame = FrameModule.topmost();
|
||||||
|
TKUnit.assert(topFrame.currentPage.content instanceof LabelModule.Label, "Content of the test page should be a Label created within test-page-module-css.");
|
||||||
|
var testLabel = <LabelModule.Label>topFrame.currentPage.content;
|
||||||
|
TKUnit.assert(testLabel.text === "Label created within a page module css.");
|
||||||
|
TKUnit.assert(testLabel.style.backgroundColor.hex === "#ff00ff00", "Expected: #ff00ff00, Actual: " + testLabel.style.backgroundColor.hex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
helper.goBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function test_NavigateToPageCreatedWithNavigationEntry() {
|
export function test_NavigateToPageCreatedWithNavigationEntry() {
|
||||||
var expectedText = "Label created with a NavigationEntry";
|
var expectedText = "Label created with a NavigationEntry";
|
||||||
var testPage: PageModule.Page;
|
var testPage: PageModule.Page;
|
||||||
|
3
apps/tests/ui/page/test-page-declarative-css.css
Normal file
3
apps/tests/ui/page/test-page-declarative-css.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Label {
|
||||||
|
background-color: #ff00ff00;
|
||||||
|
}
|
3
apps/tests/ui/page/test-page-declarative-css.xml
Normal file
3
apps/tests/ui/page/test-page-declarative-css.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<Page>
|
||||||
|
<Label text="Label created within a page declarative file with css."/>
|
||||||
|
</Page>
|
3
apps/tests/ui/page/test-page-module-css.css
Normal file
3
apps/tests/ui/page/test-page-module-css.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Label {
|
||||||
|
background-color: #ff00ff00;
|
||||||
|
}
|
19
apps/tests/ui/page/test-page-module-css.ts
Normal file
19
apps/tests/ui/page/test-page-module-css.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import PageModule = require("ui/page");
|
||||||
|
import LabelModule = require("ui/label");
|
||||||
|
|
||||||
|
export class TestPageModule extends PageModule.Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
var label = new LabelModule.Label();
|
||||||
|
label.text = "Label created within a page module css.";
|
||||||
|
|
||||||
|
this.content = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPage() {
|
||||||
|
return new TestPageModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
//export var Page = new TestPageModule();
|
@ -65,6 +65,12 @@ export function resolvePageFromEntry(entry: definition.NavigationEntry): pages.P
|
|||||||
if (!(page && page instanceof pages.Page)) {
|
if (!(page && page instanceof pages.Page)) {
|
||||||
throw new Error("Failed to load Page from entry.moduleName: " + entry.moduleName);
|
throw new Error("Failed to load Page from entry.moduleName: " + entry.moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Possible CSS file path.
|
||||||
|
var cssFileName = fileResolverModule.resolveFileName(moduleNamePath, "css");
|
||||||
|
if (cssFileName) {
|
||||||
|
page.addCssFile(cssFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
@ -83,12 +89,6 @@ function pageFromBuilder(moduleNamePath: string, moduleExports: any): pages.Page
|
|||||||
element = builder.load(fileName, moduleExports);
|
element = builder.load(fileName, moduleExports);
|
||||||
if (element instanceof pages.Page) {
|
if (element instanceof pages.Page) {
|
||||||
page = <pages.Page>element;
|
page = <pages.Page>element;
|
||||||
|
|
||||||
// Possible CSS file path.
|
|
||||||
var cssFileName = fileResolverModule.resolveFileName(moduleNamePath, "css");
|
|
||||||
if (cssFileName) {
|
|
||||||
page.addCssFile(cssFileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user