frank-cucumber 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/frank-skeleton/frank_static_resources.bundle/index.html +29 -34
- data/frank-skeleton/frank_static_resources.bundle/{index.haml → index.html.haml} +28 -29
- data/frank-skeleton/frank_static_resources.bundle/js/accessible_views_view.coffee +41 -0
- data/frank-skeleton/frank_static_resources.bundle/js/accessible_views_view.js +46 -0
- data/frank-skeleton/frank_static_resources.bundle/js/controller.coffee +129 -0
- data/frank-skeleton/frank_static_resources.bundle/js/controller.js +142 -0
- data/frank-skeleton/frank_static_resources.bundle/js/details_view.coffee +42 -0
- data/frank-skeleton/frank_static_resources.bundle/js/details_view.js +51 -0
- data/frank-skeleton/frank_static_resources.bundle/js/dropdown_control.coffee +64 -0
- data/frank-skeleton/frank_static_resources.bundle/js/dropdown_control.js +73 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_model.coffee +46 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_model.js +59 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_view.coffee +167 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_view.js +198 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_model.coffee +10 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_model.js +17 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_view.coffee +43 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_view.js +60 -0
- data/frank-skeleton/frank_static_resources.bundle/js/frank.coffee +96 -0
- data/frank-skeleton/frank_static_resources.bundle/js/frank.js +118 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/backbone.js +1431 -0
- data/frank-skeleton/frank_static_resources.bundle/{coffee-script.js → js/lib/coffee-script.js} +0 -0
- data/frank-skeleton/frank_static_resources.bundle/{jquery-ui.min.js → js/lib/jquery-ui.min.js} +0 -0
- data/frank-skeleton/frank_static_resources.bundle/{jquery.min.js → js/lib/jquery.min.js} +0 -0
- data/frank-skeleton/frank_static_resources.bundle/{jquery.treeview.js → js/lib/jquery.treeview.js} +0 -0
- data/frank-skeleton/frank_static_resources.bundle/{json2.js → js/lib/json2.js} +0 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/raphael.js +5815 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/require.js +2053 -0
- data/frank-skeleton/frank_static_resources.bundle/{underscore.js → js/lib/underscore.js} +466 -177
- data/frank-skeleton/frank_static_resources.bundle/js/main.coffee +27 -0
- data/frank-skeleton/frank_static_resources.bundle/js/main.js +29 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tabs_controller.coffee +13 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tabs_controller.js +22 -0
- data/frank-skeleton/frank_static_resources.bundle/js/toast_controller.coffee +15 -0
- data/frank-skeleton/frank_static_resources.bundle/js/toast_controller.js +28 -0
- data/frank-skeleton/frank_static_resources.bundle/js/transform_stack.coffee +59 -0
- data/frank-skeleton/frank_static_resources.bundle/js/transform_stack.js +78 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee +53 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tree_view.js +64 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_heir_model.coffee +37 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_heir_model.js +48 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_model.coffee +39 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_model.js +62 -0
- data/frank-skeleton/frank_static_resources.bundle/symbiote.css +116 -84
- data/lib/frank-cucumber/frankifier.rb +20 -2
- data/lib/frank-cucumber/version.rb +1 -1
- metadata +70 -38
- data/frank-skeleton/frank_static_resources.bundle/raphael-min.js +0 -7
- data/frank-skeleton/frank_static_resources.bundle/symbiote.js +0 -585
- data/frank-skeleton/frank_static_resources.bundle/symbiote_ui.coffee +0 -39
@@ -0,0 +1,198 @@
|
|
1
|
+
(function() {
|
2
|
+
var ISO_MAJOR_OFFSET, ISO_MINOR_OFFSET, ISO_SKEW, SCREEN_BOUNDS,
|
3
|
+
__slice = [].slice;
|
4
|
+
|
5
|
+
ISO_SKEW = 15;
|
6
|
+
|
7
|
+
ISO_MAJOR_OFFSET = 50;
|
8
|
+
|
9
|
+
ISO_MINOR_OFFSET = 5;
|
10
|
+
|
11
|
+
SCREEN_BOUNDS = {
|
12
|
+
iphone: {
|
13
|
+
x: 0,
|
14
|
+
y: 0,
|
15
|
+
width: 320,
|
16
|
+
height: 480
|
17
|
+
},
|
18
|
+
ipad: {
|
19
|
+
x: 0,
|
20
|
+
y: 0,
|
21
|
+
width: 768,
|
22
|
+
height: 1024
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
define(['transform_stack', 'ersatz_model'], function(transformStack, ErsatzModel) {
|
27
|
+
var ErsatzView, ErsatzViewSnapshotView, drawStaticBackdropAndReturnTransformer, transformFromBaseForViewModel;
|
28
|
+
drawStaticBackdropAndReturnTransformer = function(paper, deviceFamily, orientation, isoSkew) {
|
29
|
+
var isiPhone, rotation, rotationPoint, transformer;
|
30
|
+
paper.clear();
|
31
|
+
paper.canvas.setAttribute("width", "100%");
|
32
|
+
paper.canvas.setAttribute("height", "100%");
|
33
|
+
isiPhone = 'iphone' === deviceFamily;
|
34
|
+
if (isiPhone) {
|
35
|
+
paper.canvas.setAttribute("viewBox", "0 0 380 720");
|
36
|
+
rotationPoint = [190, 360];
|
37
|
+
} else {
|
38
|
+
paper.canvas.setAttribute("viewBox", "0 0 875 1200");
|
39
|
+
rotationPoint = [437, 600];
|
40
|
+
}
|
41
|
+
transformer = transformStack();
|
42
|
+
transformer.skew(0, isoSkew).translate(6, 6);
|
43
|
+
rotation = (function() {
|
44
|
+
switch (orientation) {
|
45
|
+
case 'landscape_right':
|
46
|
+
return 90;
|
47
|
+
case 'portrait_upside_down':
|
48
|
+
return 180;
|
49
|
+
case 'landscape_left':
|
50
|
+
return 270;
|
51
|
+
default:
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
})();
|
55
|
+
if (rotation) {
|
56
|
+
transformer.rotateAroundPoint.apply(transformer, [rotation].concat(__slice.call(rotationPoint)));
|
57
|
+
}
|
58
|
+
if (isiPhone) {
|
59
|
+
paper.rect(0, 0, 360, 708, 40).attr({
|
60
|
+
fill: "black",
|
61
|
+
stroke: "gray",
|
62
|
+
"stroke-width": 4
|
63
|
+
}).transform(transformer.desc());
|
64
|
+
} else {
|
65
|
+
paper.rect(10, 10, 855, 1110, 20).attr({
|
66
|
+
'fill': 'black',
|
67
|
+
'stroke': 'gray',
|
68
|
+
'stroke-width': 6
|
69
|
+
}).transform(transformer.desc());
|
70
|
+
}
|
71
|
+
if (isiPhone) {
|
72
|
+
transformer.push().translate(180, 655);
|
73
|
+
paper.circle(0, 0, 34).transform(transformer.desc()).attr("fill", "90-#303030-#101010");
|
74
|
+
paper.rect(0, 0, 22, 22, 5).attr({
|
75
|
+
stroke: "gray",
|
76
|
+
"stroke-width": 2
|
77
|
+
}).transform(transformer.push().translate(-11, -11).descAndPop());
|
78
|
+
transformer.translate(20, 120);
|
79
|
+
} else {
|
80
|
+
transformer.translate(50, 50);
|
81
|
+
}
|
82
|
+
if (isoSkew > 0) {
|
83
|
+
transformer.translate(-ISO_MAJOR_OFFSET, 0);
|
84
|
+
}
|
85
|
+
return transformer;
|
86
|
+
};
|
87
|
+
transformFromBaseForViewModel = function(baseTransformer, viewModel, withSkew) {
|
88
|
+
var x, y, _ref;
|
89
|
+
if (withSkew == null) {
|
90
|
+
withSkew = false;
|
91
|
+
}
|
92
|
+
_ref = viewModel.get('accessibilityFrame').origin, x = _ref.x, y = _ref.y;
|
93
|
+
baseTransformer.push().translate(x, y);
|
94
|
+
if (withSkew) {
|
95
|
+
baseTransformer.translate(viewModel.get('depth') * -ISO_MINOR_OFFSET, 0);
|
96
|
+
}
|
97
|
+
return baseTransformer.descAndPop();
|
98
|
+
};
|
99
|
+
ErsatzViewSnapshotView = Backbone.View.extend({
|
100
|
+
initialize: function() {
|
101
|
+
this.model.on('change:active', _.bind(this.updateOpacity, this));
|
102
|
+
return this.render();
|
103
|
+
},
|
104
|
+
render: function() {
|
105
|
+
var frame;
|
106
|
+
frame = this.model.get('accessibilityFrame');
|
107
|
+
this.el.attr({
|
108
|
+
transform: transformFromBaseForViewModel(this.options.baseTransformer, this.model, true),
|
109
|
+
src: this.model.getSnapshotUrl(),
|
110
|
+
x: 0,
|
111
|
+
y: 0,
|
112
|
+
width: frame.size.width,
|
113
|
+
height: frame.size.height
|
114
|
+
});
|
115
|
+
this.updateOpacity();
|
116
|
+
return this.el;
|
117
|
+
},
|
118
|
+
updateOpacity: function() {
|
119
|
+
var opacity;
|
120
|
+
opacity = (this.model.get('active') ? 1.0 : 0.05);
|
121
|
+
return this.el.attr('opacity', opacity);
|
122
|
+
}
|
123
|
+
});
|
124
|
+
return ErsatzView = Backbone.View.extend({
|
125
|
+
el: $('#ui-locator-view'),
|
126
|
+
initialize: function() {
|
127
|
+
_.bindAll(this, 'render');
|
128
|
+
this.model = new ErsatzModel();
|
129
|
+
this.highlights = [];
|
130
|
+
this.paper = new Raphael(this.el);
|
131
|
+
this.model.on('change:baseScreenshotUrl', _.bind(this.refreshBaseScreenshot, this));
|
132
|
+
this.model.on('change:isAsploded', _.bind(this.render, this));
|
133
|
+
this.model.on('snapshots-refreshed', _.bind(this.refreshSnapshots, this));
|
134
|
+
return this.model.on('change:highlightFrames', _.bind(this.refreshHighlightFrames, this));
|
135
|
+
},
|
136
|
+
render: function() {
|
137
|
+
var isoSkew;
|
138
|
+
this.highlights = [];
|
139
|
+
isoSkew = (this.model.get('isAsploded') ? ISO_SKEW : 0);
|
140
|
+
this.backdropTransformer = drawStaticBackdropAndReturnTransformer(this.paper, this.model.get('deviceFamily'), this.model.get('orientation'), isoSkew);
|
141
|
+
this.backdrop = this.paper.image();
|
142
|
+
this.refreshBaseScreenshot();
|
143
|
+
if (this.model.get('isAsploded')) {
|
144
|
+
this.backdrop.attr('opacity', 0.5);
|
145
|
+
this.refreshSnapshots();
|
146
|
+
}
|
147
|
+
return this.el;
|
148
|
+
},
|
149
|
+
screenBounds: function() {
|
150
|
+
return SCREEN_BOUNDS[this.model.get('deviceFamily')];
|
151
|
+
},
|
152
|
+
refreshBaseScreenshot: function() {
|
153
|
+
var newScreenshotUrl;
|
154
|
+
newScreenshotUrl = this.model.get('baseScreenshotUrl');
|
155
|
+
if (newScreenshotUrl == null) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
return this.backdrop.transform(this.backdropTransformer.desc()).attr(this.screenBounds()).attr('src', newScreenshotUrl).toFront();
|
159
|
+
},
|
160
|
+
refreshSnapshots: function() {
|
161
|
+
var _this = this;
|
162
|
+
return this.model.get('allViews').each(function(viewModel) {
|
163
|
+
var snapshotView;
|
164
|
+
return snapshotView = new ErsatzViewSnapshotView({
|
165
|
+
model: viewModel,
|
166
|
+
baseTransformer: _this.backdropTransformer,
|
167
|
+
el: _this.paper.image()
|
168
|
+
});
|
169
|
+
});
|
170
|
+
},
|
171
|
+
refreshHighlightFrames: function() {
|
172
|
+
var h, _i, _len, _ref,
|
173
|
+
_this = this;
|
174
|
+
_ref = this.highlights;
|
175
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
176
|
+
h = _ref[_i];
|
177
|
+
h.remove();
|
178
|
+
}
|
179
|
+
this.highlights = [];
|
180
|
+
return this.highlights = _.map(this.model.get('highlightFrames'), function(_arg) {
|
181
|
+
var origin, size;
|
182
|
+
origin = _arg.origin, size = _arg.size;
|
183
|
+
return _this.paper.rect().attr({
|
184
|
+
fill: "#aaff00",
|
185
|
+
opacity: 0.8,
|
186
|
+
stroke: "black",
|
187
|
+
transform: _this.backdropTransformer.push().translate(origin.x, origin.y).descAndPop(),
|
188
|
+
x: 0,
|
189
|
+
y: 0,
|
190
|
+
width: size.width,
|
191
|
+
height: size.height
|
192
|
+
});
|
193
|
+
});
|
194
|
+
}
|
195
|
+
});
|
196
|
+
});
|
197
|
+
|
198
|
+
}).call(this);
|
@@ -0,0 +1,17 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
define(function() {
|
4
|
+
var ExperimentBarModel;
|
5
|
+
return ExperimentBarModel = Backbone.Model.extend({
|
6
|
+
defaults: {
|
7
|
+
engines: ['shelley_compat', 'uiquery'],
|
8
|
+
selectorEngine: 'shelley_compat',
|
9
|
+
selector: ''
|
10
|
+
},
|
11
|
+
actionClicked: function(actionName) {
|
12
|
+
return this.trigger("" + actionName + "-clicked", this);
|
13
|
+
}
|
14
|
+
});
|
15
|
+
});
|
16
|
+
|
17
|
+
}).call(this);
|
@@ -0,0 +1,43 @@
|
|
1
|
+
define ['experiment_bar_model','dropdown_control'], (ExperimentBarModel,DropdownControl)->
|
2
|
+
|
3
|
+
ExperimentBarView = Backbone.View.extend
|
4
|
+
el: $("#selector-test")
|
5
|
+
|
6
|
+
initialize: ->
|
7
|
+
@actionDropdownView = new DropdownControl.DropdownView()
|
8
|
+
@actionDropdownView.setElement(@$('.action-buttons'))
|
9
|
+
@actionDropdownView.collection.reset([
|
10
|
+
{name: 'highlight', text:'Highlight'},
|
11
|
+
{name: 'touch', text:'Touch In App'},
|
12
|
+
{name: 'flash', text:'Flash In App'}
|
13
|
+
])
|
14
|
+
@actionDropdownView.collection.at(0).select()
|
15
|
+
@actionDropdownView.collection.on 'option-clicked', (option)=> @actionClicked(option.get('name'))
|
16
|
+
|
17
|
+
@engineDropdownView = new DropdownControl.DropdownView()
|
18
|
+
@engineDropdownView.setElement(@$('.selector-engine'))
|
19
|
+
@engineDropdownView.collection.reset([
|
20
|
+
{name: 'shelley_compat', text:'Shelley'},
|
21
|
+
{name: 'uiquery', text:'UIQuery'}
|
22
|
+
])
|
23
|
+
@engineDropdownView.collection.at(0).select()
|
24
|
+
@engineDropdownView.collection.on 'option-clicked', (option)=>
|
25
|
+
@model.set( 'selectorEngine', (option.get('name')) )
|
26
|
+
|
27
|
+
@$selectorInput = @$('input#query')
|
28
|
+
|
29
|
+
|
30
|
+
@model = new ExperimentBarModel()
|
31
|
+
@model.on 'change', _.bind(@update,@)
|
32
|
+
@update()
|
33
|
+
|
34
|
+
update: ->
|
35
|
+
@$selectorInput.val( @model.get('selector') )
|
36
|
+
|
37
|
+
actionClicked: (actionName)->
|
38
|
+
@updateModelFromSelectorInput()
|
39
|
+
@model.actionClicked(actionName)
|
40
|
+
|
41
|
+
|
42
|
+
updateModelFromSelectorInput: ->
|
43
|
+
@model.set( 'selector', @$selectorInput.val() )
|
@@ -0,0 +1,60 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
define(['experiment_bar_model', 'dropdown_control'], function(ExperimentBarModel, DropdownControl) {
|
4
|
+
var ExperimentBarView;
|
5
|
+
return ExperimentBarView = Backbone.View.extend({
|
6
|
+
el: $("#selector-test"),
|
7
|
+
initialize: function() {
|
8
|
+
var _this = this;
|
9
|
+
this.actionDropdownView = new DropdownControl.DropdownView();
|
10
|
+
this.actionDropdownView.setElement(this.$('.action-buttons'));
|
11
|
+
this.actionDropdownView.collection.reset([
|
12
|
+
{
|
13
|
+
name: 'highlight',
|
14
|
+
text: 'Highlight'
|
15
|
+
}, {
|
16
|
+
name: 'touch',
|
17
|
+
text: 'Touch In App'
|
18
|
+
}, {
|
19
|
+
name: 'flash',
|
20
|
+
text: 'Flash In App'
|
21
|
+
}
|
22
|
+
]);
|
23
|
+
this.actionDropdownView.collection.at(0).select();
|
24
|
+
this.actionDropdownView.collection.on('option-clicked', function(option) {
|
25
|
+
return _this.actionClicked(option.get('name'));
|
26
|
+
});
|
27
|
+
this.engineDropdownView = new DropdownControl.DropdownView();
|
28
|
+
this.engineDropdownView.setElement(this.$('.selector-engine'));
|
29
|
+
this.engineDropdownView.collection.reset([
|
30
|
+
{
|
31
|
+
name: 'shelley_compat',
|
32
|
+
text: 'Shelley'
|
33
|
+
}, {
|
34
|
+
name: 'uiquery',
|
35
|
+
text: 'UIQuery'
|
36
|
+
}
|
37
|
+
]);
|
38
|
+
this.engineDropdownView.collection.at(0).select();
|
39
|
+
this.engineDropdownView.collection.on('option-clicked', function(option) {
|
40
|
+
return _this.model.set('selectorEngine', option.get('name'));
|
41
|
+
});
|
42
|
+
this.$selectorInput = this.$('input#query');
|
43
|
+
this.model = new ExperimentBarModel();
|
44
|
+
this.model.on('change', _.bind(this.update, this));
|
45
|
+
return this.update();
|
46
|
+
},
|
47
|
+
update: function() {
|
48
|
+
return this.$selectorInput.val(this.model.get('selector'));
|
49
|
+
},
|
50
|
+
actionClicked: function(actionName) {
|
51
|
+
this.updateModelFromSelectorInput();
|
52
|
+
return this.model.actionClicked(actionName);
|
53
|
+
},
|
54
|
+
updateModelFromSelectorInput: function() {
|
55
|
+
return this.model.set('selector', this.$selectorInput.val());
|
56
|
+
}
|
57
|
+
});
|
58
|
+
});
|
59
|
+
|
60
|
+
}).call(this);
|
@@ -0,0 +1,96 @@
|
|
1
|
+
cacheBust = (url)-> "#{url}?#{(new Date()).getTime()}"
|
2
|
+
|
3
|
+
baseUrlFor = (path)->
|
4
|
+
window.location.protocol + "//" + window.location.host + "/" + path
|
5
|
+
|
6
|
+
isErrorResponse = (response)-> 'SUCCESS' != response.outcome
|
7
|
+
|
8
|
+
displayErrorResponse = (response)->
|
9
|
+
alert(
|
10
|
+
"""Frank isn't happy: #{response.reason}
|
11
|
+
details: #{response.details}""")
|
12
|
+
|
13
|
+
fetchViewHeirarchy = ->
|
14
|
+
request = $.ajax
|
15
|
+
type: "POST",
|
16
|
+
dataType: "json",
|
17
|
+
url: baseUrlFor( "/dump" )
|
18
|
+
|
19
|
+
fetchOrientation = ->
|
20
|
+
deferable = new $.Deferred()
|
21
|
+
|
22
|
+
request = $.ajax(
|
23
|
+
type: "GET",
|
24
|
+
dataType: "json",
|
25
|
+
url: baseUrlFor( "/orientation" )
|
26
|
+
).done (response)->
|
27
|
+
deferable.resolve( response && response.detailed_orientation || 'unknown' )
|
28
|
+
.fail( deferable.reject )
|
29
|
+
|
30
|
+
deferable.promise()
|
31
|
+
|
32
|
+
requestSnapshotRefresh = ->
|
33
|
+
$.ajax
|
34
|
+
type: 'GET'
|
35
|
+
url: baseUrlFor( "/screenshot/snapshot-all-views" )
|
36
|
+
|
37
|
+
|
38
|
+
sendMapRequest = ({selector, engine, methodName, methodArgs} )->
|
39
|
+
selector ||= 'uiquery'
|
40
|
+
methodArgs ||= []
|
41
|
+
|
42
|
+
deferable = new $.Deferred()
|
43
|
+
command = {
|
44
|
+
query: selector
|
45
|
+
selector_engine: engine
|
46
|
+
operation: {
|
47
|
+
method_name: methodName,
|
48
|
+
arguments: methodArgs
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
$.ajax({
|
53
|
+
type: "POST"
|
54
|
+
dataType: "json"
|
55
|
+
data: JSON.stringify( command )
|
56
|
+
url: baseUrlFor( '/map' )
|
57
|
+
success: (data)->
|
58
|
+
if isErrorResponse( data )
|
59
|
+
displayErrorResponse( data )
|
60
|
+
deferable.reject(data)
|
61
|
+
deferable.resolve(data.results)
|
62
|
+
error: (xhr,status,error)->
|
63
|
+
alert( "Error while talking to Frank: #{status}" )
|
64
|
+
deferable.reject(error)
|
65
|
+
})
|
66
|
+
deferable.promise()
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
define ->
|
71
|
+
fetchViewHeirarchy: fetchViewHeirarchy
|
72
|
+
fetchOrientation: fetchOrientation
|
73
|
+
requestSnapshotRefresh: requestSnapshotRefresh
|
74
|
+
baseScreenshotUrl: ->
|
75
|
+
cacheBust( baseUrlFor('/screenshot') )
|
76
|
+
snapshotUrlForViewWithUid: (uid)->
|
77
|
+
cacheBust( baseUrlFor( "/screenshot/view-snapshot/#{uid}" ) )
|
78
|
+
sendFlashCommand: (selector,engine)->
|
79
|
+
sendMapRequest(
|
80
|
+
selector:selector,
|
81
|
+
engine: engine,
|
82
|
+
methodName: 'FEX_flash'
|
83
|
+
)
|
84
|
+
sendTouchCommand: (selector,engine)->
|
85
|
+
sendMapRequest(
|
86
|
+
selector:selector,
|
87
|
+
engine: engine,
|
88
|
+
methodName: 'touch'
|
89
|
+
)
|
90
|
+
getAccessibilityFramesForViewsMatchingSelector: (selector,engine)->
|
91
|
+
sendMapRequest(
|
92
|
+
selector:selector,
|
93
|
+
engine: engine,
|
94
|
+
methodName: 'accessibilityFrame'
|
95
|
+
)
|
96
|
+
|
@@ -0,0 +1,118 @@
|
|
1
|
+
(function() {
|
2
|
+
var baseUrlFor, cacheBust, displayErrorResponse, fetchOrientation, fetchViewHeirarchy, isErrorResponse, requestSnapshotRefresh, sendMapRequest;
|
3
|
+
|
4
|
+
cacheBust = function(url) {
|
5
|
+
return "" + url + "?" + ((new Date()).getTime());
|
6
|
+
};
|
7
|
+
|
8
|
+
baseUrlFor = function(path) {
|
9
|
+
return window.location.protocol + "//" + window.location.host + "/" + path;
|
10
|
+
};
|
11
|
+
|
12
|
+
isErrorResponse = function(response) {
|
13
|
+
return 'SUCCESS' !== response.outcome;
|
14
|
+
};
|
15
|
+
|
16
|
+
displayErrorResponse = function(response) {
|
17
|
+
return alert("Frank isn't happy: " + response.reason + "\ndetails: " + response.details);
|
18
|
+
};
|
19
|
+
|
20
|
+
fetchViewHeirarchy = function() {
|
21
|
+
var request;
|
22
|
+
return request = $.ajax({
|
23
|
+
type: "POST",
|
24
|
+
dataType: "json",
|
25
|
+
url: baseUrlFor("/dump")
|
26
|
+
});
|
27
|
+
};
|
28
|
+
|
29
|
+
fetchOrientation = function() {
|
30
|
+
var deferable, request;
|
31
|
+
deferable = new $.Deferred();
|
32
|
+
request = $.ajax({
|
33
|
+
type: "GET",
|
34
|
+
dataType: "json",
|
35
|
+
url: baseUrlFor("/orientation")
|
36
|
+
}).done(function(response) {
|
37
|
+
return deferable.resolve(response && response.detailed_orientation || 'unknown');
|
38
|
+
}).fail(deferable.reject);
|
39
|
+
return deferable.promise();
|
40
|
+
};
|
41
|
+
|
42
|
+
requestSnapshotRefresh = function() {
|
43
|
+
return $.ajax({
|
44
|
+
type: 'GET',
|
45
|
+
url: baseUrlFor("/screenshot/snapshot-all-views")
|
46
|
+
});
|
47
|
+
};
|
48
|
+
|
49
|
+
sendMapRequest = function(_arg) {
|
50
|
+
var command, deferable, engine, methodArgs, methodName, selector;
|
51
|
+
selector = _arg.selector, engine = _arg.engine, methodName = _arg.methodName, methodArgs = _arg.methodArgs;
|
52
|
+
selector || (selector = 'uiquery');
|
53
|
+
methodArgs || (methodArgs = []);
|
54
|
+
deferable = new $.Deferred();
|
55
|
+
command = {
|
56
|
+
query: selector,
|
57
|
+
selector_engine: engine,
|
58
|
+
operation: {
|
59
|
+
method_name: methodName,
|
60
|
+
"arguments": methodArgs
|
61
|
+
}
|
62
|
+
};
|
63
|
+
$.ajax({
|
64
|
+
type: "POST",
|
65
|
+
dataType: "json",
|
66
|
+
data: JSON.stringify(command),
|
67
|
+
url: baseUrlFor('/map'),
|
68
|
+
success: function(data) {
|
69
|
+
if (isErrorResponse(data)) {
|
70
|
+
displayErrorResponse(data);
|
71
|
+
deferable.reject(data);
|
72
|
+
}
|
73
|
+
return deferable.resolve(data.results);
|
74
|
+
},
|
75
|
+
error: function(xhr, status, error) {
|
76
|
+
alert("Error while talking to Frank: " + status);
|
77
|
+
return deferable.reject(error);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
return deferable.promise();
|
81
|
+
};
|
82
|
+
|
83
|
+
define(function() {
|
84
|
+
return {
|
85
|
+
fetchViewHeirarchy: fetchViewHeirarchy,
|
86
|
+
fetchOrientation: fetchOrientation,
|
87
|
+
requestSnapshotRefresh: requestSnapshotRefresh,
|
88
|
+
baseScreenshotUrl: function() {
|
89
|
+
return cacheBust(baseUrlFor('/screenshot'));
|
90
|
+
},
|
91
|
+
snapshotUrlForViewWithUid: function(uid) {
|
92
|
+
return cacheBust(baseUrlFor("/screenshot/view-snapshot/" + uid));
|
93
|
+
},
|
94
|
+
sendFlashCommand: function(selector, engine) {
|
95
|
+
return sendMapRequest({
|
96
|
+
selector: selector,
|
97
|
+
engine: engine,
|
98
|
+
methodName: 'FEX_flash'
|
99
|
+
});
|
100
|
+
},
|
101
|
+
sendTouchCommand: function(selector, engine) {
|
102
|
+
return sendMapRequest({
|
103
|
+
selector: selector,
|
104
|
+
engine: engine,
|
105
|
+
methodName: 'touch'
|
106
|
+
});
|
107
|
+
},
|
108
|
+
getAccessibilityFramesForViewsMatchingSelector: function(selector, engine) {
|
109
|
+
return sendMapRequest({
|
110
|
+
selector: selector,
|
111
|
+
engine: engine,
|
112
|
+
methodName: 'accessibilityFrame'
|
113
|
+
});
|
114
|
+
}
|
115
|
+
};
|
116
|
+
});
|
117
|
+
|
118
|
+
}).call(this);
|