| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 4 <script src="../../http/tests/inspector/inspector-test.js"></script> | 4 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function initialize_ChunkedFileReaderTest() | 7 function initialize_ChunkedFileReaderTest() |
| 8 { | 8 { |
| 9 | 9 |
| 10 InspectorTest.TestOutputStreamDelegate = function(doneCallback) | 10 InspectorTest.TestOutputStreamDelegate = function(doneCallback) |
| 11 { | 11 { |
| 12 this._doneCallback = doneCallback; | 12 this._doneCallback = doneCallback; |
| 13 this._chunkCount = 0; | 13 this._chunkCount = 0; |
| 14 } | 14 } |
| 15 | 15 |
| 16 InspectorTest.TestOutputStreamDelegate.prototype = { | 16 InspectorTest.TestOutputStreamDelegate.prototype = { |
| 17 onTransferStarted: function() | 17 onTransferStarted: function() |
| 18 { | 18 { |
| 19 InspectorTest.addResult("WebInspector.OutputStreamDelegate.onTransferSta
rted() called"); | 19 InspectorTest.addResult("Bindings.OutputStreamDelegate.onTransferStarted
() called"); |
| 20 }, | 20 }, |
| 21 | 21 |
| 22 onTransferFinished: function() | 22 onTransferFinished: function() |
| 23 { | 23 { |
| 24 InspectorTest.addResult("Chunks transferred: " + this._chunkCount); | 24 InspectorTest.addResult("Chunks transferred: " + this._chunkCount); |
| 25 InspectorTest.addResult("WebInspector.OutputStreamDelegate.onTransferFin
ished() called"); | 25 InspectorTest.addResult("Bindings.OutputStreamDelegate.onTransferFinishe
d() called"); |
| 26 this._doneCallback(); | 26 this._doneCallback(); |
| 27 }, | 27 }, |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @param {!WebInspector.ChunkedReader} reader | 30 * @param {!Bindings.ChunkedReader} reader |
| 31 */ | 31 */ |
| 32 onChunkTransferred: function(reader) | 32 onChunkTransferred: function(reader) |
| 33 { | 33 { |
| 34 this._chunkCount++; | 34 this._chunkCount++; |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * @param {!WebInspector.ChunkedReader} reader | 38 * @param {!Bindings.ChunkedReader} reader |
| 39 * @param {!Event} event | 39 * @param {!Event} event |
| 40 */ | 40 */ |
| 41 onError: function(reader, event) | 41 onError: function(reader, event) |
| 42 { | 42 { |
| 43 InspectorTest.addResult("WebInspector.OutputStreamDelegate.onError() cal
led"); | 43 InspectorTest.addResult("Bindings.OutputStreamDelegate.onError() called"
); |
| 44 this._doneCallback(); | 44 this._doneCallback(); |
| 45 } | 45 } |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } | 48 } |
| 49 | 49 |
| 50 function test() | 50 function test() |
| 51 { | 51 { |
| 52 var text = ["Латынь из моды вышла ныне:\n", | 52 var text = ["Латынь из моды вышла ныне:\n", |
| 53 "Так, если правду вам сказать,\n", | 53 "Так, если правду вам сказать,\n", |
| 54 "Он знал довольно по-латыне,\n", | 54 "Он знал довольно по-латыне,\n", |
| 55 "Чтоб эпиграфы разбирать\n"]; | 55 "Чтоб эпиграфы разбирать\n"]; |
| 56 | 56 |
| 57 var blob = new Blob(text); | 57 var blob = new Blob(text); |
| 58 // Most of the characters above will be encoded as 2 bytes, so make sure we
use odd | 58 // Most of the characters above will be encoded as 2 bytes, so make sure we
use odd |
| 59 // chunk size to cause chunk boundaries sometimes to happen between chaacter
bytes. | 59 // chunk size to cause chunk boundaries sometimes to happen between chaacter
bytes. |
| 60 var chunkSize = 5; | 60 var chunkSize = 5; |
| 61 var reader = new WebInspector.ChunkedFileReader(blob, chunkSize, new Inspect
orTest.TestOutputStreamDelegate(onTransferFinished)); | 61 var reader = new Bindings.ChunkedFileReader(blob, chunkSize, new InspectorTe
st.TestOutputStreamDelegate(onTransferFinished)); |
| 62 var output = new WebInspector.StringOutputStream(); | 62 var output = new Common.StringOutputStream(); |
| 63 reader.start(output); | 63 reader.start(output); |
| 64 function onTransferFinished() | 64 function onTransferFinished() |
| 65 { | 65 { |
| 66 InspectorTest.assertEquals(text.join(""), output.data(), "Read text is d
ifferent from written text"); | 66 InspectorTest.assertEquals(text.join(""), output.data(), "Read text is d
ifferent from written text"); |
| 67 InspectorTest.addResult("DONE"); | 67 InspectorTest.addResult("DONE"); |
| 68 InspectorTest.completeTest(); | 68 InspectorTest.completeTest(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 </script> | 72 </script> |
| 73 </head> | 73 </head> |
| 74 | 74 |
| 75 <body onload="runTest()"> | 75 <body onload="runTest()"> |
| 76 <p> | 76 <p> |
| 77 This tests that ChunkedFileReader properly re-assembles chunks, especially in ca
se these contain multibyte characters. | 77 This tests that ChunkedFileReader properly re-assembles chunks, especially in ca
se these contain multibyte characters. |
| 78 </p> | 78 </p> |
| 79 | 79 |
| 80 </body> | 80 </body> |
| 81 </html> | 81 </html> |
| OLD | NEW |