mirror of https://github.com/vitalif/phantomjs
Unit tests: robustify the tests of PDF, GIF, PNG, JPEG rendering.
Issue #10973 https://github.com/ariya/phantomjs/issues/109731.x
parent
9f1f56bc3b
commit
44c3d6080d
|
@ -1934,9 +1934,6 @@ describe("WebPage render image", function(){
|
|||
p.clipRect = { top: 0, left: 0, width: 300, height: 300};
|
||||
p.viewportSize = { width: 300, height: 300};
|
||||
|
||||
p.open( TEST_FILE_DIR + "index.html");
|
||||
waits(50);
|
||||
|
||||
function render_test( format, option ){
|
||||
var opt = option || {};
|
||||
var content, expect_content;
|
||||
|
@ -1968,42 +1965,66 @@ describe("WebPage render image", function(){
|
|||
} catch (e) { console.log(e) }
|
||||
|
||||
// for PDF test
|
||||
content = content.replace(/CreationDate \(D:\d+\)Z\)/,'');
|
||||
expect_content = expect_content.replace(/CreationDate \(D:\d+\)Z\)/,'');
|
||||
if (format === "pdf") {
|
||||
content = content.replace(/CreationDate \(D:\d+\)Z\)/,'');
|
||||
expect_content = expect_content.replace(/CreationDate \(D:\d+\)Z\)/,'');
|
||||
}
|
||||
|
||||
expect(content).toEqual(expect_content);
|
||||
// Files may not be exact, compare rought size (KB) only.
|
||||
expect(content.length >> 10).toEqual(expect_content.length >> 10);
|
||||
|
||||
// Content comparison works for PNG and JPEG.
|
||||
if (format === "png" || format === "jpg") {
|
||||
expect(content).toEqual(expect_content);
|
||||
}
|
||||
}
|
||||
|
||||
it("should render PDF file", function(){
|
||||
render_test("pdf");
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("pdf");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render PDF file with format option", function(){
|
||||
render_test("pdf", { format: "pdf" });
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("pdf", { format: "pdf" });
|
||||
});
|
||||
});
|
||||
|
||||
it("should render GIF file", function(){
|
||||
render_test("gif");
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("gif");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render GIF file with format option", function(){
|
||||
render_test("gif", { format: "gif" });
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("gif", { format: "gif" });
|
||||
});
|
||||
});
|
||||
|
||||
it("should render PNG file", function(){
|
||||
render_test("png");
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("png");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render PNG file with format option", function(){
|
||||
render_test("png", { format: "png" });
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("png", { format: "png" });
|
||||
});
|
||||
});
|
||||
|
||||
it("should render JPEG file with quality option", function(){
|
||||
render_test("jpg", { quality: 50 });
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("jpg", { quality: 50 });
|
||||
});
|
||||
});
|
||||
|
||||
it("should render JPEG file with format and quality option", function(){
|
||||
render_test("jpg", { format: 'jpg', quality: 50 });
|
||||
p.open( TEST_FILE_DIR + "index.html", function () {
|
||||
render_test("jpg", { format: 'jpg', quality: 50 });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue