-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from fbuchinger/image-metrics
Image metrics
- Loading branch information
Showing
5 changed files
with
109 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,4 @@ | |
} ); | ||
|
||
|
||
}( jQuery, QUnit ) ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
( function( window, QUnit ) { | ||
|
||
"use strict"; | ||
|
||
var testCanvas = document.getElementById('testCanvas'); | ||
|
||
QUnit.module("Layoutstats Image Metrics", { | ||
beforeEach: function () { | ||
|
||
}, | ||
afterEach: function () { | ||
// we empty the testcanvas | ||
testCanvas.innerHTML = ''; | ||
} | ||
}); | ||
|
||
function injectAndGetLayoutStats(htmlStr){ | ||
testCanvas.innerHTML = htmlStr; | ||
return layoutstats(testCanvas); | ||
} | ||
|
||
QUnit.test("measure the area of all images on the page using the imageMegapixelArea metric. It ", function (assert) { | ||
var ls = layoutstats(window.document.body); | ||
var png1px = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="; | ||
assert.notEqual(ls.imageArea, undefined, 'is available in the layoutstats object'); | ||
ls = injectAndGetLayoutStats('<img width="150" height="300" src="'+png1px+'">'); | ||
assert.equal(ls.imageArea,45000,'measures the dimension of a single image with width and height attributes' ); | ||
ls = injectAndGetLayoutStats('<img style="width:150px;height:300px;" src="'+png1px+'">'); | ||
assert.equal(ls.imageArea,45000,'measures the dimension of a single image with width and height set by css' ); | ||
}); | ||
|
||
})( window, QUnit ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters