Skip to content

Adding a new test case to simulate spreadsheet behavior #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MotionMark/resources/debug-runner/tests.js
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions MotionMark/tests/simple/resources/simple-canvas-paths.js
Original file line number Diff line number Diff line change
@@ -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;