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

Side by Side Diff: test/filterStorage_readwrite.js

Issue 29802575: Issue 6559 - Replace fromObject with fromMap (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 8, 2018, 1:59 p.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 | « test/filterClasses.js ('k') | test/subscriptionClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 { 94 {
95 test.ok(!FilterStorage.initialized, "Uninitialized before the first load"); 95 test.ok(!FilterStorage.initialized, "Uninitialized before the first load");
96 96
97 return testData.then(data => 97 return testData.then(data =>
98 { 98 {
99 IO._setFileContents(FilterStorage.sourceFile, data); 99 IO._setFileContents(FilterStorage.sourceFile, data);
100 return FilterStorage.loadFromDisk(); 100 return FilterStorage.loadFromDisk();
101 }).then(() => 101 }).then(() =>
102 { 102 {
103 test.ok(FilterStorage.initialized, "Initialize after the first load"); 103 test.ok(FilterStorage.initialized, "Initialize after the first load");
104 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version"); 104 test.equal(FilterStorage.fileProperties.get("version"), FilterStorage.format Version, "File format version");
105 105
106 if (withExternal) 106 if (withExternal)
107 { 107 {
108 { 108 {
109 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription"); 109 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription");
110 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")]; 110 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")];
111 FilterStorage.addSubscription(subscription); 111 FilterStorage.addSubscription(subscription);
112 } 112 }
113 113
114 let externalSubscriptions = FilterStorage.subscriptions.filter(subscriptio n => subscription instanceof ExternalSubscription); 114 let externalSubscriptions = FilterStorage.subscriptions.filter(subscriptio n => subscription instanceof ExternalSubscription);
(...skipping 26 matching lines...) Expand all
141 testData.then(lines => 141 testData.then(lines =>
142 { 142 {
143 if (lines.length && lines[lines.length - 1] == "") 143 if (lines.length && lines[lines.length - 1] == "")
144 lines.pop(); 144 lines.pop();
145 145
146 let importer = FilterStorage.importData(); 146 let importer = FilterStorage.importData();
147 for (let line of lines) 147 for (let line of lines)
148 importer(line); 148 importer(line);
149 importer(null); 149 importer(null);
150 150
151 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version"); 151 test.equal(FilterStorage.fileProperties.get("version"), FilterStorage.format Version, "File format version");
152 152
153 let exported = Array.from(FilterStorage.exportData()); 153 let exported = Array.from(FilterStorage.exportData());
154 test.deepEqual(canonize(exported), canonize(lines), "Import/export result"); 154 test.deepEqual(canonize(exported), canonize(lines), "Import/export result");
155 }).catch(unexpectedError.bind(test)).then(() => test.done()); 155 }).catch(unexpectedError.bind(test)).then(() => test.done());
156 }; 156 };
157 157
158 exports.testSavingWithoutBackups = function(test) 158 exports.testSavingWithoutBackups = function(test)
159 { 159 {
160 Prefs.patternsbackups = 0; 160 Prefs.patternsbackups = 0;
161 Prefs.patternsbackupinterval = 24; 161 Prefs.patternsbackupinterval = 24;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return FilterStorage.restoreBackup(1); 243 return FilterStorage.restoreBackup(1);
244 }).then(() => 244 }).then(() =>
245 { 245 {
246 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter restoring backup"); 246 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter restoring backup");
247 return FilterStorage.loadFromDisk(); 247 return FilterStorage.loadFromDisk();
248 }).then(() => 248 }).then(() =>
249 { 249 {
250 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter reloading"); 250 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter reloading");
251 }).catch(unexpectedError.bind(test)).then(() => test.done()); 251 }).catch(unexpectedError.bind(test)).then(() => test.done());
252 }; 252 };
OLDNEW
« no previous file with comments | « test/filterClasses.js ('k') | test/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld