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: Rebased. Corrected most of the review issues. Created July 4, 2017, 7:57 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 15 matching lines...) Expand all
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.WaitFor(); 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 EXPECT_TRUE(sync.WaitFor()); 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)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 sync.Set(); 121 sync.Set();
119 }); 122 });
120 }); 123 });
121 }); 124 });
122 }); 125 });
123 }); 126 });
124 }); 127 });
125 128
126 EXPECT_TRUE(sync.WaitFor()); 129 EXPECT_TRUE(sync.WaitFor());
127 } 130 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld