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

Unified Diff: LayoutTests/http/tests/inspector/inspector-test.js

Issue 132993009: Use mock temp file in profiler tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comment Created 6 years, 11 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/inspector/profiler/heap-snapshot-loader.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/inspector/inspector-test.js
diff --git a/LayoutTests/http/tests/inspector/inspector-test.js b/LayoutTests/http/tests/inspector/inspector-test.js
index 1c3611f80f8498f419570aae2d542bedbbf5e304..e0792cbadc470f9f0fd9c99c5560f5405b502fb4 100644
--- a/LayoutTests/http/tests/inspector/inspector-test.js
+++ b/LayoutTests/http/tests/inspector/inspector-test.js
@@ -454,6 +454,79 @@ InspectorTest.MockSetting.prototype = {
}
};
+
+/**
+ * @constructor
+ * @param {!string} dirPath
+ * @param {!string} name
+ * @param {!function(?WebInspector.TempFile)} callback
+ */
+InspectorTest.TempFileMock = function(dirPath, name, callback)
+{
+ this._chunks = [];
+ this._name = name;
+ setTimeout(callback.bind(this, this), 0);
+}
+
+InspectorTest.TempFileMock.prototype = {
+ /**
+ * @param {!string} data
+ * @param {!function(boolean)} callback
+ */
+ write: function(data, callback)
+ {
+ this._chunks.push(data);
+ setTimeout(callback.bind(this, true), 0);
+ },
+
+ finishWriting: function() { },
+
+ /**
+ * @param {function(?string)} callback
+ */
+ read: function(callback)
+ {
+ callback(this._chunks.join(""));
+ },
+
+ /**
+ * @param {!WebInspector.OutputStream} outputStream
+ * @param {!WebInspector.OutputStreamDelegate} delegate
+ */
+ writeToOutputSteam: function(outputStream, delegate)
+ {
+ var name = this._name;
+ var text = this._chunks.join("");
+ var chunkedReaderMock = {
+ loadedSize: function()
+ {
+ return text.length;
+ },
+
+ fileSize: function()
+ {
+ return text.length;
+ },
+
+ fileName: function()
+ {
+ return name;
+ },
+
+ cancel: function() { }
+ }
+ delegate.onTransferStarted(chunkedReaderMock);
+ outputStream.write(text);
+ delegate.onChunkTransferred(chunkedReaderMock);
+ outputStream.close();
+ delegate.onTransferFinished(chunkedReaderMock);
+ },
+
+ remove: function() { }
+}
+
+WebInspector.TempFile = InspectorTest.TempFileMock;
+
};
var initializeCallId = 0;
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/inspector/profiler/heap-snapshot-loader.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698