Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: components/filesystem/directory_impl_unittest.cc

Issue 1935863002: mojo: Fix leveldb unittests by making fs::Directories cloneable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Gyp continues to exist. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/filesystem/directory_impl.cc ('k') | components/filesystem/file_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Attempt to open that directory as a file. This must fail! 147 // Attempt to open that directory as a file. This must fail!
148 FilePtr file; 148 FilePtr file;
149 error = FileError::FAILED; 149 error = FileError::FAILED;
150 directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen, 150 directory->OpenFile("my_file", GetProxy(&file), kFlagRead | kFlagOpen,
151 Capture(&error)); 151 Capture(&error));
152 ASSERT_TRUE(directory.WaitForIncomingResponse()); 152 ASSERT_TRUE(directory.WaitForIncomingResponse());
153 EXPECT_EQ(FileError::NOT_A_FILE, error); 153 EXPECT_EQ(FileError::NOT_A_FILE, error);
154 } 154 }
155 } 155 }
156 156
157 TEST_F(DirectoryImplTest, Clone) {
158 DirectoryPtr clone_one;
159 DirectoryPtr clone_two;
160 FileError error;
161
162 {
163 DirectoryPtr directory;
164 GetTemporaryRoot(&directory);
165
166 directory->Clone(GetProxy(&clone_one));
167 directory->Clone(GetProxy(&clone_two));
168
169 // Original temporary directory goes out of scope here; shouldn't be
170 // deleted since it has clones.
171 }
172
173 std::string data("one two three");
174 {
175 clone_one->WriteFile("data", mojo::Array<uint8_t>::From(data),
176 Capture(&error));
177 ASSERT_TRUE(clone_one.WaitForIncomingResponse());
178 EXPECT_EQ(FileError::OK, error);
179 }
180
181 {
182 mojo::Array<uint8_t> file_contents;
183 clone_two->ReadEntireFile("data", Capture(&error, &file_contents));
184 ASSERT_TRUE(clone_two.WaitForIncomingResponse());
185 EXPECT_EQ(FileError::OK, error);
186
187 EXPECT_EQ(data, file_contents.To<std::string>());
188 }
189 }
190
157 TEST_F(DirectoryImplTest, WriteFileReadFile) { 191 TEST_F(DirectoryImplTest, WriteFileReadFile) {
158 DirectoryPtr directory; 192 DirectoryPtr directory;
159 GetTemporaryRoot(&directory); 193 GetTemporaryRoot(&directory);
160 FileError error; 194 FileError error;
161 195
162 std::string data("one two three"); 196 std::string data("one two three");
163 { 197 {
164 directory->WriteFile("data", mojo::Array<uint8_t>::From(data), 198 directory->WriteFile("data", mojo::Array<uint8_t>::From(data),
165 Capture(&error)); 199 Capture(&error));
166 ASSERT_TRUE(directory.WaitForIncomingResponse()); 200 ASSERT_TRUE(directory.WaitForIncomingResponse());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 Capture(&error)); 273 Capture(&error));
240 ASSERT_TRUE(directory.WaitForIncomingResponse()); 274 ASSERT_TRUE(directory.WaitForIncomingResponse());
241 EXPECT_EQ(FileError::NOT_A_FILE, error); 275 EXPECT_EQ(FileError::NOT_A_FILE, error);
242 } 276 }
243 } 277 }
244 278
245 // TODO(vtl): Test delete flags. 279 // TODO(vtl): Test delete flags.
246 280
247 } // namespace 281 } // namespace
248 } // namespace filesystem 282 } // namespace filesystem
OLDNEW
« no previous file with comments | « components/filesystem/directory_impl.cc ('k') | components/filesystem/file_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698