|
| 1 | +import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; |
| 2 | +import { Label } from "tns-core-modules/ui/label"; |
| 3 | +import { TextView } from "tns-core-modules/ui/text-view"; |
| 4 | +import { Button } from "tns-core-modules/ui/button"; |
| 5 | +import { Page } from "tns-core-modules/ui/page"; |
| 6 | +import { Color } from "tns-core-modules/color"; |
| 7 | +import { isIOS } from "tns-core-modules/platform"; |
| 8 | + |
| 9 | +import * as knownColors from "tns-core-modules/color/known-colors"; |
| 10 | + |
| 11 | +import * as tests from "./tests"; |
| 12 | + |
| 13 | +let red = new Color(knownColors.Red); |
| 14 | +let green = new Color(knownColors.Green); |
| 15 | +let blue = new Color(knownColors.Blue); |
| 16 | +let purple = new Color(knownColors.Purple); |
| 17 | + |
| 18 | +const c = [10, 100, 1000, 10000, 100000]; |
| 19 | + |
| 20 | +function getStack(stack: StackLayout): StackLayout { |
| 21 | + let p = new StackLayout(); |
| 22 | + stack.removeChildren(); |
| 23 | + stack.addChild(p); |
| 24 | + return p; |
| 25 | +} |
| 26 | + |
| 27 | +let runner; |
| 28 | + |
| 29 | +export function onNavigatingFrom() { |
| 30 | + clearInterval(runner); |
| 31 | +} |
| 32 | + |
| 33 | +export function onTap3(args) { |
| 34 | + let btn = <Button>args.object; |
| 35 | + const p = btn.page.getViewById<StackLayout>("placeholder"); |
| 36 | + btn.text = "Start tests..."; |
| 37 | + |
| 38 | + let result = btn.page.getViewById<TextView>("result"); |
| 39 | + |
| 40 | + result.text = ""; |
| 41 | + |
| 42 | + function track(line: string) { |
| 43 | + console.log(line); |
| 44 | + result.text += line + "\n"; |
| 45 | + } |
| 46 | + |
| 47 | + let text = "Count"; |
| 48 | + c.forEach(e => { |
| 49 | + text += `\t${e}`; |
| 50 | + }); |
| 51 | + track(text); |
| 52 | + |
| 53 | + let tasks = [ |
| 54 | + () => track(tests.setBackgroundColor(c)), |
| 55 | + () => track(tests.setBackgroundColor(c, getStack(p))), |
| 56 | + () => track(tests.setBindingContext(c)), |
| 57 | + () => track(tests.setBindingContext(c, getStack(p))), |
| 58 | + () => track(tests.setBindingContextWithParents(c, getStack(p))), |
| 59 | + () => track(tests.setBindingContextWithParentsBound(c, getStack(p))), |
| 60 | + () => track(tests.setBorderWidths(c)), |
| 61 | + () => track(tests.setBorderWidths(c, getStack(p))), |
| 62 | + () => track(tests.setFontSize(c)), |
| 63 | + () => track(tests.setFontSize(c, getStack(p))), |
| 64 | + () => track(tests.setFontSizeWithParents(c, getStack(p))), |
| 65 | + () => track(tests.setFontWeight(c)), |
| 66 | + () => track(tests.setFontWeight(c, getStack(p))), |
| 67 | + () => track(tests.setFontWeightWithParents(c, getStack(p))), |
| 68 | + () => track(tests.setColor(c)), |
| 69 | + () => track(tests.setColor(c, getStack(p))), |
| 70 | + () => track(tests.setColorWithParents(c, getStack(p))), |
| 71 | + () => track(tests.setText(c)), |
| 72 | + () => track(tests.setText(c, getStack(p))), |
| 73 | + () => track(tests.addRemove(c, getStack(p))), |
| 74 | + () => track("Complete!") |
| 75 | + ]; |
| 76 | + let i = 0; |
| 77 | + runner = setInterval(nextTask, 1); |
| 78 | + function nextTask() { |
| 79 | + if (i < tasks.length) { |
| 80 | + tasks[i](); |
| 81 | + i++; |
| 82 | + } else { |
| 83 | + clearInterval(runner); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
0 commit comments