| LEFT | RIGHT |
| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace | 27 namespace |
| 28 { | 28 { |
| 29 const std::string testPath = "libadblockplus-t\xc3\xa4st-file"; | 29 const std::string testPath = "libadblockplus-t\xc3\xa4st-file"; |
| 30 | 30 |
| 31 void WriteString(const AdblockPlus::FileSystemPtr& fileSystem, | 31 void WriteString(const AdblockPlus::FileSystemPtr& fileSystem, |
| 32 const std::string& content) | 32 const std::string& content) |
| 33 { | 33 { |
| 34 Sync sync; | 34 Sync sync; |
| 35 | 35 |
| 36 fileSystem->Write(testPath, content, [&sync](const std::string& error) | 36 fileSystem->Write(testPath, |
| 37 IFileSystem::IOBuffer(content.cbegin(), content.cend()), |
| 38 [&sync](const std::string& error) |
| 37 { | 39 { |
| 38 EXPECT_TRUE(error.empty()); | 40 EXPECT_TRUE(error.empty()); |
| 39 | 41 |
| 40 sync.Set(); | 42 sync.Set(); |
| 41 }); | 43 }); |
| 42 | 44 |
| 43 sync.Wait(); | 45 sync.WaitFor(); |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 TEST(DefaultFileSystemTest, WriteReadRemove) | 49 TEST(DefaultFileSystemTest, WriteReadRemove) |
| 48 { | 50 { |
| 49 Sync sync; | 51 Sync sync; |
| 50 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; | 52 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; |
| 51 WriteString(fileSystem, "foo"); | 53 WriteString(fileSystem, "foo"); |
| 52 fileSystem->Read(testPath, [fileSystem, &sync](std::string&& content, const st
d::string& error) | 54 fileSystem->Read(testPath, |
| 53 { | 55 [fileSystem, &sync](IFileSystem::IOBuffer&& content, const std::string& erro
r) |
| 54 EXPECT_TRUE(error.empty()); | 56 { |
| 55 EXPECT_EQ("foo", content); | 57 EXPECT_TRUE(error.empty()); |
| 58 EXPECT_EQ("foo", std::string(content.cbegin(), content.cend())); |
| 56 | 59 |
| 57 fileSystem->Remove(testPath, [&sync](const std::string& error) | 60 fileSystem->Remove(testPath, [&sync](const std::string& error) |
| 58 { | 61 { |
| 59 EXPECT_TRUE(error.empty()); | 62 EXPECT_TRUE(error.empty()); |
| 60 sync.Set(); | 63 sync.Set(); |
| 61 }); | 64 }); |
| 62 }); | 65 }); |
| 63 | 66 |
| 64 sync.Wait(); | 67 EXPECT_TRUE(sync.WaitFor()); |
| 65 } | 68 } |
| 66 | 69 |
| 67 TEST(DefaultFileSystemTest, StatWorkingDirectory) | 70 TEST(DefaultFileSystemTest, StatWorkingDirectory) |
| 68 { | 71 { |
| 69 Sync sync; | 72 Sync sync; |
| 70 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; | 73 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; |
| 71 fileSystem->Stat(".", | 74 fileSystem->Stat(".", |
| 72 [fileSystem, &sync](const IFileSystem::StatResult result, const std::string&
error) | 75 [fileSystem, &sync](const IFileSystem::StatResult result, const std::string&
error) |
| 73 { | 76 { |
| 74 EXPECT_TRUE(error.empty()); | 77 EXPECT_TRUE(error.empty()); |
| 75 ASSERT_TRUE(result.exists); | 78 ASSERT_TRUE(result.exists); |
| 76 ASSERT_TRUE(result.isDirectory); | 79 ASSERT_TRUE(result.isDirectory); |
| 77 ASSERT_FALSE(result.isFile); | 80 ASSERT_FALSE(result.isFile); |
| 78 ASSERT_NE(0, result.lastModified); | 81 ASSERT_NE(0, result.lastModified); |
| 79 sync.Set(); | 82 sync.Set(); |
| 80 }); | 83 }); |
| 81 | 84 |
| 82 sync.Wait(); | 85 EXPECT_TRUE(sync.WaitFor()); |
| 83 } | 86 } |
| 84 | 87 |
| 85 TEST(DefaultFileSystemTest, WriteMoveStatRemove) | 88 TEST(DefaultFileSystemTest, WriteMoveStatRemove) |
| 86 { | 89 { |
| 87 Sync sync; | 90 Sync sync; |
| 88 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; | 91 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem()
; |
| 89 WriteString(fileSystem, "foo"); | 92 WriteString(fileSystem, "foo"); |
| 90 | 93 |
| 91 fileSystem->Stat(testPath, | 94 fileSystem->Stat(testPath, |
| 92 [fileSystem, &sync](const IFileSystem::StatResult& result, const std::string
& error) | 95 [fileSystem, &sync](const IFileSystem::StatResult& result, const std::string
& error) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 116 EXPECT_TRUE(error.empty()); | 119 EXPECT_TRUE(error.empty()); |
| 117 ASSERT_FALSE(result.exists); | 120 ASSERT_FALSE(result.exists); |
| 118 sync.Set(); | 121 sync.Set(); |
| 119 }); | 122 }); |
| 120 }); | 123 }); |
| 121 }); | 124 }); |
| 122 }); | 125 }); |
| 123 }); | 126 }); |
| 124 }); | 127 }); |
| 125 | 128 |
| 126 sync.Wait(); | 129 EXPECT_TRUE(sync.WaitFor()); |
| 127 } | 130 } |
| LEFT | RIGHT |