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

Delta Between Two Patch Sets: test/subscriptionClasses.js

Issue 29398669: Issue 5063 - [emscripten] Make FilterNotifier calls more efficient (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Rebased Created April 13, 2017, 1:07 p.m.
Right Patch Set: Addressed comments Created April 20, 2017, 8 a.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 | « test/filterClasses.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-2017 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
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 filter2.delete(); 259 filter2.delete();
260 260
261 test.done(); 261 test.done();
262 }; 262 };
263 263
264 exports.testNotifications = function(test) 264 exports.testNotifications = function(test)
265 { 265 {
266 function checkNotifications(action, expected, message) 266 function checkNotifications(action, expected, message)
267 { 267 {
268 let result = null; 268 let result = null;
269 let listener = (topic, subscription, newValue, oldValue) => 269 let listener = (topic, subscription) =>
270 { 270 {
271 if (result) 271 if (result)
272 test.ok(false, "Got more that one notification - " + message); 272 test.ok(false, "Got more that one notification - " + message);
273 else 273 else
274 result = [topic, subscription.url, newValue, oldValue]; 274 result = [topic, subscription.url];
275 }; 275 };
276 FilterNotifier.addListener(listener); 276 FilterNotifier.addListener(listener);
277 action(); 277 action();
278 FilterNotifier.removeListener(listener); 278 FilterNotifier.removeListener(listener);
279 test.deepEqual(result, expected, message); 279 test.deepEqual(result, expected, message);
280 } 280 }
281 281
282 let subscription = Subscription.fromURL("http://example.com/"); 282 let subscription = Subscription.fromURL("http://example.com/");
283 checkNotifications(() => 283 checkNotifications(() =>
284 { 284 {
285 subscription.title = "foobar"; 285 subscription.title = "foobar";
286 }, ["subscription.title", "http://example.com/", "foobar", "http://example.com /"], "Changing subscription title"); 286 }, ["subscription.title", "http://example.com/"], "Changing subscription title ");
287 checkNotifications(() => 287 checkNotifications(() =>
288 { 288 {
289 subscription.title = "foobar"; 289 subscription.title = "foobar";
290 }, null, "Setting subscription title to same value"); 290 }, null, "Setting subscription title to same value");
291 checkNotifications(() => 291 checkNotifications(() =>
292 { 292 {
293 subscription.title = null; 293 subscription.title = null;
294 }, ["subscription.title", "http://example.com/", "", "foobar"], "Resetting sub scription title"); 294 }, ["subscription.title", "http://example.com/"], "Resetting subscription titl e");
295 295
296 checkNotifications(() => 296 checkNotifications(() =>
297 { 297 {
298 subscription.disabled = true; 298 subscription.disabled = true;
299 }, ["subscription.disabled", "http://example.com/", true, false], "Disabling s ubscription"); 299 }, ["subscription.disabled", "http://example.com/"], "Disabling subscription") ;
300 checkNotifications(() => 300 checkNotifications(() =>
301 { 301 {
302 subscription.disabled = true; 302 subscription.disabled = true;
303 }, null, "Disabling already disabled subscription"); 303 }, null, "Disabling already disabled subscription");
304 checkNotifications(() => 304 checkNotifications(() =>
305 { 305 {
306 subscription.disabled = false; 306 subscription.disabled = false;
307 }, ["subscription.disabled", "http://example.com/", false, true], "Enabling su bscription"); 307 }, ["subscription.disabled", "http://example.com/"], "Enabling subscription");
308 308
309 checkNotifications(() => 309 checkNotifications(() =>
310 { 310 {
311 subscription.fixedTitle = true; 311 subscription.fixedTitle = true;
312 }, ["subscription.fixedTitle", "http://example.com/", true, false], "Marking t itle as fixed"); 312 }, ["subscription.fixedTitle", "http://example.com/"], "Marking title as fixed ");
313 checkNotifications(() => 313 checkNotifications(() =>
314 { 314 {
315 subscription.fixedTitle = false; 315 subscription.fixedTitle = false;
316 }, ["subscription.fixedTitle", "http://example.com/", false, true], "Marking t itle as editable"); 316 }, ["subscription.fixedTitle", "http://example.com/"], "Marking title as edita ble");
317 317
318 checkNotifications(() => 318 checkNotifications(() =>
319 { 319 {
320 subscription.homepage = "http://example.info/"; 320 subscription.homepage = "http://example.info/";
321 }, ["subscription.homepage", "http://example.com/", "http://example.info/", "" ], "Changing subscription homepage"); 321 }, ["subscription.homepage", "http://example.com/"], "Changing subscription ho mepage");
322 checkNotifications(() => 322 checkNotifications(() =>
323 { 323 {
324 subscription.homepage = null; 324 subscription.homepage = null;
325 }, ["subscription.homepage", "http://example.com/", "", "http://example.info/" ], "Resetting subscription homepage"); 325 }, ["subscription.homepage", "http://example.com/"], "Resetting subscription h omepage");
326 326
327 checkNotifications(() => 327 checkNotifications(() =>
328 { 328 {
329 // Using a large number that will only fit into double but not int 329 subscription.lastCheck = 1234;
330 subscription.lastCheck = 123456789012345; 330 }, ["subscription.lastCheck", "http://example.com/"], "Changing subscription.l astCheck");
331 }, ["subscription.lastCheck", "http://example.com/", 123456789012345, 0], "Cha nging subscription.lastCheck"); 331 checkNotifications(() =>
332 checkNotifications(() => 332 {
333 { 333 subscription.lastCheck = 1234;
334 subscription.lastCheck = 123456789012345;
335 }, null, "Setting subscription.lastCheck to same value"); 334 }, null, "Setting subscription.lastCheck to same value");
336 checkNotifications(() => 335 checkNotifications(() =>
337 { 336 {
338 subscription.lastCheck = 0; 337 subscription.lastCheck = 0;
339 }, ["subscription.lastCheck", "http://example.com/", 0, 123456789012345], "Res etting subscription.lastCheck"); 338 }, ["subscription.lastCheck", "http://example.com/"], "Resetting subscription. lastCheck");
340 339
341 checkNotifications(() => 340 checkNotifications(() =>
342 { 341 {
343 // Using a large number that will only fit into double but not int 342 subscription.lastDownload = 4321;
344 subscription.lastDownload = 543210987654321; 343 }, ["subscription.lastDownload", "http://example.com/"], "Changing subscriptio n.lastDownload");
345 }, ["subscription.lastDownload", "http://example.com/", 543210987654321, 0], " Changing subscription.lastDownload");
346 checkNotifications(() => 344 checkNotifications(() =>
347 { 345 {
348 subscription.lastDownload = 0; 346 subscription.lastDownload = 0;
349 }, ["subscription.lastDownload", "http://example.com/", 0, 543210987654321], " Resetting subscription.lastDownload"); 347 }, ["subscription.lastDownload", "http://example.com/"], "Resetting subscripti on.lastDownload");
350 348
351 checkNotifications(() => 349 checkNotifications(() =>
352 { 350 {
353 subscription.downloadStatus = "ok"; 351 subscription.downloadStatus = "ok";
354 }, ["subscription.downloadStatus", "http://example.com/", "ok", ""], "Changing subscription.downloadStatus"); 352 }, ["subscription.downloadStatus", "http://example.com/"], "Changing subscript ion.downloadStatus");
355 checkNotifications(() => 353 checkNotifications(() =>
356 { 354 {
357 subscription.downloadStatus = null; 355 subscription.downloadStatus = null;
358 }, ["subscription.downloadStatus", "http://example.com/", "", "ok"], "Resettin g subscription.downloadStatus"); 356 }, ["subscription.downloadStatus", "http://example.com/"], "Resetting subscrip tion.downloadStatus");
359 357
360 checkNotifications(() => 358 checkNotifications(() =>
361 { 359 {
362 subscription.errors++; 360 subscription.errors++;
363 }, ["subscription.errors", "http://example.com/", 1, 0], "Increasing subscript ion.errors"); 361 }, ["subscription.errors", "http://example.com/"], "Increasing subscription.er rors");
364 checkNotifications(() => 362 checkNotifications(() =>
365 { 363 {
366 subscription.errors = 0; 364 subscription.errors = 0;
367 }, ["subscription.errors", "http://example.com/", 0, 1], "Resetting subscripti on.erros"); 365 }, ["subscription.errors", "http://example.com/"], "Resetting subscription.err os");
368 366
369 subscription.delete(); 367 subscription.delete();
370 test.done(); 368 test.done();
371 }; 369 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld