diff --git a/MotionMark/resources/debug-runner/tests.js b/MotionMark/resources/debug-runner/tests.js index accaa3c..7d2218f 100644 --- a/MotionMark/resources/debug-runner/tests.js +++ b/MotionMark/resources/debug-runner/tests.js @@ -313,6 +313,10 @@ Suites.push(new Suite("Basic canvas path suite", url: "simple/simple-canvas-paths.html?pathType=ellipse", name: "Canvas ellipses" }, + { + url: "simple/simple-canvas-paths.html?pathType=spreadSheets", + name: "Canvas spreadsheets" + }, { url: "simple/simple-canvas-paths.html?pathType=lineFill", name: "Canvas line path, fill" diff --git a/MotionMark/tests/simple/resources/simple-canvas-paths.js b/MotionMark/tests/simple/resources/simple-canvas-paths.js index cda985b..1a78030 100644 --- a/MotionMark/tests/simple/resources/simple-canvas-paths.js +++ b/MotionMark/tests/simple/resources/simple-canvas-paths.js @@ -245,6 +245,51 @@ CanvasEllipseFill = Utilities.createClass( } }); +CanvasSpreadSheets = Utilities.createClass( + function(stage) { + // Some good dark color for writing text in spreadsheet. + var dark_colors = ['#000000', '#404040', '#00008B', '#442D16', '#7E0000']; + // Some good light color for filling cells in spreadsheet. + var light_colors = ['#ADFF2F', '#ADD8E6', '#FFC0CB', '#E3C8C8', '#EBEEAF']; + // Possible text alignment in spreadsheet. + var align = ['left', 'right', 'center', 'start' , 'end'] + this._text_color = dark_colors[Stage.randomInt(0, 5)]; + this._fill_color = light_colors[Stage.randomInt(0, 5)]; + this._text_align = align[Stage.randomInt(0, 5)]; + this._start = Stage.randomPosition(stage.size) + this._color = Stage.randomColor(); + this._cell_width = Stage.randomInt(90, 150); + this._cell_height = Stage.randomInt(20, 30); + this._font = Stage.randomInt(10, 40) + 'px Arial'; + this._border_style_index = Stage.randomInt(0, 3); + this._color = Stage.randomColor(); + }, { + draw: function(context) { + context.save(); + rectPath = new Path2D(); + rectPath.rect(this._start.x, this._start.y, this._cell_width, this._cell_height); + context.clip(rectPath); + context.beginPath(); + context.globalAlpha = 0.5; + context.fillStyle = this._fill_color; + context.fill(rectPath); + context.globalAlpha = 1; + context.font = this._font; + context.fillStyle = this._text_color; + context.textAlign = this._text_align; + context.fillText("hello world", (this._start.x + this._start.x + this._cell_width)/2, this._start.y + this._cell_height); + if (this._border_style_index === 0) { + context.setLineDash([5, 5]); + } else if (this._border_style_index === 1) { + context.globalAlpha = 0.5; + } else { + context.strokeStyle = "#000000"; + } + context.stroke(rectPath); + context.restore(); + } +}); + CanvasStroke = Utilities.createClass( function (stage) { this._object = new (Stage.randomElementInArray(this.objectTypes))(stage); @@ -415,6 +460,9 @@ CanvasPathBenchmark = Utilities.createSubclass(Benchmark, case "ellipse": stage = new SimpleCanvasStage(CanvasEllipse); break; + case "spreadSheets": + stage = new SimpleCanvasStage(CanvasSpreadSheets); + break; case "lineFill": stage = new SimpleCanvasPathFillStage(CanvasLinePoint); break;