| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* Copyright (C) 2006-2016 Eyeo GmbH | |
| 2 * | |
| 3 * Adblock Plus is free software: you can redistribute it and/or modify | |
| 4 * it under the terms of the GNU General Public License version 3 as | |
| 5 * published by the Free Software Foundation. | |
| 6 * | |
| 7 * Adblock Plus is distributed in the hope that it will be useful, | |
| 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 * GNU General Public License for more details. | |
| 11 * | |
| 12 * You should have received a copy of the GNU General Public License | |
| 13 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 14 */ | |
| 15 | |
| 16 | |
| 17 (function() | |
| 18 { | |
| 19 var IO = require("io").IO; | |
|
kzar
2016/08/22 15:38:33
You're requiring the same module twice here, I don
Oleksandr
2016/08/31 21:54:36
Done.
| |
| 20 var io = require("io"); | |
| 21 module("IO validation"); | |
| 22 | |
| 23 test("Test writing entry larger than 1Mb but smaller than 5Mb", function(asser t) | |
|
kzar
2016/08/22 15:38:33
Nit: If we're just supporting Edge anyway I guess
Oleksandr
2016/08/31 21:54:36
Done.
| |
| 24 { | |
| 25 var testDataOver1Mb = new Array(30000); | |
| 26 testReadWrite(testDataOver1Mb, "testFile1Mb", assert); | |
| 27 expect(2); | |
| 28 }); | |
| 29 | |
| 30 test("Test writing entry larger than 5Mb", function(assert) | |
| 31 { | |
| 32 var testDataOver5Mb = new Array(300000); | |
|
kzar
2016/08/22 15:38:33
Indentation seems wrong, should be two spaces.
Oleksandr
2016/08/31 21:54:36
Done.
| |
| 33 testReadWrite(testDataOver5Mb, "testFile5Mb", assert); | |
| 34 expect(2); | |
| 35 }); | |
| 36 | |
| 37 function DummyParser() | |
| 38 { | |
| 39 readData = new Array(); | |
| 40 }; | |
| 41 DummyParser.prototype = | |
| 42 { | |
| 43 readData: new Array(), | |
|
kzar
2016/08/22 15:38:33
Why not array literal? (Same elsewhere.)
Oleksandr
2016/08/31 21:54:36
Done.
| |
| 44 process: function (line) { | |
| 45 this.readData.push(line); | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 function testReadWrite(data, fileName, assert) | |
|
kzar
2016/08/22 15:38:33
Please put the testReadWrite function above where
| |
| 50 { | |
| 51 // For debugging purposes clear the storage | |
|
kzar
2016/08/22 15:38:32
Will this trash the user's saved filters? Also thi
Oleksandr
2016/08/31 21:54:36
This was just a comment I forgot to remove. The co
| |
| 52 var fileWritten = assert.async(); | |
| 53 for (var index = 0; index < data.length; index++) { | |
| 54 data[index] = "test string " + index; | |
| 55 } | |
| 56 IO.writeToFile(IO.resolveFilePath(fileName), data, | |
| 57 function() { }); | |
| 58 setTimeout(function() | |
| 59 { | |
| 60 fileWritten(); | |
| 61 | |
| 62 var fileRead = assert.async(); | |
| 63 var dummyParser = new DummyParser(); | |
| 64 dummyParser.readData = []; | |
| 65 IO.readFromFile(IO.resolveFilePath(fileName), | |
|
kzar
2016/08/22 15:38:33
Nit: Mind indenting this like so?
IO.readFromFile
Oleksandr
2016/08/31 21:54:36
Done.
| |
| 66 dummyParser, | |
| 67 function() | |
| 68 { | |
| 69 equal(dummyParser.readData.length, data.length, | |
| 70 "Check if read entry is the same size as written"); | |
| 71 equal(dummyParser.readData[20000], data[20000], | |
| 72 "Check if read entry element is the same as written" ); | |
| 73 fileRead(); | |
| 74 }); | |
| 75 | |
| 76 }, | |
| 77 1000); | |
| 78 | |
| 79 } | |
| 80 })(); | |
| OLD | NEW |