Skip to content

Commit bd202b2

Browse files
committed
add new test case "remote-img"
1 parent e09f5d5 commit bd202b2

File tree

7 files changed

+120
-0
lines changed

7 files changed

+120
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "remote file access",
3+
"main": "http://localhost:8123/index.html",
4+
"node-remote": "localhost"
5+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>
5+
remote file access test
6+
</title>
7+
</head>
8+
<body>
9+
<div id="img"></div>
10+
<script type="text/javascript" language="javascript">
11+
var os = require('os');
12+
var img = document.createElement("img");
13+
if (os.platform() == "win32")
14+
img.setAttribute("src", "file://c:/star.jpg");
15+
else
16+
img.setAttribute('src', "file:///tmp/star.jpg");
17+
var ad = document.getElementById("img");
18+
ad.appendChild(img);
19+
</script>
20+
</body>
21+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "remote file access",
3+
"main": "index.html"
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>remote img test</title>
6+
</head>
7+
<body>
8+
<p>remote img test</p>
9+
10+
<script src="../res/mocha_util.js"></script>
11+
<script src="mocha_test.js"></script>
12+
13+
</body>
14+
15+
</html>
16+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
var path = require('path');
2+
var spawn = require('child_process').spawn;
3+
var fs = require('fs-extra');
4+
var curDir = fs.realpathSync('.');
5+
6+
describe('remote-file-access', function(){
7+
var os = require('os');
8+
var platform = os.platform();
9+
10+
before(function(done){
11+
this.timeout(0);
12+
if(platform == "win32"){
13+
fs.copy(path.join(curDir, 'star.jpg'),'/star.jpg');
14+
}
15+
else {
16+
fs.copy(path.join(curDir, 'star.jpg'),'/tmp/star.jpg');
17+
}
18+
done();
19+
});
20+
21+
after(function() {
22+
this.timeout(0);
23+
if (platform == "win32"){
24+
fs.remove('/star.jpg');
25+
}
26+
else {
27+
fs.remove('/tmp/star.jpg');
28+
}
29+
});
30+
31+
it ('remote img should work', function(done){
32+
this.timeout(0);
33+
var exec_argv = [path.join(curDir, 'imgnotshown')]
34+
var result =false;
35+
var app = spawn(process.execPath, exec_argv);
36+
app.on('exit', function(code){
37+
result = true;
38+
done();
39+
})
40+
setTimeout(function(){
41+
if(!result){
42+
app.kill();
43+
done();
44+
}
45+
}, 3000)
46+
});
47+
48+
it ('local img should work', function(done){
49+
this.timeout(0);
50+
var exec_argv = [path.join(curDir, 'imgshown')]
51+
var result = false;
52+
var app = spawn(process.execPath, exec_argv);
53+
app.on('exit', function(code){
54+
result = true;
55+
done();
56+
});
57+
58+
setTimeout(function(){
59+
if(!result){
60+
app.kill();
61+
done();
62+
}
63+
}, 3000);
64+
65+
});
66+
67+
});
68+
69+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name":"remote_img_wrapper",
3+
"main":"index.html"
4+
}
5+

tests/automation/remote-img/star.jpg

3.76 KB
Loading

0 commit comments

Comments
 (0)