Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html

Issue 2681423002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Adding exceptions to TestExpectations Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html
index dd4c03ee23f39d62df72e3055cc126b6c647f444..5b81aef4619f49ff92d6a407c026207e81bace6f 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-fills.html
@@ -1,11 +1,11 @@
-<!DOCTYPE html>
-
-<script src="../../resources/js-test.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<pre id="console"></pre>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<canvas id="c" width="100" height="50"></canvas>
<script>
+// Tests that using the different composite modes to fill large rects doesn't crash and works as expected.
var canvas = document.getElementById("c");
var ctx = canvas.getContext("2d");
@@ -15,57 +15,38 @@ function clearContextToGreen() {
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
-var testData = [
- {compositeMode: 'source-over', expected: [0, 0, 255]},
- {compositeMode: 'source-in', expected: [0, 0, 255]},
- {compositeMode: 'source-out', expected: [0, 0, 0]},
- {compositeMode: 'source-atop', expected: [0, 0, 255]},
- {compositeMode: 'destination-over', expected: [0, 255, 0]},
- {compositeMode: 'destination-in', expected: [0, 255, 0]},
- {compositeMode: 'destination-out', expected: [0, 0, 0]},
- {compositeMode: 'destination-atop', expected: [0, 255, 0]},
- {compositeMode: 'lighter', expected: [0, 255, 255]},
- {compositeMode: 'copy', expected: [0, 0, 255]},
- {compositeMode: 'xor', expected: [0, 0, 0]},
+var testScenarios = [
+ ['Test source-over', 'source-over', [0, 0, 255]],
+ ['Test source-in', 'source-in', [0, 0, 255]],
+ ['Test source-out', 'source-out', [0, 0, 0]],
+ ['Test source-atop', 'source-atop', [0, 0, 255]],
+ ['Test destination-over', 'destination-over', [0, 255, 0]],
+ ['Test destiation-in', 'destination-in', [0, 255, 0]],
+ ['Test destination-out', 'destination-out', [0, 0, 0]],
+ ['Test destination-atop', 'destination-atop', [0, 255, 0]],
+ ['Test lighter', 'lighter', [0, 255, 255]],
+ ['Test copy', 'copy', [0, 0, 255]],
+ ['Test xor', 'xor', [0, 0, 0]]
];
-function toHexString(number) {
- var hexString = number.toString(16).toUpperCase();
- if (number <= 9)
- hexString = '0' + hexString;
- return hexString;
-}
-
-function doTest(dataItem, fillSize) {
+var fillSize = 0;
+function testLargeRect(compositeMode, expected) {
clearContextToGreen();
ctx.fillStyle = "rgb(0, 0, 255)";
- ctx.globalCompositeOperation = dataItem.compositeMode;
+ ctx.globalCompositeOperation = compositeMode;
ctx.fillRect(0, 0, fillSize, fillSize);
- var data = ctx.getImageData(0, 0, canvas.width, canvas.height);
- var pixelOK = true;
- var pixelString = '#';
- var expectedString = '#';
-
- for (var x = 0; x < 3; x++) {
- pixelString = pixelString + toHexString(data.data[x]);
- expectedString = expectedString + toHexString(dataItem.expected[x]);
- if (data.data[x] != dataItem.expected[x])
- pixelOK = false;
- }
-
- var testName = "Fill Size " + fillSize + ', ' + dataItem.compositeMode;
- if (pixelOK)
- testPassed(testName + ': ' + pixelString);
- else
- testFailed(testName + ': EXPECTED ' + expectedString + ', GOT ' + pixelString);
+ var data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
+ var testPassed = true;
+ for (var i = 0; i < 3; i++)
+ if (data[i] != expected[i])
+ testPassed = false;
+ assert_true(testPassed);
}
-debug("Tests that using the different composite modes to fill large rects doesn't crash and works as expected.");
-[10000, 50000, 100000].forEach(function(fillSize) {
- testData.forEach(function(dataItem) {
- doTest(dataItem, fillSize)
- })});
+[10000, 50000, 100000].forEach(function(fillSizeItem) {
+ fillSize = fillSizeItem;
+ generate_tests(testLargeRect, testScenarios);
+});
</script>
-</html>

Powered by Google App Engine
This is Rietveld 408576698