summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/epoch/src/core/context.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'debian/missing-sources/epoch/src/core/context.coffee')
-rw-r--r--debian/missing-sources/epoch/src/core/context.coffee25
1 files changed, 25 insertions, 0 deletions
diff --git a/debian/missing-sources/epoch/src/core/context.coffee b/debian/missing-sources/epoch/src/core/context.coffee
new file mode 100644
index 0000000..8566552
--- /dev/null
+++ b/debian/missing-sources/epoch/src/core/context.coffee
@@ -0,0 +1,25 @@
+# Rendering context used for unit testing.
+class Epoch.TestContext
+ VOID_METHODS = [
+ 'arc', 'arcTo', 'beginPath', 'bezierCurveTo', 'clearRect',
+ 'clip', 'closePath', 'drawImage', 'fill', 'fillRect', 'fillText',
+ 'moveTo', 'quadraticCurveTo', 'rect', 'restore', 'rotate', 'save',
+ 'scale', 'scrollPathIntoView', 'setLineDash', 'setTransform',
+ 'stroke', 'strokeRect', 'strokeText', 'transform', 'translate', 'lineTo'
+ ]
+
+ # Creates a new test rendering context.
+ constructor: ->
+ @_log = []
+ @_makeFauxMethod(method) for method in VOID_METHODS
+
+ # Creates a fake method with the given name that logs the method called
+ # and arguments passed when executed.
+ # @param name Name of the fake method to create.
+ _makeFauxMethod: (name) ->
+ @[name] = -> @_log.push "#{name}(#{(arg.toString() for arg in arguments).join(',')})"
+
+ # Faux method that emulates the "getImageData" method
+ getImageData: ->
+ @_log.push "getImageData(#{(arg.toString() for arg in arguments).join(',')})"
+ return { width: 0, height: 0, resolution: 1.0, data: [] }