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

Side by Side Diff: test/DefaultFileSystem.cpp

Issue 29731562: Issue 6477 - separate done and error callbacks in IFileSystem::Read (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git@c0a6434596a83383e37678ef3b6ecef00ed6a261
Patch Set: Created March 23, 2018, 10:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 EXPECT_EQ(SLASH_STRING "foo" SLASH_STRING "bar" SLASH_STRING "baz.txt", 123 EXPECT_EQ(SLASH_STRING "foo" SLASH_STRING "bar" SLASH_STRING "baz.txt",
124 fullPath); 124 fullPath);
125 } 125 }
126 } 126 }
127 127
128 TEST_F(DefaultFileSystemTest, WriteReadRemove) 128 TEST_F(DefaultFileSystemTest, WriteReadRemove)
129 { 129 {
130 WriteString("foo"); 130 WriteString("foo");
131 131
132 bool hasReadRun = false; 132 bool hasReadRun = false;
133 bool hasErrorRun = false;
133 fileSystem->Read(testFileName, 134 fileSystem->Read(testFileName,
134 [this, &hasReadRun](IFileSystem::IOBuffer&& content, const std::string& erro r) 135 [this, &hasReadRun](IFileSystem::IOBuffer&& content)
135 { 136 {
136 EXPECT_TRUE(error.empty()); 137 EXPECT_EQ("foo", std::string(content.cbegin(), content.cend()));
137 EXPECT_EQ("foo", std::string(content.cbegin(), content.cend())); 138 hasReadRun = true;
138 hasReadRun = true; 139 }, [&hasErrorRun](const std::string& error)
139 }); 140 {
141 hasErrorRun = true;
142 });
140 EXPECT_FALSE(hasReadRun); 143 EXPECT_FALSE(hasReadRun);
144 EXPECT_FALSE(hasErrorRun);
141 PumpTask(); 145 PumpTask();
142 EXPECT_TRUE(hasReadRun); 146 EXPECT_TRUE(hasReadRun);
147 EXPECT_FALSE(hasErrorRun);
143 148
144 bool hasRemoveRun = false; 149 bool hasRemoveRun = false;
145 fileSystem->Remove(testFileName, [&hasRemoveRun](const std::string& error) 150 fileSystem->Remove(testFileName, [&hasRemoveRun](const std::string& error)
146 { 151 {
147 EXPECT_TRUE(error.empty()); 152 EXPECT_TRUE(error.empty());
148 hasRemoveRun = true; 153 hasRemoveRun = true;
149 }); 154 });
150 EXPECT_FALSE(hasRemoveRun); 155 EXPECT_FALSE(hasRemoveRun);
151 PumpTask(); 156 PumpTask();
152 EXPECT_TRUE(hasRemoveRun); 157 EXPECT_TRUE(hasRemoveRun);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 fileSystem->Stat(newTestFileName, [&hasStatRemovedFileRun](const IFileSystem:: StatResult& result, const std::string& error) 237 fileSystem->Stat(newTestFileName, [&hasStatRemovedFileRun](const IFileSystem:: StatResult& result, const std::string& error)
233 { 238 {
234 EXPECT_TRUE(error.empty()); 239 EXPECT_TRUE(error.empty());
235 ASSERT_FALSE(result.exists); 240 ASSERT_FALSE(result.exists);
236 hasStatRemovedFileRun = true; 241 hasStatRemovedFileRun = true;
237 }); 242 });
238 EXPECT_FALSE(hasStatRemovedFileRun); 243 EXPECT_FALSE(hasStatRemovedFileRun);
239 PumpTask(); 244 PumpTask();
240 EXPECT_TRUE(hasStatRemovedFileRun); 245 EXPECT_TRUE(hasStatRemovedFileRun);
241 } 246 }
OLDNEW
« test/BaseJsTest.h ('K') | « test/BaseJsTest.h ('k') | test/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld