Left: | ||
Right: |
OLD | NEW |
---|---|
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 | 591 |
592 TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun) | 592 TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun) |
593 { | 593 { |
594 AppInfo appInfo; | 594 AppInfo appInfo; |
595 appInfo.locale = "zh"; | 595 appInfo.locale = "zh"; |
596 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"; |
597 auto jsEngine = createJsEngine(appInfo); | 597 auto jsEngine = createJsEngine(appInfo); |
598 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)); | 598 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine)); |
599 const auto subscriptions = filterEngine->GetListedSubscriptions(); | 599 const auto subscriptions = filterEngine->GetListedSubscriptions(); |
600 ASSERT_EQ(2u, subscriptions.size()); | 600 ASSERT_EQ(2u, subscriptions.size()); |
601 const auto aaUrl = filterEngine->GetPref("subscriptions_exceptionsurl")->AsStr ing(); | |
602 SubscriptionPtr aaSubscription; | 601 SubscriptionPtr aaSubscription; |
603 SubscriptionPtr langSubscription; | 602 SubscriptionPtr langSubscription; |
604 if (subscriptions[0]->GetProperty("url")->AsString() == aaUrl) | 603 if (subscriptions[0]->IsAA()) |
605 { | 604 { |
606 aaSubscription = subscriptions[0]; | 605 aaSubscription = subscriptions[0]; |
607 langSubscription = subscriptions[1]; | 606 langSubscription = subscriptions[1]; |
608 } | 607 } else if (subscriptions[1]->IsAA()) |
609 else if (subscriptions[1]->GetProperty("url")->AsString() == aaUrl) | |
610 { | 608 { |
611 aaSubscription = subscriptions[1]; | 609 aaSubscription = subscriptions[1]; |
612 langSubscription = subscriptions[0]; | 610 langSubscription = subscriptions[0]; |
613 } | 611 } |
614 ASSERT_NE(nullptr, aaSubscription); | 612 ASSERT_NE(nullptr, aaSubscription); |
615 ASSERT_NE(nullptr, langSubscription); | 613 ASSERT_NE(nullptr, langSubscription); |
616 EXPECT_EQ(aaUrl, aaSubscription->GetProperty("url")->AsString()); | |
617 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString( )); | 614 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString( )); |
615 EXPECT_TRUE(filterEngine->IsAAEnabled()); | |
618 } | 616 } |
619 | 617 |
620 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun) | 618 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun) |
621 { | 619 { |
622 auto jsEngine = createJsEngine(); | 620 auto jsEngine = createJsEngine(); |
623 FilterEngine::Prefs preSettings; | 621 FilterEngine::Prefs preSettings; |
624 preSettings["first_run_subscription_auto_select"] = jsEngine->NewValue(false); | 622 preSettings["first_run_subscription_auto_select"] = jsEngine->NewValue(false); |
625 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine, pr eSettings)); | 623 auto filterEngine = FilterEnginePtr(new AdblockPlus::FilterEngine(jsEngine, pr eSettings)); |
626 const auto subscriptions = filterEngine->GetListedSubscriptions(); | 624 const auto subscriptions = filterEngine->GetListedSubscriptions(); |
627 EXPECT_EQ(0u, subscriptions.size()); | 625 EXPECT_EQ(0u, subscriptions.size()); |
626 EXPECT_FALSE(filterEngine->IsAAEnabled()); | |
628 } | 627 } |
628 | |
629 TEST_F(FilterEngineTest, IsAAEnabled) | |
630 { | |
631 // no subscription (because of preconfigured prefs.json and patterns.ini) | |
632 EXPECT_FALSE(filterEngine->IsAAEnabled()); | |
633 // add subscription and enable | |
634 filterEngine->SetAAEnabled(true); | |
635 EXPECT_TRUE(filterEngine->IsAAEnabled()); | |
636 // disable | |
637 filterEngine->SetAAEnabled(false); | |
638 EXPECT_FALSE(filterEngine->IsAAEnabled()); | |
639 // only enable already existing disabled | |
640 filterEngine->SetAAEnabled(true); | |
641 EXPECT_TRUE(filterEngine->IsAAEnabled()); | |
642 // remove | |
643 filterEngine->GetSubscription(filterEngine->GetAAURL())->RemoveFromList(); | |
644 EXPECT_FALSE(filterEngine->IsAAEnabled()); | |
645 // no subscription | |
646 EXPECT_FALSE(filterEngine->IsAAEnabled()); | |
647 } | |
Eric
2016/12/05 14:40:58
This is a bunch of unit tests all combined into on
sergei
2017/03/17 15:55:25
Added more tests and they run in each separate tes
| |
OLD | NEW |