Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
timer, +other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Jan 10, 2008
1 parent 92c6baf commit 4203b14
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ task 'build/index.html' => 'README' do |t|
end

AUTORUN_FILES = %w{autorun-browser.js autorun-lz.js autorun.css list-files.jsp}
SHARED_FILES = AUTORUN_FILES + %w(hopkit.js jsspec.js lzmock.js lzspec.js lzunit-async.lzx lzunit-extensions.js)
SHARED_FILES = AUTORUN_FILES + %w(hopkit.js jsspec.js lzmock.js lzspec.js lzunit-async.lzx lzunit-extensions.js lztimer.lzx lztimer-browser.js)

# TODO: sync sequencing.js, hopkit.js with jsutils

Expand Down
54 changes: 54 additions & 0 deletions examples/test-expects.lzx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!-- Copyright 2008 by Oliver Steele. Available under the MIT License. -->
<canvas debug="true">
<include href="../src/library.lzx"/>

<TestSuite>
<TestCase>
<method name="testArguments"><![CDATA[
function C() {}
var I = function(x){return x};
C.prototype = {a:I, b:I, c:I}

var m = mock(C);
m.expects.a(1);
m.a(2);
m.verify(this);

m.expects.a({a:1});
m.a({a:2});
m.verify(this);
]]></method>

<method name="testXML"><![CDATA[
return
m.expects.a(ds1.data);
m.a(ds2.data);
m.verify(this);

m.expects.a(ds3.data);
m.a(ds4.data);
m.verify(this);

m.expects.a(ds5.data);
m.a(ds6.data);
m.verify(this);

m.expects.a(ds7.data);
m.a(ds8.data);
m.verify(this);
]]></method>
</TestCase>
</TestSuite>

<dataset name="ds1"><e1/></dataset>
<dataset name="ds2"><e2/></dataset>

<dataset name="ds3"><e1 a="expected"/></dataset>
<dataset name="ds4"><e1 a="actual"/></dataset>

<dataset name="ds5"><e1><e2/></e1></dataset>
<dataset name="ds6"><e1/></dataset>

<dataset name="ds7"><e1>expected</e1></dataset>
<dataset name="ds8"><e1>actual</e1></dataset>
</canvas>
15 changes: 11 additions & 4 deletions src/autorun-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ window.console || (window.console={info:function(){}});
var gRunner;

function LzTestRunner(files) {
this.files = files;
this.remaining = [].concat(files);
this.current = null;
this.initialize.apply(this, arguments);
}

LzTestRunner.skip = 0;
Expand All @@ -23,6 +21,7 @@ LzTestRunner.run = function(options) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (!file.match(/\.swf$/)
&& !file.match(/^(#.*#|\.#.*|.*~)$/)
&& file.match(match)
&& (!exclude || !file.match(exclude)))
matches.push(file);
Expand All @@ -32,6 +31,12 @@ LzTestRunner.run = function(options) {
}

LzTestRunner.prototype = {
initialize: function(files) {
this.files = files;
this.remaining = [].concat(files);
this.current = null;
},

run: function() {
$('body').addClass('running');
this.runNext();
Expand Down Expand Up @@ -90,7 +95,9 @@ LzTestRunner.prototype = {
load: function(file) {
this.unload();
var app = this.current = new LzTestApplication(file);
this.status('running ' + app.url);
this.status(['running ', app.url,
' (', (this.files.length - this.remaining.length),
'/', this.files.length, ')'].join(''));
app.load();
},

Expand Down
11 changes: 9 additions & 2 deletions src/autorun-lz.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2007 by Oliver Steele. Available under the MIT License. */
/* Copyright 2007-2008 by Oliver Steele. Available under the MIT License. */

// OL 3.4 compatibility
TestSuite.addProperty != Object.addProperty
Expand Down Expand Up @@ -32,7 +32,7 @@ LzBrowser.exec = function(expr) {
if (now < nextTime)
return setTimeout(function(){LzBrowser.exec(expr)},
nextTime - now);
_root.getURL('javascript:'+expr);
_root.getURL('javascript:(function(){'+expr+'})()');
arguments.callee.nextTime = now + 100;
}

Expand All @@ -51,3 +51,10 @@ String.prototype['replace'] || (String.prototype.replace = function(pattern, sub
}
return segments.join('');
})

LzBrowser.setDefaultHTMLTitleToLoadURL = function() {
var name = LzBrowser.getLoadURL().split('?')[0].split('/').reverse()[0];
LzBrowser.exec('document.title=="OpenLaszlo Application"&&(document.title="'
+ name + '")');
}
LzBrowser.setDefaultHTMLTitleToLoadURL();
Loading

0 comments on commit 4203b14

Please sign in to comment.