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-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 20 matching lines...) Expand all Loading... |
31 return 0 == str.compare(0, beginning.size(), beginning); | 31 return 0 == str.compare(0, beginning.size(), beginning); |
32 } | 32 } |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 namespace | 36 namespace |
37 { | 37 { |
38 class NoFilesFileSystem : public LazyFileSystem | 38 class NoFilesFileSystem : public LazyFileSystem |
39 { | 39 { |
40 public: | 40 public: |
41 void Stat(const std::string& path, const StatCallback& callback) const overr
ide | 41 void Stat(const std::string& fileName, const StatCallback& callback) const o
verride |
42 { | 42 { |
43 scheduler([callback] | 43 scheduler([callback] |
44 { | 44 { |
45 callback(StatResult(), ""); | 45 callback(StatResult(), ""); |
46 }); | 46 }); |
47 } | 47 } |
48 }; | 48 }; |
49 | 49 |
50 template<class LazyFileSystemT, class LogSystem> | 50 template<class LazyFileSystemT, class LogSystem> |
51 class FilterEngineTestGeneric : public BaseJsTest | 51 class FilterEngineTestGeneric : public BaseJsTest |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return platform->GetFilterEngine(); | 115 return platform->GetFilterEngine(); |
116 } | 116 } |
117 | 117 |
118 void TearDown() override | 118 void TearDown() override |
119 { | 119 { |
120 removeFileIfExists("patterns.ini"); | 120 removeFileIfExists("patterns.ini"); |
121 removeFileIfExists("prefs.json"); | 121 removeFileIfExists("prefs.json"); |
122 fileSystem.reset(); | 122 fileSystem.reset(); |
123 BaseJsTest::TearDown(); | 123 BaseJsTest::TearDown(); |
124 } | 124 } |
125 void removeFileIfExists(const std::string& path) | 125 void removeFileIfExists(const std::string& fileName) |
126 { | 126 { |
127 bool hasStatRun = false; | 127 bool hasStatRun = false; |
128 bool doesFileExists; | 128 bool doesFileExists; |
129 fileSystem->Stat(path, [&hasStatRun, &doesFileExists](const IFileSystem::S
tatResult& stats, const std::string& error) | 129 fileSystem->Stat(fileName, [&hasStatRun, &doesFileExists](const IFileSyste
m::StatResult& stats, const std::string& error) |
130 { | 130 { |
131 EXPECT_TRUE(error.empty()) << error; | 131 EXPECT_TRUE(error.empty()) << error; |
132 doesFileExists = stats.exists; | 132 doesFileExists = stats.exists; |
133 hasStatRun = true; | 133 hasStatRun = true; |
134 }); | 134 }); |
135 while (!hasStatRun && !fileSystemTasks.empty()) | 135 while (!hasStatRun && !fileSystemTasks.empty()) |
136 { | 136 { |
137 (*fileSystemTasks.begin())(); | 137 (*fileSystemTasks.begin())(); |
138 fileSystemTasks.pop_front(); | 138 fileSystemTasks.pop_front(); |
139 } | 139 } |
140 | 140 |
141 if (!doesFileExists) | 141 if (!doesFileExists) |
142 return; | 142 return; |
143 | 143 |
144 bool hasRemoveRun = false; | 144 bool hasRemoveRun = false; |
145 fileSystem->Remove(path, [&hasRemoveRun](const std::string& error) | 145 fileSystem->Remove(fileName, [&hasRemoveRun](const std::string& error) |
146 { | 146 { |
147 EXPECT_TRUE(error.empty()) << error; | 147 EXPECT_TRUE(error.empty()) << error; |
148 hasRemoveRun = true; | 148 hasRemoveRun = true; |
149 }); | 149 }); |
150 while (!hasStatRun && !fileSystemTasks.empty()) | 150 while (!hasStatRun && !fileSystemTasks.empty()) |
151 { | 151 { |
152 (*fileSystemTasks.begin())(); | 152 (*fileSystemTasks.begin())(); |
153 fileSystemTasks.pop_front(); | 153 fileSystemTasks.pop_front(); |
154 } | 154 } |
155 } | 155 } |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 std::string testConnection = "test connection"; | 1064 std::string testConnection = "test connection"; |
1065 GetFilterEngine().SetAllowedConnectionType(&testConnection); | 1065 GetFilterEngine().SetAllowedConnectionType(&testConnection); |
1066 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB"); | 1066 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB"); |
1067 EXPECT_EQ("synchronize_ok", subscription.GetProperty("downloadStatus").AsStr
ing()); | 1067 EXPECT_EQ("synchronize_ok", subscription.GetProperty("downloadStatus").AsStr
ing()); |
1068 EXPECT_EQ(1u, subscription.GetProperty("filters").AsList().size()); | 1068 EXPECT_EQ(1u, subscription.GetProperty("filters").AsList().size()); |
1069 ASSERT_EQ(1u, capturedConnectionTypes.size()); | 1069 ASSERT_EQ(1u, capturedConnectionTypes.size()); |
1070 EXPECT_TRUE(capturedConnectionTypes[0].first); | 1070 EXPECT_TRUE(capturedConnectionTypes[0].first); |
1071 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second); | 1071 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second); |
1072 } | 1072 } |
1073 } | 1073 } |
OLD | NEW |