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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <sstream> | 18 #include <sstream> |
19 #include <AdblockPlus.h> | 19 #include <AdblockPlus.h> |
20 #include <gtest/gtest.h> | 20 #include <gtest/gtest.h> |
21 | 21 #include "../src/DefaultFileSystem.h" |
22 #include "BaseJsTest.h" | 22 #include "BaseJsTest.h" |
23 | 23 |
24 using AdblockPlus::IFileSystem; | 24 using AdblockPlus::IFileSystem; |
25 using AdblockPlus::FileSystemPtr; | 25 using AdblockPlus::FileSystemPtr; |
26 using AdblockPlus::SchedulerTask; | 26 using AdblockPlus::SchedulerTask; |
27 | 27 |
| 28 using namespace AdblockPlus; |
28 namespace | 29 namespace |
29 { | 30 { |
30 const std::string testFileName = "libadblockplus-t\xc3\xa4st-file"; | 31 const std::string testFileName = "libadblockplus-t\xc3\xa4st-file"; |
31 | 32 |
| 33 FileSystemPtr CreateDefaultFileSystem(const Scheduler& scheduler) |
| 34 { |
| 35 return FileSystemPtr(new DefaultFileSystem(scheduler, std::unique_ptr<Defaul
tFileSystemSync>(new DefaultFileSystemSync("")))); |
| 36 } |
| 37 |
32 class DefaultFileSystemTest : public ::testing::Test | 38 class DefaultFileSystemTest : public ::testing::Test |
33 { | 39 { |
34 public: | 40 public: |
35 void SetUp() override | 41 void SetUp() override |
36 { | 42 { |
37 fileSystem = AdblockPlus::CreateDefaultFileSystem([this](const SchedulerTa
sk& task) | 43 fileSystem = CreateDefaultFileSystem([this](const SchedulerTask& task) |
38 { | 44 { |
39 fileSystemTasks.emplace_back(task); | 45 fileSystemTasks.emplace_back(task); |
40 }); | 46 }); |
41 } | 47 } |
42 protected: | 48 protected: |
43 void WriteString(const std::string& content) | 49 void WriteString(const std::string& content) |
44 { | 50 { |
45 bool hasRun = false; | 51 bool hasRun = false; |
46 fileSystem->Write(testFileName, | 52 fileSystem->Write(testFileName, |
47 IFileSystem::IOBuffer(content.cbegin(), content.cend()), | 53 IFileSystem::IOBuffer(content.cbegin(), content.cend()), |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 fileSystem->Stat(newTestFileName, [&hasStatRemovedFileRun](const IFileSystem::
StatResult& result, const std::string& error) | 180 fileSystem->Stat(newTestFileName, [&hasStatRemovedFileRun](const IFileSystem::
StatResult& result, const std::string& error) |
175 { | 181 { |
176 EXPECT_TRUE(error.empty()); | 182 EXPECT_TRUE(error.empty()); |
177 ASSERT_FALSE(result.exists); | 183 ASSERT_FALSE(result.exists); |
178 hasStatRemovedFileRun = true; | 184 hasStatRemovedFileRun = true; |
179 }); | 185 }); |
180 EXPECT_FALSE(hasStatRemovedFileRun); | 186 EXPECT_FALSE(hasStatRemovedFileRun); |
181 PumpTask(); | 187 PumpTask(); |
182 EXPECT_TRUE(hasStatRemovedFileRun); | 188 EXPECT_TRUE(hasStatRemovedFileRun); |
183 } | 189 } |
OLD | NEW |