diff --git a/tests/app/ui/layouts/grid-layout-tests.ts b/tests/app/ui/layouts/grid-layout-tests.ts index a872d6c67..faaaf1293 100644 --- a/tests/app/ui/layouts/grid-layout-tests.ts +++ b/tests/app/ui/layouts/grid-layout-tests.ts @@ -10,7 +10,7 @@ import * as layoutHelper from "./layout-helper"; import * as platform from "tns-core-modules/platform"; import * as commonTests from "./common-layout-tests"; import * as helper from "../helper"; - +import { parse } from "tns-core-modules/ui/builder"; var DELTA = 1; class RemovalTrackingGridLayout extends GridLayout { @@ -58,6 +58,39 @@ export class GridLayoutTest extends testModule.UITest return GridLayout.getColumnSpan(view); } + // TODO: Start Refactor + private getViews (template: string) { + let root = parse(template); + return { + root, + grid: root.getViewById("grid") as GridLayout, + cells: [ + [ root.getViewById("cell00") as view.View, root.getViewById("cell01") as view.View, root.getViewById("cell02") as view.View ], + [ root.getViewById("cell10") as view.View, root.getViewById("cell11") as view.View, root.getViewById("cell12") as view.View ], + [ root.getViewById("cell20") as view.View, root.getViewById("cell21") as view.View, root.getViewById("cell22") as view.View ] + ] + }; + }; + + private executeSnippet(ui: U, setup: (ui: U) => void, test: (ui: U) => void): void { + function waitUntilTestElementLayoutIsValid(view: view.View, timeoutSec?: number): void { + TKUnit.waitUntilReady(() => { + return view.isLayoutValid; + }, timeoutSec || 1); + } + + setup(ui); + helper.buildUIAndRunTest(ui.root, () => { + waitUntilTestElementLayoutIsValid(ui.root); + test(ui); + }); + }; + + private noop() { + // no operation + }; + // TODO: End Refactor + private prepareGridLayout(wait?: boolean) { this.testView.addRow(new ItemSpec(1, "star")); @@ -96,6 +129,69 @@ export class GridLayoutTest extends testModule.UITest } } + public test_grid() { + const snippet = ` + + + `; + + this.executeSnippet( + this.getViews(snippet), + this.noop, + ({ root, grid, cells }) => { + // TODO: Test Layout position + } + ); + } + + public test_grid_3x3_label() { + const snippet = ` + + + + + + + + + + + + `; + + this.executeSnippet( + this.getViews(snippet), + this.noop, + ({ root, grid, cells }) => { + // TODO: Test Label components position + } + ); + } + + public test_grid_3x3_grid() { + const snippet = ` + + + + + + + + + + + + `; + + this.executeSnippet( + this.getViews(snippet), + this.noop, + ({ root, grid, cells }) => { + // TODO: Test Nested Layout position + } + ); + } + public test_row_defaultValue() { var test = new Button(); TKUnit.assert(test !== null);