|
1 | 1 | import * as frame from "tns-core-modules/ui/frame"; |
2 | 2 | import { ViewBase, View, unsetValue, isIOS } from "tns-core-modules/ui/core/view"; |
3 | 3 | import { Page } from "tns-core-modules/ui/page"; |
| 4 | +import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view"; |
4 | 5 | import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; |
5 | 6 | import { Button } from "tns-core-modules/ui/button"; |
6 | 7 | import * as TKUnit from "../TKUnit"; |
@@ -78,13 +79,55 @@ export function do_PageTest_WithStackLayout_AndButton(test: (views: [Page, Stack |
78 | 79 | newPage.content = null; |
79 | 80 | } |
80 | 81 |
|
81 | | -//export function buildUIAndRunTest(controlToTest, testFunction, pageCss?, testDelay?) { |
82 | | -export function buildUIAndRunTest<T extends View>(controlToTest: T, testFunction: (views: [T, Page]) => void, pageCss?) { |
| 82 | +export interface PageOptions { |
| 83 | + pageCss?: any, |
| 84 | + actionBar?: boolean, |
| 85 | + actionBarFlat?: boolean, |
| 86 | + actionBarHidden?: boolean, |
| 87 | + tabBar?: boolean |
| 88 | +} |
| 89 | + |
| 90 | +//export function buildUIAndRunTest(controlToTest, testFunction, options) { |
| 91 | +export function buildUIAndRunTest<T extends View>(controlToTest: T, testFunction: (views: [T, Page]) => void, options?: PageOptions) { |
83 | 92 | clearPage(); |
84 | 93 | let newPage = getCurrentPage(); |
85 | 94 |
|
86 | | - newPage.css = pageCss; |
87 | | - newPage.content = controlToTest; |
| 95 | + let testSubject = controlToTest as View; |
| 96 | + |
| 97 | + if (options) { |
| 98 | + if (options.pageCss) { |
| 99 | + newPage.css = options.pageCss; |
| 100 | + } |
| 101 | + |
| 102 | + newPage.actionBarHidden = true; |
| 103 | + newPage.actionBar.flat = false; |
| 104 | + |
| 105 | + if (options.actionBar) { |
| 106 | + newPage.actionBarHidden = false; |
| 107 | + newPage.actionBar.title = "Test ActionBar"; |
| 108 | + } |
| 109 | + |
| 110 | + if (options.actionBarFlat) { |
| 111 | + newPage.actionBarHidden = false; |
| 112 | + newPage.actionBar.title = "Test ActionBar Flat"; |
| 113 | + newPage.actionBar.flat = true; |
| 114 | + } |
| 115 | + |
| 116 | + if (options.actionBarHidden) { |
| 117 | + newPage.actionBarHidden = true; |
| 118 | + } |
| 119 | + |
| 120 | + if (options.tabBar) { |
| 121 | + const tabView = new TabView(); |
| 122 | + const tabEntry = new TabViewItem(); |
| 123 | + tabEntry.title = "Test"; |
| 124 | + tabEntry.view = controlToTest; |
| 125 | + tabView.items = [tabEntry]; |
| 126 | + testSubject = tabView; |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + newPage.content = testSubject; |
88 | 131 |
|
89 | 132 | testFunction([controlToTest, newPage]); |
90 | 133 | newPage.content = null; |
|
0 commit comments