|
| 1 | +import * as helper from '../../ui-helper'; |
| 2 | +import * as TKUnit from '../../tk-unit'; |
| 3 | +import { Color, Button, StackLayout } from '@nativescript/core'; |
| 4 | + |
| 5 | +export var test_value_after_initial = function () { |
| 6 | + let page = helper.getCurrentPage(); |
| 7 | + let btn = new Button(); |
| 8 | + let testStack = new StackLayout(); |
| 9 | + |
| 10 | + page.css = 'StackLayout { background-color: #FF0000; }'; |
| 11 | + |
| 12 | + page.content = testStack; |
| 13 | + testStack.addChild(btn); |
| 14 | + |
| 15 | + btn.backgroundColor = new Color('#0000FF'); |
| 16 | + TKUnit.assertEqual(btn.backgroundColor.hex, '#0000FF', 'backgroundColor property'); |
| 17 | + btn.backgroundColor = 'initial'; |
| 18 | + TKUnit.assertEqual(btn.backgroundColor, undefined, 'backgroundColor property'); |
| 19 | +}; |
| 20 | + |
| 21 | +export var test_value_Inherited_after_initial = function () { |
| 22 | + let page = helper.getCurrentPage(); |
| 23 | + let btn = new Button(); |
| 24 | + let testStack = new StackLayout(); |
| 25 | + |
| 26 | + page.css = 'StackLayout { color: #FF0000; }'; |
| 27 | + |
| 28 | + page.content = testStack; |
| 29 | + testStack.addChild(btn); |
| 30 | + |
| 31 | + btn.color = new Color('#0000FF'); |
| 32 | + TKUnit.assertEqual(btn.color.hex, '#0000FF', 'color property'); |
| 33 | + (btn as any).color = 'initial'; |
| 34 | + TKUnit.assertEqual(btn.color, undefined, 'color property'); |
| 35 | +}; |
| 36 | + |
| 37 | +export var test_value_after_unset = function () { |
| 38 | + let page = helper.getCurrentPage(); |
| 39 | + let btn = new Button(); |
| 40 | + let testStack = new StackLayout(); |
| 41 | + |
| 42 | + page.css = 'StackLayout { background-color: #FF0000; }'; |
| 43 | + |
| 44 | + page.content = testStack; |
| 45 | + testStack.addChild(btn); |
| 46 | + |
| 47 | + btn.backgroundColor = new Color('#0000FF'); |
| 48 | + TKUnit.assertEqual(btn.backgroundColor.hex, '#0000FF', 'backgroundColor property'); |
| 49 | + btn.backgroundColor = 'unset'; |
| 50 | + TKUnit.assertEqual(btn.backgroundColor, undefined, 'backgroundColor property'); |
| 51 | +}; |
| 52 | + |
| 53 | +export var test_value_Inherited_after_unset = function () { |
| 54 | + let page = helper.getCurrentPage(); |
| 55 | + let btn = new Button(); |
| 56 | + let testStack = new StackLayout(); |
| 57 | + |
| 58 | + page.css = 'StackLayout { color: #FF0000; }'; |
| 59 | + |
| 60 | + page.content = testStack; |
| 61 | + testStack.addChild(btn); |
| 62 | + |
| 63 | + btn.color = new Color('#0000FF'); |
| 64 | + TKUnit.assertEqual(btn.color.hex, '#0000FF', 'color property'); |
| 65 | + (btn as any).color = 'unset'; |
| 66 | + TKUnit.assertEqual(btn.color.hex, '#FF0000', 'color property'); |
| 67 | +}; |
| 68 | + |
| 69 | +export var test_value_after_revert = function () { |
| 70 | + let page = helper.getCurrentPage(); |
| 71 | + let btn = new Button(); |
| 72 | + let testStack = new StackLayout(); |
| 73 | + |
| 74 | + page.css = 'StackLayout { background-color: #FF0000; }'; |
| 75 | + |
| 76 | + page.content = testStack; |
| 77 | + testStack.addChild(btn); |
| 78 | + |
| 79 | + btn.backgroundColor = new Color('#0000FF'); |
| 80 | + TKUnit.assertEqual(btn.backgroundColor.hex, '#0000FF', 'backgroundColor property'); |
| 81 | + btn.backgroundColor = 'revert'; |
| 82 | + TKUnit.assertEqual(btn.backgroundColor, undefined, 'backgroundColor property'); |
| 83 | +}; |
| 84 | + |
| 85 | +export var test_value_Inherited_after_revert = function () { |
| 86 | + let page = helper.getCurrentPage(); |
| 87 | + let btn = new Button(); |
| 88 | + let testStack = new StackLayout(); |
| 89 | + |
| 90 | + page.css = 'StackLayout { color: #FF0000; }'; |
| 91 | + |
| 92 | + page.content = testStack; |
| 93 | + testStack.addChild(btn); |
| 94 | + |
| 95 | + btn.color = new Color('#0000FF'); |
| 96 | + TKUnit.assertEqual(btn.color.hex, '#0000FF', 'color property'); |
| 97 | + (btn as any).color = 'revert'; |
| 98 | + TKUnit.assertEqual(btn.color.hex, '#FF0000', 'color property'); |
| 99 | +}; |
| 100 | + |
| 101 | +// TODO: Add missing inherit support for non-inherited properties |
| 102 | +export var test_value_after_inherit = function () { |
| 103 | + let page = helper.getCurrentPage(); |
| 104 | + let btn = new Button(); |
| 105 | + let testStack = new StackLayout(); |
| 106 | + |
| 107 | + page.css = 'StackLayout { background-color: #FF0000; }'; |
| 108 | + |
| 109 | + page.content = testStack; |
| 110 | + testStack.addChild(btn); |
| 111 | + |
| 112 | + btn.backgroundColor = new Color('#0000FF'); |
| 113 | + TKUnit.assertEqual(btn.backgroundColor.hex, '#0000FF', 'backgroundColor property'); |
| 114 | + btn.backgroundColor = 'inherit'; |
| 115 | + TKUnit.assertEqual(btn.backgroundColor, undefined, 'backgroundColor property'); |
| 116 | +}; |
| 117 | + |
| 118 | +export var test_value_Inherited_after_inherit = function () { |
| 119 | + let page = helper.getCurrentPage(); |
| 120 | + let btn = new Button(); |
| 121 | + let testStack = new StackLayout(); |
| 122 | + |
| 123 | + page.css = 'StackLayout { color: #FF0000; }'; |
| 124 | + |
| 125 | + page.content = testStack; |
| 126 | + testStack.addChild(btn); |
| 127 | + |
| 128 | + btn.color = new Color('#0000FF'); |
| 129 | + TKUnit.assertEqual(btn.color.hex, '#0000FF', 'color property'); |
| 130 | + (btn as any).color = 'inherit'; |
| 131 | + TKUnit.assertEqual(btn.color.hex, '#FF0000', 'color property'); |
| 132 | +}; |
0 commit comments