mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Update logic for opening pages in ui-tests-app.
This commit is contained in:
@ -1,41 +1,42 @@
|
||||
import pages = require("ui/page");
|
||||
import frame = require("ui/frame");
|
||||
import button = require("ui/button");
|
||||
import text = require("ui/text-view");
|
||||
import button = require("ui/button");
|
||||
import dialogs = require("ui/dialogs");
|
||||
import frame = require("ui/frame");
|
||||
import gridModule = require("ui/layouts/grid-layout");
|
||||
import pages = require("ui/page");
|
||||
import text = require("ui/text-view");
|
||||
import fs = require("file-system");
|
||||
import trace = require("trace");
|
||||
|
||||
trace.enable();
|
||||
trace.setCategories(trace.categories.Test);
|
||||
|
||||
var list: string[] = ["pages", "layouts", "modal-view"];
|
||||
|
||||
export function createPage() {
|
||||
var txtInput = new text.TextView();
|
||||
var btn = new button.Button();
|
||||
btn.text = "Run";
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
|
||||
var fileName = fs.path.join(__dirname, "pages", txtInput.text);
|
||||
if ((fs.File.exists(fileName + ".xml") || (fs.File.exists(fileName + ".js")))) {
|
||||
frame.topmost().navigate("pages/" + txtInput.text);
|
||||
var filePath, fileName, i = 0;
|
||||
while (i < list.length) {
|
||||
filePath = fs.path.join(__dirname, list[i], txtInput.text);
|
||||
if ((fs.File.exists(filePath + ".xml") || (fs.File.exists(filePath + ".js")))) {
|
||||
fileName = list[i] + "/" + txtInput.text;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
fileName = fs.path.join(__dirname, txtInput.text, txtInput.text);
|
||||
if ((fs.File.exists(fileName + ".xml") || (fs.File.exists(fileName + ".js")))) {
|
||||
frame.topmost().navigate(txtInput.text + "/" + txtInput.text);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
if (i < list.length) {
|
||||
frame.topmost().navigate(fileName);
|
||||
} else {
|
||||
dialogs.alert("Cannot find page: " + txtInput.text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var grid = new gridModule.GridLayout();
|
||||
|
||||
grid.addRow(new gridModule.ItemSpec(1, gridModule.GridUnitType.auto));
|
||||
grid.addRow(new gridModule.ItemSpec());
|
||||
gridModule.GridLayout.setRow(txtInput, 1);
|
||||
|
||||
grid.addChild(btn);
|
||||
grid.addChild(txtInput);
|
||||
|
||||
|
Reference in New Issue
Block a user