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

Delta Between Two Patch Sets: test/subscriptionClasses.js

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Created March 15, 2017, 3:05 p.m.
Right Patch Set: Addressed comments Created April 13, 2017, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/subscriptionClasses.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 let {createSandbox} = require("./_common"); 20 let {createSandbox} = require("./_common");
21 21
22 let Filter = null; 22 let Filter = null;
23 let Subscription = null; 23 let Subscription = null;
24 let SpecialSubscription = null; 24 let SpecialSubscription = null;
25 let DownloadableSubscription = null; 25 let DownloadableSubscription = null;
26 let RegularSubscription = null; 26 let RegularSubscription = null;
27 let ExternalSubscription = null; 27 let ExternalSubscription = null;
28 28
29 exports.setUp = function(callback) 29 exports.setUp = function(callback)
30 { 30 {
31 let sandboxedRequire = createSandbox(); 31 let sandboxedRequire = createSandbox();
32 ({Filter} = sandboxedRequire("../lib/filterClassesNew")); 32 ({Filter} = sandboxedRequire("../lib/filterClasses"));
33 ( 33 (
34 { 34 {
35 Subscription, SpecialSubscription, DownloadableSubscription 35 Subscription, SpecialSubscription, DownloadableSubscription
36 } = sandboxedRequire("../lib/subscriptionClassesNew") 36 } = sandboxedRequire("../lib/subscriptionClasses")
37 ); 37 );
38 callback(); 38 callback();
39 }; 39 };
40 40
41 function compareSubscription(test, url, expected, postInit) 41 function compareSubscription(test, url, expected, postInit)
42 { 42 {
43 expected.push("[Subscription]") 43 expected.push("[Subscription]")
44 let subscription = Subscription.fromURL(url); 44 let subscription = Subscription.fromURL(url);
45 if (postInit) 45 if (postInit)
46 postInit(subscription) 46 postInit(subscription)
(...skipping 12 matching lines...) Expand all
59 }; 59 };
60 60
61 exports.testSubscriptionsWithState = function(test) 61 exports.testSubscriptionsWithState = function(test)
62 { 62 {
63 compareSubscription(test, "~fl~", ["url=~fl~"]); 63 compareSubscription(test, "~fl~", ["url=~fl~"]);
64 compareSubscription(test, "http://test/default", ["url=http://test/default", " title=http://test/default"]); 64 compareSubscription(test, "http://test/default", ["url=http://test/default", " title=http://test/default"]);
65 compareSubscription(test, "http://test/default_titled", ["url=http://test/defa ult_titled", "title=test"], function(subscription) 65 compareSubscription(test, "http://test/default_titled", ["url=http://test/defa ult_titled", "title=test"], function(subscription)
66 { 66 {
67 subscription.title = "test"; 67 subscription.title = "test";
68 }); 68 });
69 compareSubscription(test, "http://test/non_default", ["url=http://test/non_def ault", "title=test", "fixedTitle=true", 69 compareSubscription(test, "http://test/non_default", [
70 "disabled=true", "lastSuccess= 8", "lastDownload=12", "lastCheck=16", "softExpiration=18", "expires=20", "downl oadStatus=foo", 70 "url=http://test/non_default", "title=test", "fixedTitle=true",
71 "errors=3", "version=24", "req uiredVersion=0.6"], function(subscription) 71 "disabled=true", "lastSuccess=20015998341138",
72 "lastDownload=5124097847590911", "lastCheck=18446744069414584320",
73 "softExpiration=2682143778081159", "expires=4294967295",
74 "downloadStatus=foo", "errors=3", "version=24", "requiredVersion=0.6"
75 ], function(subscription)
72 { 76 {
73 subscription.title = "test"; 77 subscription.title = "test";
74 subscription.fixedTitle = true; 78 subscription.fixedTitle = true;
75 subscription.disabled = true; 79 subscription.disabled = true;
76 subscription.lastSuccess = 8; 80 subscription.lastSuccess = 20015998341138; // 0x123456789012
77 subscription.lastDownload = 12; 81 subscription.lastDownload = 5124097847590911; // 0x123456FFFFFFFF
78 subscription.lastCheck = 16; 82 subscription.lastCheck = 18446744069414584320; // 0xFFFFFFFF00000000
79 subscription.softExpiration = 18; 83 subscription.softExpiration = 2682143778081159; // 0x9876543210987
80 subscription.expires = 20; 84 subscription.expires = 4294967295; // 0xFFFFFFFF
81 subscription.downloadStatus = "foo"; 85 subscription.downloadStatus = "foo";
82 subscription.errors = 3; 86 subscription.errors = 3;
83 subscription.version = 24 87 subscription.version = 24
84 subscription.requiredVersion = "0.6"; 88 subscription.requiredVersion = "0.6";
85 }); 89 });
86 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr oup"], function(subscription) 90 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr oup"], function(subscription)
87 { 91 {
88 subscription.title = "Test group"; 92 subscription.title = "Test group";
89 subscription.disabled = true; 93 subscription.disabled = true;
90 }); 94 });
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 157
154 subscription1.delete(); 158 subscription1.delete();
155 subscription2.delete(); 159 subscription2.delete();
156 160
157 let subscription3 = Subscription.fromURL("http://example.com/"); 161 let subscription3 = Subscription.fromURL("http://example.com/");
158 test.equal(subscription3.lastDownload, 0, "Subscription data has been reset on ce previous instances have been released"); 162 test.equal(subscription3.lastDownload, 0, "Subscription data has been reset on ce previous instances have been released");
159 subscription3.delete(); 163 subscription3.delete();
160 164
161 test.done(); 165 test.done();
162 }; 166 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld