Page events

This commit is contained in:
vakrilov
2015-05-18 15:57:53 +03:00
parent 8b4807ca78
commit fe66104595
8 changed files with 88 additions and 34 deletions

View File

@@ -39,7 +39,7 @@ export class ControlsPage extends pagesModule.Page implements definition.Control
this.content = this._mainLayout;
}
public onNavigatedTo(context: any) {
public onNavigatedTo() {
trace.write("Creating " + this._count + " controls...", trace.categories.Test, trace.messageType.info);
this._infoLabel.text = "Creating " + this._count + " controls...";
var startTime = new Date().getMilliseconds();

View File

@@ -23,6 +23,7 @@ function isRunningOnEmulator(): boolean {
}
export var allTests = {};
allTests["APPLICATION"] = require("./application-tests");
allTests["DOCKLAYOUT"] = require("./layouts/dock-layout-tests");
allTests["WRAPLAYOUT"] = require("./layouts/wrap-layout-tests");
allTests["ABSOLUTELAYOUT"] = require("./layouts/absolute-layout-tests");
@@ -31,7 +32,6 @@ allTests["STACKLAYOUT"] = require("./layouts/stack-layout-tests");
allTests["PLATFORM"] = require("./platform-tests");
allTests["STYLE-PROPERTIES"] = require("./ui/style/style-properties-tests");
allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
allTests["APPLICATION"] = require("./application-tests");
allTests["FILE SYSTEM"] = require("./file-system-tests");
allTests["HTTP"] = require("./http-tests");
allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");

View File

@@ -198,9 +198,9 @@ export function buildUIWithWeakRefAndInteract<T extends view.View>(createFunc: (
}
}
export function navigate(pageFactory: () => page.Page) {
export function navigate(pageFactory: () => page.Page, navigationContext?: any) {
var currentPage = frame.topmost().currentPage;
frame.topmost().navigate({ create: pageFactory, animated: false });
frame.topmost().navigate({ create: pageFactory, animated: false, context: navigationContext });
TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; });
}

View File

@@ -153,10 +153,10 @@ export function test_PageLoaded_is_called_once() {
var handler = function (data) {
loaded++;
}
var pageFactory = function (): PageModule.Page {
page1 = new PageModule.Page();
addLabelToPage(page1, "Page 1");
addLabelToPage(page1, "Page 1");
return page1;
};
@@ -225,29 +225,36 @@ export var test_NavigateToNewPage = function () {
export var test_PageNavigation_EventSequence = function () {
var testPage: PageModule.Page;
var context = { property: "this is the context" };
var eventSequence = [];
var pageFactory = function () {
testPage = new PageModule.Page();
addLabelToPage(testPage);
testPage.onNavigatingFrom = function () {
eventSequence.push("onNavigatingFrom");
}
testPage.onNavigatedFrom = function () {
eventSequence.push("onNavigatedFrom");
}
testPage.onNavigatingTo = function () {
testPage.on(PageModule.Page.navigatingToEvent, function (data: PageModule.NavigatedData) {
eventSequence.push("onNavigatingTo");
}
TKUnit.assertEqual(data.context, context, "onNavigatingTo: navigationContext");
});
testPage.onNavigatedTo = function () {
testPage.on(PageModule.Page.navigatedToEvent, function (data: PageModule.NavigatedData) {
eventSequence.push("onNavigatedTo");
}
TKUnit.assertEqual(data.context, context, "onNavigatedTo : navigationContext");
});
testPage.on(PageModule.Page.navigatingFromEvent, function (data: PageModule.NavigatedData) {
eventSequence.push("onNavigatingFrom");
TKUnit.assertEqual(data.context, context, "onNavigatingFrom: navigationContext");
});
testPage.on(PageModule.Page.navigatedFromEvent, function (data: PageModule.NavigatedData) {
eventSequence.push("onNavigatedFrom");
TKUnit.assertEqual(data.context, context, "onNavigatedFrom: navigationContext");
});
return testPage;
};
helper.navigate(pageFactory);
helper.navigate(pageFactory, context);
helper.goBack();
var expectedEventSequence = ["onNavigatingTo", "onNavigatedTo", "onNavigatingFrom", "onNavigatedFrom"];
@@ -263,9 +270,9 @@ export var test_NavigateTo_WithContext = function () {
var testPage: PageModule.Page;
var pageFactory = function (): PageModule.Page {
testPage = new PageModule.Page();
testPage.onNavigatedTo = function (context) {
testPage.on(PageModule.Page.navigatedToEvent, function () {
////console.log(JSON.stringify(context));
}
});
return testPage;
};
var navEntry = {
@@ -362,7 +369,7 @@ export var test_cssShouldBeAppliedToAllNestedElements = function () {
};
helper.navigate(pageFactory);
var expectedText = "Some text";
try {
TKUnit.assert(label.style.backgroundColor.hex === "#ff00ff00", "Expected: #ff00ff00, Actual: " + label.style.backgroundColor.hex);