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

Delta Between Two Patch Sets: test/FilterEngine.cpp

Issue 29363607: Issue 4612 - enable AA on first run and make automatic adding of any subscription optional (Closed)
Left Patch Set: address comments Created Nov. 23, 2016, 2:17 p.m.
Right Patch Set: reduce number of attempts to remove test files Created Dec. 2, 2016, 2:15 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/prefs.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-2016 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 { 153 {
154 if (fileSystem->Stat(path).exists) 154 if (fileSystem->Stat(path).exists)
155 fileSystem->Remove(path); 155 fileSystem->Remove(path);
156 return true; 156 return true;
157 } 157 }
158 catch (...) 158 catch (...)
159 { 159 {
160 return false; 160 return false;
161 } 161 }
162 }; 162 };
163 int i = 100; 163 int i = 5;
164 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove()) 164 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove())
165 std::this_thread::sleep_for(std::chrono::seconds(2)); 165 std::this_thread::sleep_for(std::chrono::seconds(2));
166 } 166 }
167 }; 167 };
168 } 168 }
169 169
170 TEST_F(FilterEngineTest, FilterCreation) 170 TEST_F(FilterEngineTest, FilterCreation)
171 { 171 {
172 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo"); 172 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo");
173 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType()); 173 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType());
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 582
583 ASSERT_TRUE(filterEngine->IsElemhideWhitelisted( 583 ASSERT_TRUE(filterEngine->IsElemhideWhitelisted(
584 "http://example.com", 584 "http://example.com",
585 documentUrls1)); 585 documentUrls1));
586 586
587 ASSERT_FALSE(filterEngine->IsElemhideWhitelisted( 587 ASSERT_FALSE(filterEngine->IsElemhideWhitelisted(
588 "http://example.co.uk", 588 "http://example.co.uk",
589 documentUrls1)); 589 documentUrls1));
590 } 590 }
591 591
592 TEST(NewFilterEngineTest, MemoryLeak_NoCircularReferences)
593 {
594 std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine;
595 {
596 auto jsEngine = AdblockPlus::JsEngine::New();
597 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem()));
598 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new LazyWebRequest()));
599 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem()));
600 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)) ;
601 }
602 EXPECT_FALSE(weakJsEngine.lock());
603 }
604
605 TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun) 592 TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun)
606 { 593 {
607 AppInfo appInfo; 594 AppInfo appInfo;
608 appInfo.locale = "zh"; 595 appInfo.locale = "zh";
609 const std::string langSubscriptionUrl = "https://easylist-downloads.adblockplu s.org/easylistchina+easylist.txt"; 596 const std::string langSubscriptionUrl = "https://easylist-downloads.adblockplu s.org/easylistchina+easylist.txt";
610 auto jsEngine = createJsEngine(appInfo); 597 auto jsEngine = createJsEngine(appInfo);
611 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)); 598 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine));
612 const auto subscriptions = filterEngine->GetListedSubscriptions(); 599 const auto subscriptions = filterEngine->GetListedSubscriptions();
613 ASSERT_EQ(2u, subscriptions.size()); 600 ASSERT_EQ(2u, subscriptions.size());
614 const auto aaUrl = filterEngine->GetPref("subscriptions_exceptionsurl")->AsStr ing(); 601 const auto aaUrl = filterEngine->GetPref("subscriptions_exceptionsurl")->AsStr ing();
(...skipping 17 matching lines...) Expand all
632 619
633 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun) 620 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
634 { 621 {
635 auto jsEngine = createJsEngine(); 622 auto jsEngine = createJsEngine();
636 FilterEngine::Prefs preSettings; 623 FilterEngine::Prefs preSettings;
637 preSettings["first_run_subscription_auto_select"] = jsEngine->NewValue(false); 624 preSettings["first_run_subscription_auto_select"] = jsEngine->NewValue(false);
638 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine, pr eSettings)); 625 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine, pr eSettings));
639 const auto subscriptions = filterEngine->GetListedSubscriptions(); 626 const auto subscriptions = filterEngine->GetListedSubscriptions();
640 EXPECT_EQ(0u, subscriptions.size()); 627 EXPECT_EQ(0u, subscriptions.size());
641 } 628 }
LEFTRIGHT
« lib/prefs.js ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld