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

Delta Between Two Patch Sets: test/FilterEngine.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Updated implementation. Created June 2, 2017, 3:49 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 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 | « test/FileSystemJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (error.empty() && stats.exists) 117 if (error.empty() && stats.exists)
118 { 118 {
119 fs->Remove(path, [&sync](const std::string& error) 119 fs->Remove(path, [&sync](const std::string& error)
120 { 120 {
121 sync.Set(error); 121 sync.Set(error);
122 }); 122 });
123 } 123 }
124 else 124 else
125 sync.Set(error); 125 sync.Set(error);
126 }); 126 });
127 sync.Wait(); 127 sync.WaitFor();
128 return sync.GetError().empty(); 128 return sync.GetError().empty();
129 } 129 }
130 catch (...) 130 catch (...)
131 { 131 {
132 return false; 132 return false;
133 } 133 }
134 }; 134 };
135 int i = 5; 135 int i = 5;
136 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove()) 136 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove())
137 std::this_thread::sleep_for(std::chrono::seconds(2)); 137 std::this_thread::sleep_for(std::chrono::seconds(2));
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 int timesCalled = 0; 593 int timesCalled = 0;
594 std::this_thread::sleep_for(std::chrono::milliseconds(200)); 594 std::this_thread::sleep_for(std::chrono::milliseconds(200));
595 filterEngine->SetFilterChangeCallback([&timesCalled](const std::string&, Adblo ckPlus::JsValue&&) 595 filterEngine->SetFilterChangeCallback([&timesCalled](const std::string&, Adblo ckPlus::JsValue&&)
596 { 596 {
597 timesCalled++; 597 timesCalled++;
598 }); 598 });
599 filterEngine->GetFilter("foo").AddToList(); 599 filterEngine->GetFilter("foo").AddToList();
600 EXPECT_EQ(1, timesCalled); 600 EXPECT_EQ(1, timesCalled);
601 601
602 // we want to actually check the call count didn't change. 602 // we want to actually check the call count didn't change.
603 int previousTimesCalled = timesCalled;
604 filterEngine->RemoveFilterChangeCallback(); 603 filterEngine->RemoveFilterChangeCallback();
605 filterEngine->GetFilter("foo").RemoveFromList(); 604 filterEngine->GetFilter("foo").RemoveFromList();
606 EXPECT_EQ(previousTimesCalled, timesCalled); 605 EXPECT_EQ(1, timesCalled);
607 } 606 }
608 607
609 TEST_F(FilterEngineTest, DocumentWhitelisting) 608 TEST_F(FilterEngineTest, DocumentWhitelisting)
610 { 609 {
611 filterEngine->GetFilter("@@||example.org^$document").AddToList(); 610 filterEngine->GetFilter("@@||example.org^$document").AddToList();
612 filterEngine->GetFilter("@@||example.com^$document,domain=example.de").AddToLi st(); 611 filterEngine->GetFilter("@@||example.com^$document,domain=example.de").AddToLi st();
613 612
614 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted( 613 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
615 "http://example.org", 614 "http://example.org",
616 std::vector<std::string>())); 615 std::vector<std::string>()));
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 std::string testConnection = "test connection"; 1025 std::string testConnection = "test connection";
1027 filterEngine->SetAllowedConnectionType(&testConnection); 1026 filterEngine->SetAllowedConnectionType(&testConnection);
1028 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB"); 1027 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB");
1029 EXPECT_EQ("synchronize_ok", subscription.GetProperty("downloadStatus").AsStr ing()); 1028 EXPECT_EQ("synchronize_ok", subscription.GetProperty("downloadStatus").AsStr ing());
1030 EXPECT_EQ(1u, subscription.GetProperty("filters").AsList().size()); 1029 EXPECT_EQ(1u, subscription.GetProperty("filters").AsList().size());
1031 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1030 ASSERT_EQ(1u, capturedConnectionTypes.size());
1032 EXPECT_TRUE(capturedConnectionTypes[0].first); 1031 EXPECT_TRUE(capturedConnectionTypes[0].first);
1033 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second); 1032 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second);
1034 } 1033 }
1035 } 1034 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld