+};
+
+/**
+ * Verifies that every call to context.save() has a matching call to
+ * context.restore().
+ */
+CanvasAssertions.assertBalancedSaveRestore = function(proxy) {
+ var depth = 0;
+ for (var i = 0; i < proxy.calls__.length; i++) {
+ var call = proxy.calls__[i];
+ if (call.name == "save") depth++
+ if (call.name == "restore") {
+ if (depth == 0) {
+ fail("Too many calls to restore()");
+ }
+ depth--;
+ }
+ }
+
+ if (depth > 0) {
+ fail("Missing matching 'context.restore()' calls.");
+ }
+};
+
+/**
+ * Checks how many lines of the given color have been drawn.
+ * @return {Integer} The number of lines of the given color.
+ */
+CanvasAssertions.numLinesDrawn = function(proxy, color) {
+ var num_lines = 0;
+ for (var i = 0; i < proxy.calls__.length; i++) {
+ var call = proxy.calls__[i];
+ if (call.name == "lineTo" && call.properties.strokeStyle == color) {
+ num_lines++;
+ }
+ }
+ return num_lines;
+};