diff options
author | Eric Guzman | 2012-03-27 10:22:42 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-27 10:22:42 -0700 |
commit | 309b201017da2a4094df4f06adeeff9d396b193a (patch) | |
tree | 92257b32855bcd31dd74967b085a6632fd7dbe9b /node_modules/montage/test | |
parent | da03585a0b03220281f6d54d9acf0ae0fafaef16 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-309b201017da2a4094df4f06adeeff9d396b193a.tar.gz |
Merge branch 'refs/heads/master' into PresetsPI
Diffstat (limited to 'node_modules/montage/test')
3 files changed, 419 insertions, 0 deletions
diff --git a/node_modules/montage/test/ui/youtube-player-spec.js b/node_modules/montage/test/ui/youtube-player-spec.js new file mode 100755 index 00000000..dc57e3ec --- /dev/null +++ b/node_modules/montage/test/ui/youtube-player-spec.js | |||
@@ -0,0 +1,363 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | var Montage = require("montage").Montage, | ||
7 | TestPageLoader = require("support/testpageloader").TestPageLoader; | ||
8 | |||
9 | var testPage = TestPageLoader.queueTest("buttontest", function() { | ||
10 | var test = testPage.test; | ||
11 | |||
12 | var click = function(component, el, fn) { | ||
13 | el = el || component.element; | ||
14 | |||
15 | var listener = testPage.addListener(component, fn); | ||
16 | |||
17 | testPage.mouseEvent({target: el}, "mousedown"); | ||
18 | testPage.mouseEvent({target: el}, "mouseup"); | ||
19 | testPage.mouseEvent({target: el}, "click"); | ||
20 | |||
21 | // Return this so that it can be checked in tha calling function. | ||
22 | return listener; | ||
23 | }; | ||
24 | var testButton = function(component, value) { | ||
25 | expect(component).toBeDefined(); | ||
26 | expect(click(component)).toHaveBeenCalled(); | ||
27 | expect(component.label).toBe(value); | ||
28 | }; | ||
29 | |||
30 | describe("ui/button-spec", function() { | ||
31 | it("should load", function() { | ||
32 | expect(testPage.loaded).toBe(true); | ||
33 | }); | ||
34 | |||
35 | describe("button", function(){ | ||
36 | |||
37 | it("can be created from a div element", function(){ | ||
38 | testButton(test.divbutton, "div button"); | ||
39 | }); | ||
40 | it("can be created from an input element", function(){ | ||
41 | testButton(test.inputbutton, "input button"); | ||
42 | }); | ||
43 | it("can be created from a button element", function(){ | ||
44 | testButton(test.buttonbutton, "button button"); | ||
45 | }); | ||
46 | |||
47 | describe("disabled property", function(){ | ||
48 | it("is taken from the element's disabled attribute", function() { | ||
49 | expect(test.disabledbutton.disabled).toBe(true); | ||
50 | expect(click(test.disabledbutton)).not.toHaveBeenCalled(); | ||
51 | expect(test.disabledinput.disabled).toBe(true); | ||
52 | expect(click(test.disabledinput)).not.toHaveBeenCalled(); | ||
53 | expect(test.inputbutton.disabled).toBe(false); | ||
54 | }); | ||
55 | it("can be set", function(){ | ||
56 | expect(test.disabledbutton.disabled).toBe(true); | ||
57 | test.disabledbutton.disabled = false; | ||
58 | expect(test.disabledbutton.disabled).toBe(false); | ||
59 | // TODO click the button and check that it wasn't pressed | ||
60 | |||
61 | expect(test.disabledinput.disabled).toBe(true); | ||
62 | test.disabledinput.disabled = false; | ||
63 | expect(test.disabledinput.disabled).toBe(false); | ||
64 | // TODO click the button and check that it wasn't pressed | ||
65 | }); | ||
66 | it("can can be set in the serialization", function(){ | ||
67 | expect(test.disabledinputszn.disabled).toBe(true); | ||
68 | // TODO check button pressibility | ||
69 | }); | ||
70 | it("is the inverse of the enabled property", function(){ | ||
71 | expect(test.enabledinputszn.disabled).toBe(false); | ||
72 | expect(test.enabledinputszn.enabled).toBe(true); | ||
73 | test.enabledinputszn.enabled = false; | ||
74 | expect(test.enabledinputszn.disabled).toBe(true); | ||
75 | expect(test.enabledinputszn.enabled).toBe(false); | ||
76 | // TODO click the button and check that it wasn't pressed | ||
77 | }); | ||
78 | }); | ||
79 | |||
80 | describe("label property", function() { | ||
81 | it("is set from the serialization on a button", function() { | ||
82 | expect(test.buttonlabelszn.label).toBe("pass"); | ||
83 | testPage.waitForDraw(); | ||
84 | runs(function(){ | ||
85 | expect(test.buttonlabelszn.element.firstChild.data).toBe("pass"); | ||
86 | }); | ||
87 | }); | ||
88 | it("is set from the serialization on an input", function() { | ||
89 | expect(test.inputlabelszn.label).toBe("pass"); | ||
90 | expect(test.inputlabelszn.element.value).toBe("pass"); | ||
91 | }); | ||
92 | it("sets the value on an input", function() { | ||
93 | expect(test.inputbutton.label).toBe("input button"); | ||
94 | test.inputbutton.label = "label pass"; | ||
95 | expect(test.inputbutton.label).toBe("label pass"); | ||
96 | expect(test.inputbutton.value).toBe("label pass"); | ||
97 | test.inputbutton.label = "input button"; | ||
98 | }); | ||
99 | it("sets the first child on a non-input element", function() { | ||
100 | expect(test.buttonbutton.label).toBe("button button"); | ||
101 | test.buttonbutton.label = "label pass"; | ||
102 | expect(test.buttonbutton.label).toBe("label pass"); | ||
103 | |||
104 | testPage.waitForDraw(); | ||
105 | runs(function(){ | ||
106 | expect(test.buttonbutton.element.firstChild.data).toBe("label pass"); | ||
107 | test.buttonbutton.label = "button button"; | ||
108 | }); | ||
109 | }); | ||
110 | }); | ||
111 | |||
112 | describe("value property", function() { | ||
113 | it("is set from the value on an input", function() { | ||
114 | expect(test.inputbutton.element.value).toBe("input button"); | ||
115 | expect(test.inputbutton.value).toBe("input button"); | ||
116 | }); | ||
117 | it("is set by the label property in the serialization", function() { | ||
118 | expect(test.inputlabelszn.label).toBe("pass"); | ||
119 | //expect(test.inputlabelszn.value).toBe("pass"); | ||
120 | }); | ||
121 | it("sets the label property when using an input element", function() { | ||
122 | expect(test.inputbutton.label).toBe("input button"); | ||
123 | test.inputbutton.value = "value pass"; | ||
124 | expect(test.inputbutton.value).toBe("value pass"); | ||
125 | expect(test.inputbutton.label).toBe("value pass"); | ||
126 | test.inputbutton.value = "input button"; | ||
127 | }); | ||
128 | it("doesn't set the label property when using a non-input element", function() { | ||
129 | expect(test.buttonbutton.label).toBe("button button"); | ||
130 | test.buttonbutton.value = "value fail"; | ||
131 | expect(test.buttonbutton.label).toBe("button button"); | ||
132 | testPage.waitForDraw(); | ||
133 | runs(function(){ | ||
134 | expect(test.buttonbutton.element.firstChild.data).toBe("button button"); | ||
135 | test.buttonbutton.value = "button button"; | ||
136 | }); | ||
137 | }); | ||
138 | |||
139 | }); | ||
140 | |||
141 | |||
142 | it("responds when child elements are clicked on", function(){ | ||
143 | expect(click(test.buttonnested, test.buttonnested.element.firstChild)).toHaveBeenCalled(); | ||
144 | }); | ||
145 | |||
146 | it("supports converters for label", function(){ | ||
147 | expect(test.converterbutton.label).toBe("PASS"); | ||
148 | expect(test.converterbutton.element.value).toBe("PASS"); | ||
149 | }); | ||
150 | |||
151 | // TODO should be transplanted to the press-composer-spec | ||
152 | // it("correctly releases the pointer", function() { | ||
153 | // var l = testPage.addListener(test.scroll_button); | ||
154 | |||
155 | // testpage.mouseEvent({target: test.scroll_button.element}, "mousedown");; | ||
156 | // expect(test.scroll_button.active).toBe(true); | ||
157 | // test.scroll_button.surrenderPointer(test.scroll_button._observedPointer, null); | ||
158 | // expect(test.scroll_button.active).toBe(false); | ||
159 | // testPage.mouseEvent({target: test.scroll_button.element}, "mouseup");; | ||
160 | |||
161 | // expect(l).not.toHaveBeenCalled(); | ||
162 | |||
163 | // }); | ||
164 | |||
165 | if (window.Touch) { | ||
166 | |||
167 | describe("when supporting touch events", function() { | ||
168 | |||
169 | it("should dispatch an action event when a touchend follows a touchstart on a button", function() { | ||
170 | |||
171 | }); | ||
172 | |||
173 | }); | ||
174 | |||
175 | } else { | ||
176 | |||
177 | describe("when supporting mouse events", function() { | ||
178 | it("dispatches an action event when a mouseup follows a mousedown", function() { | ||
179 | expect(click(test.inputbutton)).toHaveBeenCalled(); | ||
180 | }); | ||
181 | |||
182 | it("does not dispatch an action event when a mouseup occurs after not previously receiving a mousedown", function() { | ||
183 | // reset interaction | ||
184 | // test.inputbutton._endInteraction(); | ||
185 | var l = testPage.addListener(test.inputbutton); | ||
186 | testPage.mouseEvent({target: test.inputbutton.element}, "mouseup");; | ||
187 | expect(l).not.toHaveBeenCalled(); | ||
188 | }); | ||
189 | |||
190 | it("does not dispatch an action event when a mouseup occurs away from the button after a mousedown on a button", function() { | ||
191 | var l = testPage.addListener(test.inputbutton); | ||
192 | |||
193 | testpage.mouseEvent({target: test.inputbutton.element}, "mousedown");; | ||
194 | // Mouse up somewhere else | ||
195 | testPage.mouseEvent({target: test.divbutton.element}, "mouseup");; | ||
196 | |||
197 | expect(l).not.toHaveBeenCalled(); | ||
198 | }); | ||
199 | }); | ||
200 | } | ||
201 | |||
202 | describe("inside a scroll view", function() { | ||