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

Side by Side Diff: test/FilterEngine.cpp

Issue 29331737: Issue 3363 - Implement IsDocumentWhitelisted and IsElemhideWhitelisted (Closed)
Patch Set: Reverted a whitespace removal Created Dec. 3, 2015, 8:39 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 | « src/FilterEngine.cpp ('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
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback); 406 filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback);
407 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); 407 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback);
408 AdblockPlus::Sleep(100); 408 AdblockPlus::Sleep(100);
409 ASSERT_EQ(1, timesCalled); 409 ASSERT_EQ(1, timesCalled);
410 410
411 filterEngine->RemoveUpdateAvailableCallback(); 411 filterEngine->RemoveUpdateAvailableCallback();
412 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); 412 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback);
413 AdblockPlus::Sleep(100); 413 AdblockPlus::Sleep(100);
414 ASSERT_EQ(1, timesCalled); 414 ASSERT_EQ(1, timesCalled);
415 } 415 }
416
417 TEST_F(FilterEngineTest, DocumentWhitelisting)
418 {
419 filterEngine->GetFilter("@@||example.org^$document")->AddToList();
420 filterEngine->GetFilter("@@||example.com^$document,domain=example.de")->AddToL ist();
421
422 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
423 "http://example.org",
424 std::vector<std::string>()));
425
426 ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
427 "http://example.co.uk",
428 std::vector<std::string>()));
429
430 ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
431 "http://example.com",
432 std::vector<std::string>()));
433
434 std::vector<std::string> documentUrls1;
435 documentUrls1.push_back("http://example.de");
436
437 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
438 "http://example.com",
439 documentUrls1));
440
441 ASSERT_FALSE(filterEngine->IsDocumentWhitelisted(
442 "http://example.co.uk",
443 documentUrls1));
444 }
445
446 TEST_F(FilterEngineTest, ElemhideWhitelisting)
447 {
448 filterEngine->GetFilter("@@||example.org^$elemhide")->AddToList();
449 filterEngine->GetFilter("@@||example.com^$elemhide,domain=example.de")->AddToL ist();
450
451 ASSERT_TRUE(filterEngine->IsElemhideWhitelisted(
452 "http://example.org",
453 std::vector<std::string>()));
454
455 ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
456 "http://example.co.uk",
457 std::vector<std::string>()));
458
459 ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
460 "http://example.com",
461 std::vector<std::string>()));
462
463 std::vector<std::string> documentUrls1;
464 documentUrls1.push_back("http://example.de");
465
466 ASSERT_TRUE(filterEngine->IsElemhideWhitelisted(
467 "http://example.com",
468 documentUrls1));
469
470 ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
471 "http://example.co.uk",
472 documentUrls1));
473 }
OLDNEW
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld