Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: qunit/tests/io.js

Issue 29348062: Issue 4023 - The logic for splitting up storage.local into 1MB chunks does not work (Closed)
Patch Set: Created July 20, 2016, 11:31 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « metadata.common ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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;
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)
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);
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(),
44 process: function (line) {
45 this.readData.push(line);
46 }
47 };
48
49 function testReadWrite(data, fileName, assert)
50 {
51 // For debugging purposes clear the storage
52 chrome.storage.local.clear();
53 var fileWritten = assert.async();
54 for (var index = 0; index < data.length; index++) {
55 data[index] = "test string " + index;
56 }
57 IO.writeToFile(IO.resolveFilePath(fileName), data,
58 function() { });
59 setTimeout(function()
60 {
61 fileWritten();
62
63 var fileRead = assert.async();
64 var dummyParser = new DummyParser();
65 IO.readFromFile(IO.resolveFilePath(fileName),
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 })();
OLDNEW
« no previous file with comments | « metadata.common ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld