middleman 2.0.9.pre.2-x86-mingw32 → 2.0.9.pre.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/features/builder.feature +6 -0
- data/features/data.feature +16 -1
- data/features/fonts.feature +11 -0
- data/features/relative_assets.feature +8 -2
- data/features/step_definitions/middleman_steps.rb +9 -2
- data/fixtures/data-app/config.rb +3 -0
- data/fixtures/data-app/data/pages.yml +6 -0
- data/fixtures/data-app/source/index.html.haml +1 -0
- data/fixtures/data-app/source/layout.haml +3 -0
- data/fixtures/fonts-app/config.rb +0 -0
- data/fixtures/fonts-app/source/fonts/StMarie-Thin.otf +0 -0
- data/fixtures/fonts-app/source/stylesheets/fonts.css.sass +3 -0
- data/fixtures/glob-app/config.rb +1 -0
- data/fixtures/glob-app/source/index.html.haml +6 -0
- data/fixtures/glob-app/source/stylesheets/site.css.sass +1 -0
- data/fixtures/test-app/config.rb +1 -0
- data/fixtures/test-app/data/test2.json +4 -0
- data/fixtures/test-app/source/data3.html.erb +1 -0
- data/lib/middleman/base.rb +8 -3
- data/lib/middleman/builder.rb +61 -22
- data/lib/middleman/cli.rb +2 -1
- data/lib/middleman/core_extensions/assets.rb +1 -1
- data/lib/middleman/core_extensions/compass.rb +6 -2
- data/lib/middleman/core_extensions/data.rb +20 -3
- data/lib/middleman/templates/html5.rb +1 -0
- data/lib/middleman/templates/mobile.rb +17 -0
- data/lib/middleman/templates/mobile/source/404.html +38 -0
- data/lib/middleman/templates/mobile/source/README.markdown +64 -0
- data/lib/middleman/templates/mobile/source/crossdomain.xml +25 -0
- data/lib/middleman/templates/mobile/source/css/style.css +236 -0
- data/lib/middleman/templates/mobile/source/default.appcache +17 -0
- data/lib/middleman/templates/mobile/source/humans.txt +43 -0
- data/lib/middleman/templates/mobile/source/img/h/apple-touch-icon.png +0 -0
- data/lib/middleman/templates/mobile/source/img/h/splash.png +0 -0
- data/lib/middleman/templates/mobile/source/img/l/apple-touch-icon-precomposed.png +0 -0
- data/lib/middleman/templates/mobile/source/img/l/apple-touch-icon.png +0 -0
- data/lib/middleman/templates/mobile/source/img/l/splash.png +0 -0
- data/lib/middleman/templates/mobile/source/img/m/apple-touch-icon.png +0 -0
- data/lib/middleman/templates/mobile/source/index.html +95 -0
- data/lib/middleman/templates/mobile/source/js/libs/jquery-1.5.1.js +8316 -0
- data/lib/middleman/templates/mobile/source/js/libs/jquery-1.5.1.min.js +16 -0
- data/lib/middleman/templates/mobile/source/js/libs/modernizr-custom.js +14 -0
- data/lib/middleman/templates/mobile/source/js/libs/respond.min.js +7 -0
- data/lib/middleman/templates/mobile/source/js/mylibs/helper.js +147 -0
- data/lib/middleman/templates/mobile/source/js/script.js +0 -0
- data/lib/middleman/templates/mobile/source/robots.txt +5 -0
- data/lib/middleman/templates/mobile/source/sitemap.xml +10 -0
- data/lib/middleman/templates/mobile/source/test/index.html +31 -0
- data/lib/middleman/templates/mobile/source/test/qunit/qunit.css +148 -0
- data/lib/middleman/templates/mobile/source/test/qunit/qunit.js +1265 -0
- data/lib/middleman/templates/mobile/source/test/tests.js +26 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF +0 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet +31 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet +2 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx +195 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx +44 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp +225 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet +35 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet +2 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp +51 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php +176 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet +30 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet +4 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php +44 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl +195 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet +27 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet +1 -0
- data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl +38 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING +202 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js +559 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html +43 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js +57 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png +0 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png +0 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images +33 -0
- data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png +0 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/README +27 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/databasefactory.js +45 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbworker.js +324 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbworker_test.html +393 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbworkerstarter.js +32 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_gears.js +595 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html +404 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_html5.js +203 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html +468 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapperapi.js +202 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapperapi_test.html +51 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gears_resultset.js +71 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gears_resultset_test.html +86 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gears_transaction.js +196 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gears_transaction_test.html +221 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gearsutils.js +94 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/gearsutils_test.html +84 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/global_functions.js +72 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/index.html +347 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js +503 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/styles.css +66 -0
- data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/template.js +75 -0
- data/lib/middleman/version.rb +1 -1
- data/middleman-x86-mingw32.gemspec +0 -1
- data/middleman.gemspec +3 -2
- metadata +103 -6
- data/lib/middleman/config.ru +0 -2
- data/lib/middleman/features/tiny_src.rb +0 -11
@@ -0,0 +1,468 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<!--
|
3
|
+
Copyright 2009 Google Inc.
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
-->
|
17
|
+
|
18
|
+
<html>
|
19
|
+
<head>
|
20
|
+
<title>Database wrapper tests</title>
|
21
|
+
<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
|
22
|
+
<script type="text/javascript" src="jsmock.js"></script>
|
23
|
+
<script type="text/javascript" src="global_functions.js"></script>
|
24
|
+
<script type="text/javascript" src="dbwrapperapi.js"></script>
|
25
|
+
<script type="text/javascript" src="dbwrapper_html5.js"></script>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<script type='text/javascript'>
|
29
|
+
|
30
|
+
var mockControl;
|
31
|
+
var html5Tx;
|
32
|
+
var callbackMock;
|
33
|
+
var html5Window;
|
34
|
+
var html5Db;
|
35
|
+
var populateMock;
|
36
|
+
|
37
|
+
function setUp() {
|
38
|
+
mockControl = new MockControl();
|
39
|
+
html5Tx = mockControl.createMock({executeSql: function(){}});
|
40
|
+
callbackMock = mockControl.createMock({onSuccess: function(){},
|
41
|
+
onFailure: function(){}});
|
42
|
+
html5Window = mockControl.createMock({openDatabase: function(){}});
|
43
|
+
html5Db = mockControl.createMock({transaction: function(){}});
|
44
|
+
populateMock = mockControl.createMock({populate: function(){}});
|
45
|
+
|
46
|
+
dbTx = mockControl.createMock({execute: function(){}, executeAll:
|
47
|
+
function(){}});
|
48
|
+
dbRows = mockControl.createMock({item: function(){}});
|
49
|
+
}
|
50
|
+
|
51
|
+
function testConstructTransaction() {
|
52
|
+
var trans = new google.wspl.html5.Transaction('foo');
|
53
|
+
assertEquals('transaction instance not set correctly', 'foo', trans.tx_);
|
54
|
+
}
|
55
|
+
|
56
|
+
function testTransactionExecuteAll() {
|
57
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
58
|
+
|
59
|
+
try {
|
60
|
+
trans.executeAll([], callbackMock);
|
61
|
+
fail('Should never get here');
|
62
|
+
} catch(e) {
|
63
|
+
assertEquals(
|
64
|
+
'did not exception fault on empty statement list',
|
65
|
+
'Error: Possibly silly attempt to execute empty statement list.',
|
66
|
+
e.toString());
|
67
|
+
}
|
68
|
+
mockControl.verify();
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
The sequence of digits at the end of the test names indicate as boolean
|
73
|
+
variables the success or failure of each statement.
|
74
|
+
*/
|
75
|
+
function testTransactionExecuteAll_1() {
|
76
|
+
var stat1 = new google.wspl.Statement('stat1');
|
77
|
+
|
78
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
79
|
+
|
80
|
+
var successCallback = null;
|
81
|
+
var failureCallback = null;
|
82
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
83
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
84
|
+
successCallback = arguments[2];
|
85
|
+
});
|
86
|
+
|
87
|
+
callbackMock.expects().onSuccess(trans,
|
88
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
89
|
+
assertEquals('result not returned', 'resultset', arguments[1].result_)});
|
90
|
+
|
91
|
+
trans.executeAll([stat1], callbackMock);
|
92
|
+
successCallback(html5Tx, 'resultset');
|
93
|
+
mockControl.verify();
|
94
|
+
}
|
95
|
+
|
96
|
+
function testTransactionExecuteAll_11() {
|
97
|
+
var stat1 = new google.wspl.Statement('stat1');
|
98
|
+
var stat2 = new google.wspl.Statement('stat2', [1]);
|
99
|
+
|
100
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
101
|
+
|
102
|
+
var successCallback1 = null;
|
103
|
+
var successCallback2 = null;
|
104
|
+
var failureCallback = null;
|
105
|
+
|
106
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
107
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
108
|
+
successCallback1 = arguments[2];
|
109
|
+
});
|
110
|
+
|
111
|
+
html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
|
112
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
113
|
+
successCallback2 = arguments[2];
|
114
|
+
var params = arguments[1];
|
115
|
+
assertEquals('incorrect params to sql', 1, params[0]);
|
116
|
+
});
|
117
|
+
|
118
|
+
callbackMock.expects().onSuccess(trans,
|
119
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
120
|
+
assertEquals('result not returned', 'resultset1', arguments[1].result_)});
|
121
|
+
|
122
|
+
callbackMock.expects().onSuccess(trans,
|
123
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
124
|
+
assertEquals('result not returned', 'resultset2', arguments[1].result_)});
|
125
|
+
|
126
|
+
trans.executeAll([stat1, stat2], callbackMock);
|
127
|
+
successCallback1(html5Tx, 'resultset1');
|
128
|
+
successCallback2(html5Tx, 'resultset2');
|
129
|
+
mockControl.verify();
|
130
|
+
}
|
131
|
+
|
132
|
+
function testTransactionExecuteAll_111() {
|
133
|
+
var stat1 = new google.wspl.Statement('stat1');
|
134
|
+
var stat2 = new google.wspl.Statement('stat2', [1]);
|
135
|
+
var stat3 = new google.wspl.Statement('stat3', [2, 3]);
|
136
|
+
|
137
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
138
|
+
|
139
|
+
var successCallback1 = null;
|
140
|
+
var successCallback2 = null;
|
141
|
+
var successCallback3 = null;
|
142
|
+
var failureCallback = null;
|
143
|
+
|
144
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
145
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
146
|
+
successCallback1 = arguments[2];
|
147
|
+
});
|
148
|
+
|
149
|
+
html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
|
150
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
151
|
+
successCallback2 = arguments[2];
|
152
|
+
var params = arguments[1];
|
153
|
+
assertEquals('incorrect params to sql', 1, params[0]);
|
154
|
+
});
|
155
|
+
|
156
|
+
html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
|
157
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
158
|
+
successCallback3 = arguments[2];
|
159
|
+
var params = arguments[1];
|
160
|
+
assertEquals('incorrect params to sql', 2, params[0]);
|
161
|
+
assertEquals('incorrect params to sql', 3, params[1]);
|
162
|
+
});
|
163
|
+
|
164
|
+
callbackMock.expects().onSuccess(trans,
|
165
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
166
|
+
assertEquals('result not returned', 'resultset1', arguments[1].result_)});
|
167
|
+
|
168
|
+
callbackMock.expects().onSuccess(trans,
|
169
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
170
|
+
assertEquals('result not returned', 'resultset2', arguments[1].result_)});
|
171
|
+
|
172
|
+
callbackMock.expects().onSuccess(trans,
|
173
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
174
|
+
assertEquals('result not returned', 'resultset3', arguments[1].result_)});
|
175
|
+
|
176
|
+
trans.executeAll([stat1, stat2, stat3], callbackMock);
|
177
|
+
successCallback1(html5Tx, 'resultset1');
|
178
|
+
successCallback2(html5Tx, 'resultset2');
|
179
|
+
successCallback3(html5Tx, 'resultset3');
|
180
|
+
mockControl.verify();
|
181
|
+
}
|
182
|
+
|
183
|
+
function testTransactionExecuteAll_noCallback_111() {
|
184
|
+
var stat1 = new google.wspl.Statement('stat1');
|
185
|
+
var stat2 = new google.wspl.Statement('stat2', [1]);
|
186
|
+
var stat3 = new google.wspl.Statement('stat3', [2, 3]);
|
187
|
+
|
188
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
189
|
+
|
190
|
+
var successCallback1 = null;
|
191
|
+
var successCallback2 = null;
|
192
|
+
var successCallback3 = null;
|
193
|
+
var failureCallback = null;
|
194
|
+
|
195
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
196
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
197
|
+
successCallback1 = arguments[2];
|
198
|
+
});
|
199
|
+
|
200
|
+
html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
|
201
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(
|
202
|
+
function() { successCallback2 = arguments[2];
|
203
|
+
var params = arguments[1];
|
204
|
+
assertEquals('incorrect params to sql', 1, params[0]);
|
205
|
+
});
|
206
|
+
|
207
|
+
html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
|
208
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(
|
209
|
+
function() { successCallback3 = arguments[2];
|
210
|
+
var params = arguments[1];
|
211
|
+
assertEquals('incorrect params to sql', 2, params[0]);
|
212
|
+
assertEquals('incorrect params to sql', 3, params[1]);
|
213
|
+
});
|
214
|
+
|
215
|
+
trans.executeAll([stat1, stat2, stat3]);
|
216
|
+
successCallback1(html5Tx, 'resultset1');
|
217
|
+
successCallback2(html5Tx, 'resultset2');
|
218
|
+
successCallback3(html5Tx, 'resultset3');
|
219
|
+
mockControl.verify();
|
220
|
+
}
|
221
|
+
|
222
|
+
function testTransactionExecuteAll_110() {
|
223
|
+
var stat1 = new google.wspl.Statement('stat1');
|
224
|
+
var stat2 = new google.wspl.Statement('stat2', [1]);
|
225
|
+
var stat3 = new google.wspl.Statement('stat3', [2, 3]);
|
226
|
+
|
227
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
228
|
+
|
229
|
+
var successCallback1 = null;
|
230
|
+
var successCallback2 = null;
|
231
|
+
var successCallback3 = null;
|
232
|
+
var failureCallback3 = null;
|
233
|
+
|
234
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
235
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
236
|
+
successCallback1 = arguments[2];
|
237
|
+
});
|
238
|
+
|
239
|
+
html5Tx.expects().executeSql('stat2', TypeOf.isA(Array),
|
240
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
241
|
+
successCallback2 = arguments[2];
|
242
|
+
var params = arguments[1];
|
243
|
+
assertEquals('incorrect params to sql', 1, params[0]);
|
244
|
+
});
|
245
|
+
|
246
|
+
html5Tx.expects().executeSql('stat3', TypeOf.isA(Array),
|
247
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
248
|
+
successCallback3 = arguments[2];
|
249
|
+
failureCallback3 = arguments[3];
|
250
|
+
var params = arguments[1];
|
251
|
+
assertEquals('incorrect params to sql', 2, params[0]);
|
252
|
+
assertEquals('incorrect params to sql', 3, params[1]);
|
253
|
+
});
|
254
|
+
|
255
|
+
callbackMock.expects().onSuccess(trans,
|
256
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
257
|
+
assertEquals('result not returned', 'resultset1', arguments[1].result_)});
|
258
|
+
|
259
|
+
callbackMock.expects().onSuccess(trans,
|
260
|
+
TypeOf.isA(google.wspl.html5.ResultSet)).andStub(function() {
|
261
|
+
assertEquals('result not returned', 'resultset2', arguments[1].result_)});
|
262
|
+
|
263
|
+
callbackMock.expects().onFailure('error3');
|
264
|
+
|
265
|
+
trans.executeAll([stat1, stat2, stat3], callbackMock);
|
266
|
+
successCallback1(html5Tx, 'resultset1');
|
267
|
+
successCallback2(html5Tx, 'resultset2');
|
268
|
+
assertTrue('failure case callback not terminating transaction',
|
269
|
+
failureCallback3(html5Tx, 'error3'));
|
270
|
+
mockControl.verify();
|
271
|
+
}
|
272
|
+
|
273
|
+
function testTransactionExecute_nocallback() {
|
274
|
+
var stat1 = new google.wspl.Statement('stat1');
|
275
|
+
|
276
|
+
var trans = new google.wspl.html5.Transaction(html5Tx);
|
277
|
+
|
278
|
+
var successCallback = null;
|
279
|
+
var failureCallback = null;
|
280
|
+
html5Tx.expects().executeSql('stat1', TypeOf.isA(Array),
|
281
|
+
TypeOf.isA(Function), TypeOf.isA(Function)).andStub(function() {
|
282
|
+
successCallback = arguments[2];
|
283
|
+
});
|
284
|
+
|
285
|
+
trans.execute(stat1);
|
286
|
+
successCallback(html5Tx, 'resultset');
|
287
|
+
mockControl.verify();
|
288
|
+
}
|
289
|
+
|
290
|
+
function buildDatabase() {
|
291
|
+
html5Window.expects().openDatabase('name', '', 'name',
|
292
|
+
google.wspl.LARGEST_SUPPORTED_DATABASE).
|
293
|
+
andReturn(html5Db);
|
294
|
+
return new google.wspl.html5.Database('name', html5Window);
|
295
|
+
}
|
296
|
+
|
297
|
+
function testConstructDatabase() {
|
298
|
+
var db = buildDatabase();
|
299
|
+
mockControl.verify();
|
300
|
+
assertEquals('did not set db_ correctly', db.db_, html5Db);
|
301
|
+
}
|
302
|
+
|
303
|
+
function testConstructDatabase_null() {
|
304
|
+
html5Window.expects().openDatabase('name', '', 'name',
|
305
|
+
google.wspl.LARGEST_SUPPORTED_DATABASE).
|
306
|
+
andReturn(null);
|
307
|
+
try {
|
308
|
+
var db = google.wspl.html5.Database('name', html5Window);
|
309
|
+
fail('Should never get here');
|
310
|
+
} catch (e) {
|
311
|
+
if (e.isJsUnitException) {
|
312
|
+
throw e;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
mockControl.verify();
|
316
|
+
}
|
317
|
+
|
318
|
+
function testConstructDatabase_undefined() {
|
319
|
+
html5Window.expects().openDatabase('name', '', 'name',
|
320
|
+
google.wspl.LARGEST_SUPPORTED_DATABASE).
|
321
|
+
andReturn(undefined);
|
322
|
+
try {
|
323
|
+
var db = google.wspl.html5.Database('name', html5Window);
|
324
|
+
fail('Should never get here');
|
325
|
+
} catch (e) {
|
326
|
+
if (e.isJsUnitException) {
|
327
|
+
throw e;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
mockControl.verify();
|
331
|
+
}
|
332
|
+
|
333
|
+
function createTransactionCore() {
|
334
|
+
var db = buildDatabase();
|
335
|
+
var fun1 = null;
|
336
|
+
var failure = null;
|
337
|
+
var success = null;
|
338
|
+
html5Db.expects().transaction(TypeOf.isA(Function), TypeOf.isA(Function),
|
339
|
+
TypeOf.isA(Function)).andStub(function() {
|
340
|
+
fun1 = arguments[0];
|
341
|
+
failure = arguments[1];
|
342
|
+
success = arguments[2];
|
343
|
+
});
|
344
|
+
|
345
|
+
var tx = null;
|
346
|
+
var populateMock = function(txa) {
|
347
|
+
tx = txa;
|
348
|
+
};
|
349
|
+
|
350
|
+
db.createTransaction(populateMock, callbackMock);
|
351
|
+
fun1('transactionTest');
|
352
|
+
|
353
|
+
assertEquals('transaction not saved', 'transactionTest', tx.tx_);
|
354
|
+
assertEquals('did not set db_ correctly', db.db_, html5Db);
|
355
|
+
|
356
|
+
return {failure: failure, success: success};
|
357
|
+
}
|
358
|
+
|
359
|
+
function testCreateTransaction_success() {
|
360
|
+
cbs = createTransactionCore();
|
361
|
+
callbackMock.expects().onSuccess();
|
362
|
+
cbs.success('success');
|
363
|
+
mockControl.verify();
|
364
|
+
}
|
365
|
+
|
366
|
+
function testCreateTransaction_failure() {
|
367
|
+
cbs = createTransactionCore();
|
368
|
+
callbackMock.expects().onFailure('error');
|
369
|
+
cbs.failure('error');
|
370
|
+
mockControl.verify();
|
371
|
+
}
|
372
|
+
|
373
|
+
function testCreateTransaction_onlyPopulate() {
|
374
|
+
cbs = createTransactionCore();
|
375
|
+
mockControl.verify();
|
376
|
+
}
|
377
|
+
|
378
|
+
function testDatabaseExecute_nocallback() {
|
379
|
+
var db = buildDatabase();
|
380
|
+
|
381
|
+
dbTx.expects().execute('statementText', null);
|
382
|
+
db.execute('statementText');
|
383
|
+
}
|
384
|
+
|
385
|
+
function testDatabaseExecute_nocallback() {
|
386
|
+
var db = buildDatabase();
|
387
|
+
|
388
|
+
dbTx.expects().execute('statementText', null);
|
389
|
+
db.execute('statementText');
|
390
|
+
}
|
391
|
+
|
392
|
+
function testDatabaseExecuteAll() {
|
393
|
+
var db = buildDatabase();
|
394
|
+
dbTx.expects().executeAll(TypeOf.isA(Array));
|
395
|
+
}
|
396
|
+
|
397
|
+
function testResultSetNext() {
|
398
|
+
var res = {rows: {length: 4}};
|
399
|
+
var result = new google.wspl.html5.ResultSet(res);
|
400
|
+
|
401
|
+
for (var i = 0; i < 4; i++) {
|
402
|
+
assertTrue('expected valid row', result.isValidRow());
|
403
|
+
result.next();
|
404
|
+
}
|
405
|
+
assertFalse('expected invalid row', result.isValidRow());
|
406
|
+
}
|
407
|
+
|
408
|
+
function testResultSetIsValidRow() {
|
409
|
+
var res = {rows: {length: 0}};
|
410
|
+
var result = new google.wspl.html5.ResultSet(res);
|
411
|
+
|
412
|
+
assertFalse('expected invalid row', result.isValidRow());
|
413
|
+
res.rows.length = 1;
|
414
|
+
assertTrue('expected valid row', result.isValidRow());
|
415
|
+
result.next();
|
416
|
+
assertFalse('expected invalid row', result.isValidRow());
|
417
|
+
}
|
418
|
+
|
419
|
+
function testResultSetGetRow() {
|
420
|
+
var res = {rows: {
|
421
|
+
length: 3,
|
422
|
+
item: function(index) {
|
423
|
+
assertEquals('expected index of 1', 1, index);
|
424
|
+
return {h0: 'value0', h1: 'value1', h2: 'value2'};
|
425
|
+
}
|
426
|
+
}};
|
427
|
+
|
428
|
+
var result = new google.wspl.html5.ResultSet(res);
|
429
|
+
result.next();
|
430
|
+
var row = result.getRow();
|
431
|
+
assertEquals('first field is not valid', 'value0', row.h0);
|
432
|
+
assertEquals('first field is not valid', 'value1', row.h1);
|
433
|
+
assertEquals('first field is not valid', 'value2', row.h2);
|
434
|
+
}
|
435
|
+
|
436
|
+
function testHasInflightTransactions() {
|
437
|
+
var fakeTime = 1000;
|
438
|
+
var db = buildDatabase();
|
439
|
+
var dummyPopulate = function() {};
|
440
|
+
db.getCurrentTime = function() {return fakeTime;};
|
441
|
+
|
442
|
+
// Create a transaction, make sure it's kept track of.
|
443
|
+
var transId = db.sequenceNum_;
|
444
|
+
db.createTransaction(dummyPopulate);
|
445
|
+
assertEquals('There should be an inflight request.',
|
446
|
+
fakeTime, db.inflightTransactions_[transId]);
|
447
|
+
|
448
|
+
// Haven't advanced time, so hasInflightTransactions should return false.
|
449
|
+
assertFalse('Expected hasInflightTransactions=false.',
|
450
|
+
db.hasInflightTransactions(100));
|
451
|
+
|
452
|
+
// Advance time, now hasInflightTransactions should return true.
|
453
|
+
fakeTime += 10000;
|
454
|
+
var faqs = db.hasInflightTransactions(100);
|
455
|
+
assertTrue('Expected hasInflightTransactions=true.',
|
456
|
+
db.hasInflightTransactions(100));
|
457
|
+
|
458
|
+
// Now now have the transaction completed, hasInflightTransactions
|
459
|
+
// should return false.
|
460
|
+
delete db.inflightTransactions_[transId];
|
461
|
+
assertFalse('Expected hasInflightTransactions=false.',
|
462
|
+
db.hasInflightTransactions(100));
|
463
|
+
|
464
|
+
};
|
465
|
+
|
466
|
+
</script>
|
467
|
+
</body>
|
468
|
+
</html>
|