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

Delta Between Two Patch Sets: test/DefaultFileSystem.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Make read write deal with binary buffers. Created July 6, 2017, 12:19 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/BaseJsTest.cpp ('k') | test/FileSystemJsObject.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 16 matching lines...) Expand all
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, 36 fileSystem->Write(testPath,
37 std::vector<char>(content.cbegin(), content.cend()), 37 IFileSystem::IOBuffer(content.cbegin(), content.cend()),
38 [&sync](const std::string& error) 38 [&sync](const std::string& error)
39 { 39 {
40 EXPECT_TRUE(error.empty()); 40 EXPECT_TRUE(error.empty());
41 41
42 sync.Set(); 42 sync.Set();
43 }); 43 });
44 44
45 sync.WaitFor(); 45 sync.WaitFor();
46 } 46 }
47 } 47 }
48 48
49 TEST(DefaultFileSystemTest, WriteReadRemove) 49 TEST(DefaultFileSystemTest, WriteReadRemove)
50 { 50 {
51 Sync sync; 51 Sync sync;
52 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem() ; 52 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem() ;
53 WriteString(fileSystem, "foo"); 53 WriteString(fileSystem, "foo");
54 fileSystem->Read(testPath, [fileSystem, &sync](std::vector<char>&& content, co nst std::string& error) 54 fileSystem->Read(testPath,
55 { 55 [fileSystem, &sync](IFileSystem::IOBuffer&& content, const std::string& erro r)
56 EXPECT_TRUE(error.empty()); 56 {
57 EXPECT_EQ("foo", std::string(content.cbegin(), content.cend())); 57 EXPECT_TRUE(error.empty());
58 EXPECT_EQ("foo", std::string(content.cbegin(), content.cend()));
58 59
59 fileSystem->Remove(testPath, [&sync](const std::string& error) 60 fileSystem->Remove(testPath, [&sync](const std::string& error)
60 { 61 {
61 EXPECT_TRUE(error.empty()); 62 EXPECT_TRUE(error.empty());
62 sync.Set(); 63 sync.Set();
63 }); 64 });
64 }); 65 });
65 66
66 EXPECT_TRUE(sync.WaitFor()); 67 EXPECT_TRUE(sync.WaitFor());
67 } 68 }
68 69
69 TEST(DefaultFileSystemTest, StatWorkingDirectory) 70 TEST(DefaultFileSystemTest, StatWorkingDirectory)
70 { 71 {
71 Sync sync; 72 Sync sync;
72 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem() ; 73 AdblockPlus::FileSystemPtr fileSystem = AdblockPlus::CreateDefaultFileSystem() ;
73 fileSystem->Stat(".", 74 fileSystem->Stat(".",
74 [fileSystem, &sync](const IFileSystem::StatResult result, const std::string& error) 75 [fileSystem, &sync](const IFileSystem::StatResult result, const std::string& error)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 sync.Set(); 121 sync.Set();
121 }); 122 });
122 }); 123 });
123 }); 124 });
124 }); 125 });
125 }); 126 });
126 }); 127 });
127 128
128 EXPECT_TRUE(sync.WaitFor()); 129 EXPECT_TRUE(sync.WaitFor());
129 } 130 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld