OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/chromeos/fileapi/memory_file_util.h" | 10 #include "webkit/chromeos/fileapi/memory_file_util.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 TEST_F(MemoryFileUtilTest, TestCreateGetFileInfo) { | 235 TEST_F(MemoryFileUtilTest, TestCreateGetFileInfo) { |
236 const int request_id1 = GetNextRequestId(); | 236 const int request_id1 = GetNextRequestId(); |
237 file_util()->GetFileInfo(FilePath("/mnt/memory/test.txt"), | 237 file_util()->GetFileInfo(FilePath("/mnt/memory/test.txt"), |
238 GetGetFileInfoCallback(request_id1)); | 238 GetGetFileInfoCallback(request_id1)); |
239 | 239 |
240 // In case the file system is truely asynchronous, RunAllPending is not | 240 // In case the file system is truely asynchronous, RunAllPending is not |
241 // enough to wait for answer. In that case the thread should be blocked | 241 // enough to wait for answer. In that case the thread should be blocked |
242 // until the callback is called (ex. use Run() instead here, and call | 242 // until the callback is called (ex. use Run() instead here, and call |
243 // Quit() from callback). | 243 // Quit() from callback). |
244 MessageLoop::current()->RunAllPending(); | 244 MessageLoop::current()->RunUntilIdle(); |
245 | 245 |
246 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id1)); | 246 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id1)); |
247 CallbackStatus status = GetStatus(request_id1); | 247 CallbackStatus status = GetStatus(request_id1); |
248 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status.result); | 248 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status.result); |
249 | 249 |
250 base::Time start_create = base::Time::Now(); | 250 base::Time start_create = base::Time::Now(); |
251 | 251 |
252 const int request_id2 = GetNextRequestId(); | 252 const int request_id2 = GetNextRequestId(); |
253 file_util()->Create(FilePath("/mnt/memory/test.txt"), | 253 file_util()->Create(FilePath("/mnt/memory/test.txt"), |
254 GetStatusCallback(request_id2)); | 254 GetStatusCallback(request_id2)); |
255 MessageLoop::current()->RunAllPending(); | 255 MessageLoop::current()->RunUntilIdle(); |
256 ASSERT_EQ(CALLBACK_TYPE_STATUS, GetStatusType(request_id2)); | 256 ASSERT_EQ(CALLBACK_TYPE_STATUS, GetStatusType(request_id2)); |
257 status = GetStatus(request_id2); | 257 status = GetStatus(request_id2); |
258 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 258 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
259 | 259 |
260 const int request_id3 = GetNextRequestId(); | 260 const int request_id3 = GetNextRequestId(); |
261 file_util()->GetFileInfo(FilePath("/mnt/memory/test.txt"), | 261 file_util()->GetFileInfo(FilePath("/mnt/memory/test.txt"), |
262 GetGetFileInfoCallback(request_id3)); | 262 GetGetFileInfoCallback(request_id3)); |
263 MessageLoop::current()->RunAllPending(); | 263 MessageLoop::current()->RunUntilIdle(); |
264 | 264 |
265 base::Time end_create = base::Time::Now(); | 265 base::Time end_create = base::Time::Now(); |
266 | 266 |
267 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id3)); | 267 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id3)); |
268 status = GetStatus(request_id3); | 268 status = GetStatus(request_id3); |
269 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 269 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
270 ASSERT_EQ(0, status.file_info.size); | 270 ASSERT_EQ(0, status.file_info.size); |
271 ASSERT_FALSE(status.file_info.is_directory); | 271 ASSERT_FALSE(status.file_info.is_directory); |
272 ASSERT_FALSE(status.file_info.is_symbolic_link); | 272 ASSERT_FALSE(status.file_info.is_symbolic_link); |
273 ASSERT_GE(status.file_info.last_modified, start_create); | 273 ASSERT_GE(status.file_info.last_modified, start_create); |
274 ASSERT_LE(status.file_info.last_modified, end_create); | 274 ASSERT_LE(status.file_info.last_modified, end_create); |
275 ASSERT_GE(status.file_info.creation_time, start_create); | 275 ASSERT_GE(status.file_info.creation_time, start_create); |
276 ASSERT_LE(status.file_info.creation_time, end_create); | 276 ASSERT_LE(status.file_info.creation_time, end_create); |
277 } | 277 } |
278 | 278 |
279 TEST_F(MemoryFileUtilTest, TestReadWrite) { | 279 TEST_F(MemoryFileUtilTest, TestReadWrite) { |
280 // Check that the file does not exist. | 280 // Check that the file does not exist. |
281 | 281 |
282 const int request_id1 = GetNextRequestId(); | 282 const int request_id1 = GetNextRequestId(); |
283 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 283 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
284 GetGetFileInfoCallback(request_id1)); | 284 GetGetFileInfoCallback(request_id1)); |
285 | 285 |
286 MessageLoop::current()->RunAllPending(); | 286 MessageLoop::current()->RunUntilIdle(); |
287 | 287 |
288 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id1)); | 288 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id1)); |
289 CallbackStatus status = GetStatus(request_id1); | 289 CallbackStatus status = GetStatus(request_id1); |
290 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status.result); | 290 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status.result); |
291 | 291 |
292 // Create & open file for writing. | 292 // Create & open file for writing. |
293 | 293 |
294 base::Time start_create = base::Time::Now(); | 294 base::Time start_create = base::Time::Now(); |
295 const int request_id2 = GetNextRequestId(); | 295 const int request_id2 = GetNextRequestId(); |
296 file_util()->Open(FilePath("/mnt/memory/test1.txt"), | 296 file_util()->Open(FilePath("/mnt/memory/test1.txt"), |
297 base::PLATFORM_FILE_CREATE_ALWAYS | | 297 base::PLATFORM_FILE_CREATE_ALWAYS | |
298 base::PLATFORM_FILE_WRITE, | 298 base::PLATFORM_FILE_WRITE, |
299 GetOpenCallback(request_id2)); | 299 GetOpenCallback(request_id2)); |
300 MessageLoop::current()->RunAllPending(); | 300 MessageLoop::current()->RunUntilIdle(); |
301 | 301 |
302 base::Time end_create = base::Time::Now(); | 302 base::Time end_create = base::Time::Now(); |
303 | 303 |
304 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id2)); | 304 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id2)); |
305 status = GetStatus(request_id2); | 305 status = GetStatus(request_id2); |
306 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 306 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
307 | 307 |
308 AsyncFileStream* write_file_stream = status.file_stream; | 308 AsyncFileStream* write_file_stream = status.file_stream; |
309 | 309 |
310 // Check that file was created and has 0 size. | 310 // Check that file was created and has 0 size. |
311 | 311 |
312 const int request_id3 = GetNextRequestId(); | 312 const int request_id3 = GetNextRequestId(); |
313 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 313 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
314 GetGetFileInfoCallback(request_id3)); | 314 GetGetFileInfoCallback(request_id3)); |
315 MessageLoop::current()->RunAllPending(); | 315 MessageLoop::current()->RunUntilIdle(); |
316 | 316 |
317 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id3)); | 317 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id3)); |
318 status = GetStatus(request_id3); | 318 status = GetStatus(request_id3); |
319 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 319 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
320 ASSERT_EQ(0, status.file_info.size); | 320 ASSERT_EQ(0, status.file_info.size); |
321 ASSERT_FALSE(status.file_info.is_directory); | 321 ASSERT_FALSE(status.file_info.is_directory); |
322 ASSERT_FALSE(status.file_info.is_symbolic_link); | 322 ASSERT_FALSE(status.file_info.is_symbolic_link); |
323 ASSERT_GE(status.file_info.last_modified, start_create); | 323 ASSERT_GE(status.file_info.last_modified, start_create); |
324 ASSERT_LE(status.file_info.last_modified, end_create); | 324 ASSERT_LE(status.file_info.last_modified, end_create); |
325 | 325 |
326 // Write 10 bytes to file. | 326 // Write 10 bytes to file. |
327 | 327 |
328 const int request_id4 = GetNextRequestId(); | 328 const int request_id4 = GetNextRequestId(); |
329 base::Time start_write = base::Time::Now(); | 329 base::Time start_write = base::Time::Now(); |
330 write_file_stream->Write(kTestString, 10, | 330 write_file_stream->Write(kTestString, 10, |
331 GetReadWriteCallback(request_id4)); | 331 GetReadWriteCallback(request_id4)); |
332 MessageLoop::current()->RunAllPending(); | 332 MessageLoop::current()->RunUntilIdle(); |
333 base::Time end_write = base::Time::Now(); | 333 base::Time end_write = base::Time::Now(); |
334 | 334 |
335 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id4)); | 335 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id4)); |
336 status = GetStatus(request_id4); | 336 status = GetStatus(request_id4); |
337 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 337 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
338 ASSERT_EQ(10, status.length); | 338 ASSERT_EQ(10, status.length); |
339 | 339 |
340 // Check that the file has now size 10 and correct modification time. | 340 // Check that the file has now size 10 and correct modification time. |
341 | 341 |
342 const int request_id5 = GetNextRequestId(); | 342 const int request_id5 = GetNextRequestId(); |
343 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 343 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
344 GetGetFileInfoCallback(request_id5)); | 344 GetGetFileInfoCallback(request_id5)); |
345 MessageLoop::current()->RunAllPending(); | 345 MessageLoop::current()->RunUntilIdle(); |
346 | 346 |
347 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id5)); | 347 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id5)); |
348 status = GetStatus(request_id5); | 348 status = GetStatus(request_id5); |
349 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 349 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
350 ASSERT_EQ(10, status.file_info.size); | 350 ASSERT_EQ(10, status.file_info.size); |
351 ASSERT_GE(status.file_info.last_modified, start_write); | 351 ASSERT_GE(status.file_info.last_modified, start_write); |
352 ASSERT_LE(status.file_info.last_modified, end_write); | 352 ASSERT_LE(status.file_info.last_modified, end_write); |
353 | 353 |
354 // Write the rest of the string to file. | 354 // Write the rest of the string to file. |
355 | 355 |
356 const int request_id6 = GetNextRequestId(); | 356 const int request_id6 = GetNextRequestId(); |
357 start_write = base::Time::Now(); | 357 start_write = base::Time::Now(); |
358 write_file_stream->Write(kTestString + 10, | 358 write_file_stream->Write(kTestString + 10, |
359 kTestStringLength - 10, | 359 kTestStringLength - 10, |
360 GetReadWriteCallback(request_id6)); | 360 GetReadWriteCallback(request_id6)); |
361 MessageLoop::current()->RunAllPending(); | 361 MessageLoop::current()->RunUntilIdle(); |
362 end_write = base::Time::Now(); | 362 end_write = base::Time::Now(); |
363 | 363 |
364 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id6)); | 364 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id6)); |
365 status = GetStatus(request_id6); | 365 status = GetStatus(request_id6); |
366 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 366 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
367 ASSERT_EQ(static_cast<int64>(kTestStringLength) - 10, status.length); | 367 ASSERT_EQ(static_cast<int64>(kTestStringLength) - 10, status.length); |
368 | 368 |
369 // Check the file size & modification time. | 369 // Check the file size & modification time. |
370 | 370 |
371 const int request_id7 = GetNextRequestId(); | 371 const int request_id7 = GetNextRequestId(); |
372 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 372 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
373 GetGetFileInfoCallback(request_id7)); | 373 GetGetFileInfoCallback(request_id7)); |
374 MessageLoop::current()->RunAllPending(); | 374 MessageLoop::current()->RunUntilIdle(); |
375 | 375 |
376 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id7)); | 376 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id7)); |
377 status = GetStatus(request_id7); | 377 status = GetStatus(request_id7); |
378 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 378 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
379 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); | 379 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); |
380 ASSERT_GE(status.file_info.last_modified, start_write); | 380 ASSERT_GE(status.file_info.last_modified, start_write); |
381 ASSERT_LE(status.file_info.last_modified, end_write); | 381 ASSERT_LE(status.file_info.last_modified, end_write); |
382 | 382 |
383 // Open file for reading. | 383 // Open file for reading. |
384 | 384 |
385 const int request_id8 = GetNextRequestId(); | 385 const int request_id8 = GetNextRequestId(); |
386 file_util()->Open(FilePath("/mnt/memory/test1.txt"), | 386 file_util()->Open(FilePath("/mnt/memory/test1.txt"), |
387 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 387 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
388 GetOpenCallback(request_id8)); | 388 GetOpenCallback(request_id8)); |
389 MessageLoop::current()->RunAllPending(); | 389 MessageLoop::current()->RunUntilIdle(); |
390 | 390 |
391 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id8)); | 391 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id8)); |
392 status = GetStatus(request_id8); | 392 status = GetStatus(request_id8); |
393 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 393 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
394 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 394 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
395 | 395 |
396 AsyncFileStream* read_file_stream = status.file_stream; | 396 AsyncFileStream* read_file_stream = status.file_stream; |
397 | 397 |
398 // Read the whole file | 398 // Read the whole file |
399 char buffer[1024]; | 399 char buffer[1024]; |
400 const int request_id9 = GetNextRequestId(); | 400 const int request_id9 = GetNextRequestId(); |
401 read_file_stream->Read(buffer, 1023, GetReadWriteCallback(request_id9)); | 401 read_file_stream->Read(buffer, 1023, GetReadWriteCallback(request_id9)); |
402 MessageLoop::current()->RunAllPending(); | 402 MessageLoop::current()->RunUntilIdle(); |
403 | 403 |
404 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id9)); | 404 ASSERT_EQ(CALLBACK_TYPE_READ_WRITE, GetStatusType(request_id9)); |
405 status = GetStatus(request_id9); | 405 status = GetStatus(request_id9); |
406 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 406 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
407 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); | 407 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); |
408 | 408 |
409 buffer[status.length] = '\0'; | 409 buffer[status.length] = '\0'; |
410 std::string result_string(buffer); | 410 std::string result_string(buffer); |
411 ASSERT_EQ(kTestString, result_string); | 411 ASSERT_EQ(kTestString, result_string); |
412 | 412 |
413 // Check that size & modification time have not changed. | 413 // Check that size & modification time have not changed. |
414 | 414 |
415 const int request_id10 = GetNextRequestId(); | 415 const int request_id10 = GetNextRequestId(); |
416 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 416 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
417 GetGetFileInfoCallback(request_id10)); | 417 GetGetFileInfoCallback(request_id10)); |
418 MessageLoop::current()->RunAllPending(); | 418 MessageLoop::current()->RunUntilIdle(); |
419 | 419 |
420 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id10)); | 420 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id10)); |
421 status = GetStatus(request_id10); | 421 status = GetStatus(request_id10); |
422 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 422 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
423 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); | 423 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); |
424 ASSERT_GE(status.file_info.last_modified, start_write); | 424 ASSERT_GE(status.file_info.last_modified, start_write); |
425 ASSERT_LE(status.file_info.last_modified, end_write); | 425 ASSERT_LE(status.file_info.last_modified, end_write); |
426 | 426 |
427 // Open once more for writing. | 427 // Open once more for writing. |
428 | 428 |
429 const int request_id11 = GetNextRequestId(); | 429 const int request_id11 = GetNextRequestId(); |
430 file_util()->Open(FilePath("/mnt/memory/test1.txt"), | 430 file_util()->Open(FilePath("/mnt/memory/test1.txt"), |
431 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE, | 431 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE, |
432 GetOpenCallback(request_id11)); | 432 GetOpenCallback(request_id11)); |
433 MessageLoop::current()->RunAllPending(); | 433 MessageLoop::current()->RunUntilIdle(); |
434 | 434 |
435 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id11)); | 435 ASSERT_EQ(CALLBACK_TYPE_OPEN, GetStatusType(request_id11)); |
436 status = GetStatus(request_id11); | 436 status = GetStatus(request_id11); |
437 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 437 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
438 | 438 |
439 AsyncFileStream* write_file_stream2 = status.file_stream; | 439 AsyncFileStream* write_file_stream2 = status.file_stream; |
440 | 440 |
441 // Check that the size has not changed. | 441 // Check that the size has not changed. |
442 | 442 |
443 const int request_id12 = GetNextRequestId(); | 443 const int request_id12 = GetNextRequestId(); |
444 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 444 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
445 GetGetFileInfoCallback(request_id12)); | 445 GetGetFileInfoCallback(request_id12)); |
446 MessageLoop::current()->RunAllPending(); | 446 MessageLoop::current()->RunUntilIdle(); |
447 | 447 |
448 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id12)); | 448 ASSERT_EQ(CALLBACK_TYPE_GET_FILE_INFO, GetStatusType(request_id12)); |
449 status = GetStatus(request_id12); | 449 status = GetStatus(request_id12); |
450 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 450 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
451 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); | 451 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.file_info.size); |
452 | 452 |
453 // Seek beyond the end of file. Should return error. | 453 // Seek beyond the end of file. Should return error. |
454 | 454 |
455 const int request_id13 = GetNextRequestId(); | 455 const int request_id13 = GetNextRequestId(); |
456 write_file_stream2->Seek(1000, GetStatusCallback(request_id13)); | 456 write_file_stream2->Seek(1000, GetStatusCallback(request_id13)); |
457 MessageLoop::current()->RunAllPending(); | 457 MessageLoop::current()->RunUntilIdle(); |
458 ASSERT_EQ(CALLBACK_TYPE_STATUS, GetStatusType(request_id13)); | 458 ASSERT_EQ(CALLBACK_TYPE_STATUS, GetStatusType(request_id13)); |
459 status = GetStatus(request_id13); | 459 status = GetStatus(request_id13); |
460 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status.result); | 460 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status.result); |
461 | 461 |
462 // Try to write to read-only stream. | 462 // Try to write to read-only stream. |
463 | 463 |
464 const int request_id14 = GetNextRequestId(); | 464 const int request_id14 = GetNextRequestId(); |
465 read_file_stream->Write(kTestString, | 465 read_file_stream->Write(kTestString, |
466 kTestStringLength, | 466 kTestStringLength, |
467 GetReadWriteCallback(request_id14)); | 467 GetReadWriteCallback(request_id14)); |
468 MessageLoop::current()->RunAllPending(); | 468 MessageLoop::current()->RunUntilIdle(); |
469 status = GetStatus(request_id14); | 469 status = GetStatus(request_id14); |
470 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status.result); | 470 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status.result); |
471 | 471 |
472 // Write data overlapping with already written. | 472 // Write data overlapping with already written. |
473 | 473 |
474 | 474 |
475 const int request_id15 = GetNextRequestId(); | 475 const int request_id15 = GetNextRequestId(); |
476 write_file_stream2->Seek(10, GetStatusCallback(request_id15)); | 476 write_file_stream2->Seek(10, GetStatusCallback(request_id15)); |
477 MessageLoop::current()->RunAllPending(); | 477 MessageLoop::current()->RunUntilIdle(); |
478 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id15).result); | 478 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id15).result); |
479 | 479 |
480 const int request_id16 = GetNextRequestId(); | 480 const int request_id16 = GetNextRequestId(); |
481 write_file_stream2->Write(kTestString, | 481 write_file_stream2->Write(kTestString, |
482 kTestStringLength, | 482 kTestStringLength, |
483 GetReadWriteCallback(request_id16)); | 483 GetReadWriteCallback(request_id16)); |
484 MessageLoop::current()->RunAllPending(); | 484 MessageLoop::current()->RunUntilIdle(); |
485 status = GetStatus(request_id16); | 485 status = GetStatus(request_id16); |
486 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 486 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
487 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); | 487 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); |
488 | 488 |
489 // Check size. | 489 // Check size. |
490 | 490 |
491 const int request_id17 = GetNextRequestId(); | 491 const int request_id17 = GetNextRequestId(); |
492 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), | 492 file_util()->GetFileInfo(FilePath("/mnt/memory/test1.txt"), |
493 GetGetFileInfoCallback(request_id17)); | 493 GetGetFileInfoCallback(request_id17)); |
494 MessageLoop::current()->RunAllPending(); | 494 MessageLoop::current()->RunUntilIdle(); |
495 status = GetStatus(request_id17); | 495 status = GetStatus(request_id17); |
496 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 496 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
497 ASSERT_EQ(static_cast<int64>(kTestStringLength) + 10, | 497 ASSERT_EQ(static_cast<int64>(kTestStringLength) + 10, |
498 status.file_info.size); | 498 status.file_info.size); |
499 | 499 |
500 // Read from 10th byte. | 500 // Read from 10th byte. |
501 const int request_id18 = GetNextRequestId(); | 501 const int request_id18 = GetNextRequestId(); |
502 read_file_stream->Seek(10, GetStatusCallback(request_id18)); | 502 read_file_stream->Seek(10, GetStatusCallback(request_id18)); |
503 MessageLoop::current()->RunAllPending(); | 503 MessageLoop::current()->RunUntilIdle(); |
504 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id18).result); | 504 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id18).result); |
505 | 505 |
506 const int request_id19 = GetNextRequestId(); | 506 const int request_id19 = GetNextRequestId(); |
507 read_file_stream->Read(buffer, 1023, GetReadWriteCallback(request_id19)); | 507 read_file_stream->Read(buffer, 1023, GetReadWriteCallback(request_id19)); |
508 MessageLoop::current()->RunAllPending(); | 508 MessageLoop::current()->RunUntilIdle(); |
509 status = GetStatus(request_id19); | 509 status = GetStatus(request_id19); |
510 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); | 510 ASSERT_EQ(base::PLATFORM_FILE_OK, status.result); |
511 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); | 511 ASSERT_EQ(static_cast<int64>(kTestStringLength), status.length); |
512 buffer[status.length] = '\0'; | 512 buffer[status.length] = '\0'; |
513 std::string result_string2(buffer); | 513 std::string result_string2(buffer); |
514 ASSERT_EQ(kTestString, result_string2); | 514 ASSERT_EQ(kTestString, result_string2); |
515 } | 515 } |
516 | 516 |
517 // The directory structure we'll be testing on: | 517 // The directory structure we'll be testing on: |
518 // path size | 518 // path size |
519 // | 519 // |
520 // /mnt/memory/a 0 | 520 // /mnt/memory/a 0 |
521 // /mnt/memory/b/ | 521 // /mnt/memory/b/ |
522 // /mnt/memory/b/c kTestStringLength | 522 // /mnt/memory/b/c kTestStringLength |
523 // /mnt/memory/b/d/ | 523 // /mnt/memory/b/d/ |
524 // /mnt/memory/b/e 0 | 524 // /mnt/memory/b/e 0 |
525 // /mnt/memory/b/f kTestStringLength | 525 // /mnt/memory/b/f kTestStringLength |
526 // /mnt/memory/b/g/ | 526 // /mnt/memory/b/g/ |
527 // /mnt/memory/b/g/h 0 | 527 // /mnt/memory/b/g/h 0 |
528 // /mnt/memory/b/i kTestStringLength | 528 // /mnt/memory/b/i kTestStringLength |
529 // /mnt/memory/c/ | 529 // /mnt/memory/c/ |
530 // /mnt/memory/longer_file_name.txt kTestStringLength | 530 // /mnt/memory/longer_file_name.txt kTestStringLength |
531 TEST_F(MemoryFileUtilTest, TestDirectoryOperations) { | 531 TEST_F(MemoryFileUtilTest, TestDirectoryOperations) { |
532 // Check the directory is empty. | 532 // Check the directory is empty. |
533 const int request_id0 = GetNextRequestId(); | 533 const int request_id0 = GetNextRequestId(); |
534 file_util()->ReadDirectory(FilePath("/mnt/memory/"), | 534 file_util()->ReadDirectory(FilePath("/mnt/memory/"), |
535 GetReadDirectoryCallback(request_id0)); | 535 GetReadDirectoryCallback(request_id0)); |
536 | 536 |
537 MessageLoop::current()->RunAllPending(); | 537 MessageLoop::current()->RunUntilIdle(); |
538 | 538 |
539 ASSERT_EQ(CALLBACK_TYPE_READ_DIRECTORY, GetStatusType(request_id0)); | 539 ASSERT_EQ(CALLBACK_TYPE_READ_DIRECTORY, GetStatusType(request_id0)); |
540 CallbackStatus& status = GetStatus(request_id0); | 540 CallbackStatus& status = GetStatus(request_id0); |
541 ASSERT_TRUE(status.completed); | 541 ASSERT_TRUE(status.completed); |
542 ASSERT_FALSE(status.called_after_completed); | 542 ASSERT_FALSE(status.called_after_completed); |
543 ASSERT_EQ(1, status.called); | 543 ASSERT_EQ(1, status.called); |
544 ASSERT_EQ(0u, status.entries.size()); | 544 ASSERT_EQ(0u, status.entries.size()); |
545 | 545 |
546 // Create /mnt/memory/a, /mnt/memory/b/, /mnt/memory/longer_file_name.txt, | 546 // Create /mnt/memory/a, /mnt/memory/b/, /mnt/memory/longer_file_name.txt, |
547 // /mnt/memory/c/ asyncronously (i.e. we do not wait for each operation to | 547 // /mnt/memory/c/ asyncronously (i.e. we do not wait for each operation to |
548 // complete before starting the next one. | 548 // complete before starting the next one. |
549 | 549 |
550 base::Time start_create = base::Time::Now(); | 550 base::Time start_create = base::Time::Now(); |
551 CreateEmptyFile(FilePath("/mnt/memory/a")); | 551 CreateEmptyFile(FilePath("/mnt/memory/a")); |
552 | 552 |
553 int request_id1 = GetNextRequestId(); | 553 int request_id1 = GetNextRequestId(); |
554 file_util()->CreateDirectory(FilePath("/mnt/memory/b"), | 554 file_util()->CreateDirectory(FilePath("/mnt/memory/b"), |
555 GetStatusCallback(request_id1)); | 555 GetStatusCallback(request_id1)); |
556 | 556 |
557 CreateNonEmptyFile(FilePath("/mnt/memory/longer_file_name.txt"), | 557 CreateNonEmptyFile(FilePath("/mnt/memory/longer_file_name.txt"), |
558 kTestString, | 558 kTestString, |
559 kTestStringLength); | 559 kTestStringLength); |
560 | 560 |
561 int request_id2 = GetNextRequestId(); | 561 int request_id2 = GetNextRequestId(); |
562 file_util()->CreateDirectory(FilePath("/mnt/memory/c"), | 562 file_util()->CreateDirectory(FilePath("/mnt/memory/c"), |
563 GetStatusCallback(request_id2)); | 563 GetStatusCallback(request_id2)); |
564 | 564 |
565 MessageLoop::current()->RunAllPending(); | 565 MessageLoop::current()->RunUntilIdle(); |
566 base::Time end_create = base::Time::Now(); | 566 base::Time end_create = base::Time::Now(); |
567 | 567 |
568 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 568 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
569 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id2).result); | 569 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id2).result); |
570 | 570 |
571 // ReadDirectory /mnt/memory, /mnt/memory/a (not a dir), /mnt/memory/b/, | 571 // ReadDirectory /mnt/memory, /mnt/memory/a (not a dir), /mnt/memory/b/, |
572 // /mnt/memory/d (not found) | 572 // /mnt/memory/d (not found) |
573 | 573 |
574 set_read_directory_buffer_size(5); // Should complete in one go. | 574 set_read_directory_buffer_size(5); // Should complete in one go. |
575 | 575 |
576 request_id1 = GetNextRequestId(); | 576 request_id1 = GetNextRequestId(); |
577 file_util()->ReadDirectory(FilePath("/mnt/memory"), | 577 file_util()->ReadDirectory(FilePath("/mnt/memory"), |
578 GetReadDirectoryCallback(request_id1)); | 578 GetReadDirectoryCallback(request_id1)); |
579 request_id2 = GetNextRequestId(); | 579 request_id2 = GetNextRequestId(); |
580 file_util()->ReadDirectory(FilePath("/mnt/memory/a"), | 580 file_util()->ReadDirectory(FilePath("/mnt/memory/a"), |
581 GetReadDirectoryCallback(request_id2)); | 581 GetReadDirectoryCallback(request_id2)); |
582 const int request_id3 = GetNextRequestId(); | 582 const int request_id3 = GetNextRequestId(); |
583 file_util()->ReadDirectory(FilePath("/mnt/memory/b/"), | 583 file_util()->ReadDirectory(FilePath("/mnt/memory/b/"), |
584 GetReadDirectoryCallback(request_id3)); | 584 GetReadDirectoryCallback(request_id3)); |
585 const int request_id4 = GetNextRequestId(); | 585 const int request_id4 = GetNextRequestId(); |
586 file_util()->ReadDirectory(FilePath("/mnt/memory/d/"), | 586 file_util()->ReadDirectory(FilePath("/mnt/memory/d/"), |
587 GetReadDirectoryCallback(request_id4)); | 587 GetReadDirectoryCallback(request_id4)); |
588 | 588 |
589 MessageLoop::current()->RunAllPending(); | 589 MessageLoop::current()->RunUntilIdle(); |
590 | 590 |
591 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 591 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
592 status = GetStatus(request_id1); | 592 status = GetStatus(request_id1); |
593 ASSERT_TRUE(status.completed); | 593 ASSERT_TRUE(status.completed); |
594 ASSERT_FALSE(status.called_after_completed); | 594 ASSERT_FALSE(status.called_after_completed); |
595 ASSERT_EQ(1, status.called); // Because the number of entries < 5. | 595 ASSERT_EQ(1, status.called); // Because the number of entries < 5. |
596 ASSERT_EQ(4u, status.entries.size()); | 596 ASSERT_EQ(4u, status.entries.size()); |
597 | 597 |
598 std::set<FilePath::StringType> seen; | 598 std::set<FilePath::StringType> seen; |
599 | 599 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 CreateNonEmptyFile(FilePath("/mnt/memory/b/f"), | 654 CreateNonEmptyFile(FilePath("/mnt/memory/b/f"), |
655 kTestString, | 655 kTestString, |
656 kTestStringLength); | 656 kTestStringLength); |
657 request_id2 = GetNextRequestId(); | 657 request_id2 = GetNextRequestId(); |
658 file_util()->CreateDirectory(FilePath("/mnt/memory/b/g"), | 658 file_util()->CreateDirectory(FilePath("/mnt/memory/b/g"), |
659 GetStatusCallback(request_id1)); | 659 GetStatusCallback(request_id1)); |
660 CreateNonEmptyFile(FilePath("/mnt/memory/b/i"), | 660 CreateNonEmptyFile(FilePath("/mnt/memory/b/i"), |
661 kTestString, | 661 kTestString, |
662 kTestStringLength); | 662 kTestStringLength); |
663 | 663 |
664 MessageLoop::current()->RunAllPending(); | 664 MessageLoop::current()->RunUntilIdle(); |
665 | 665 |
666 CreateEmptyFile(FilePath("/mnt/memory/b/g/h")); | 666 CreateEmptyFile(FilePath("/mnt/memory/b/g/h")); |
667 | 667 |
668 MessageLoop::current()->RunAllPending(); | 668 MessageLoop::current()->RunUntilIdle(); |
669 end_create = base::Time::Now(); | 669 end_create = base::Time::Now(); |
670 | 670 |
671 // Read /mnt/memory and check that the number of entries is unchanged. | 671 // Read /mnt/memory and check that the number of entries is unchanged. |
672 | 672 |
673 request_id1 = GetNextRequestId(); | 673 request_id1 = GetNextRequestId(); |
674 file_util()->ReadDirectory(FilePath("/mnt/memory"), | 674 file_util()->ReadDirectory(FilePath("/mnt/memory"), |
675 GetReadDirectoryCallback(request_id1)); | 675 GetReadDirectoryCallback(request_id1)); |
676 | 676 |
677 MessageLoop::current()->RunAllPending(); | 677 MessageLoop::current()->RunUntilIdle(); |
678 | 678 |
679 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 679 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
680 status = GetStatus(request_id1); | 680 status = GetStatus(request_id1); |
681 ASSERT_TRUE(status.completed); | 681 ASSERT_TRUE(status.completed); |
682 ASSERT_FALSE(status.called_after_completed); | 682 ASSERT_FALSE(status.called_after_completed); |
683 ASSERT_EQ(1, status.called); // Because the number of entries < 5. | 683 ASSERT_EQ(1, status.called); // Because the number of entries < 5. |
684 ASSERT_EQ(4u, status.entries.size()); | 684 ASSERT_EQ(4u, status.entries.size()); |
685 | 685 |
686 // Read /mnt/memory/b | 686 // Read /mnt/memory/b |
687 | 687 |
688 request_id1 = GetNextRequestId(); | 688 request_id1 = GetNextRequestId(); |
689 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), | 689 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), |
690 GetReadDirectoryCallback(request_id1)); | 690 GetReadDirectoryCallback(request_id1)); |
691 | 691 |
692 MessageLoop::current()->RunAllPending(); | 692 MessageLoop::current()->RunUntilIdle(); |
693 | 693 |
694 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 694 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
695 status = GetStatus(request_id1); | 695 status = GetStatus(request_id1); |
696 ASSERT_TRUE(status.completed); | 696 ASSERT_TRUE(status.completed); |
697 ASSERT_FALSE(status.called_after_completed); | 697 ASSERT_FALSE(status.called_after_completed); |
698 ASSERT_EQ(2, status.called); // Because the number of entries > 5. | 698 ASSERT_EQ(2, status.called); // Because the number of entries > 5. |
699 ASSERT_EQ(6u, status.entries.size()); | 699 ASSERT_EQ(6u, status.entries.size()); |
700 | 700 |
701 seen.clear(); | 701 seen.clear(); |
702 | 702 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 LOG(ERROR) << "Unexpected file: " << it->name; | 736 LOG(ERROR) << "Unexpected file: " << it->name; |
737 ASSERT_TRUE(false); | 737 ASSERT_TRUE(false); |
738 } | 738 } |
739 } | 739 } |
740 | 740 |
741 // Remove single file: /mnt/memory/b/f | 741 // Remove single file: /mnt/memory/b/f |
742 | 742 |
743 request_id1 = GetNextRequestId(); | 743 request_id1 = GetNextRequestId(); |
744 file_util()->Remove(FilePath("/mnt/memory/b/f"), false /* recursive */, | 744 file_util()->Remove(FilePath("/mnt/memory/b/f"), false /* recursive */, |
745 GetStatusCallback(request_id1)); | 745 GetStatusCallback(request_id1)); |
746 MessageLoop::current()->RunAllPending(); | 746 MessageLoop::current()->RunUntilIdle(); |
747 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 747 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
748 | 748 |
749 // Check the number of files in b/ | 749 // Check the number of files in b/ |
750 | 750 |
751 request_id1 = GetNextRequestId(); | 751 request_id1 = GetNextRequestId(); |
752 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), | 752 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), |
753 GetReadDirectoryCallback(request_id1)); | 753 GetReadDirectoryCallback(request_id1)); |
754 | 754 |
755 MessageLoop::current()->RunAllPending(); | 755 MessageLoop::current()->RunUntilIdle(); |
756 | 756 |
757 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 757 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
758 status = GetStatus(request_id1); | 758 status = GetStatus(request_id1); |
759 ASSERT_TRUE(status.completed); | 759 ASSERT_TRUE(status.completed); |
760 ASSERT_FALSE(status.called_after_completed); | 760 ASSERT_FALSE(status.called_after_completed); |
761 ASSERT_EQ(5u, status.entries.size()); | 761 ASSERT_EQ(5u, status.entries.size()); |
762 | 762 |
763 // Try remove /mnt/memory/b non-recursively (error) | 763 // Try remove /mnt/memory/b non-recursively (error) |
764 | 764 |
765 request_id1 = GetNextRequestId(); | 765 request_id1 = GetNextRequestId(); |
766 file_util()->Remove(FilePath("/mnt/memory/b"), false /* recursive */, | 766 file_util()->Remove(FilePath("/mnt/memory/b"), false /* recursive */, |
767 GetStatusCallback(request_id1)); | 767 GetStatusCallback(request_id1)); |
768 MessageLoop::current()->RunAllPending(); | 768 MessageLoop::current()->RunUntilIdle(); |
769 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE, | 769 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE, |
770 GetStatus(request_id1).result); | 770 GetStatus(request_id1).result); |
771 | 771 |
772 // Non-recursively remove empty directory. | 772 // Non-recursively remove empty directory. |
773 | 773 |
774 request_id1 = GetNextRequestId(); | 774 request_id1 = GetNextRequestId(); |
775 file_util()->Remove(FilePath("/mnt/memory/b/d"), false /* recursive */, | 775 file_util()->Remove(FilePath("/mnt/memory/b/d"), false /* recursive */, |
776 GetStatusCallback(request_id1)); | 776 GetStatusCallback(request_id1)); |
777 MessageLoop::current()->RunAllPending(); | 777 MessageLoop::current()->RunUntilIdle(); |
778 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 778 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
779 | 779 |
780 request_id1 = GetNextRequestId(); | 780 request_id1 = GetNextRequestId(); |
781 file_util()->GetFileInfo(FilePath("/mnt/memory/b/d"), | 781 file_util()->GetFileInfo(FilePath("/mnt/memory/b/d"), |
782 GetGetFileInfoCallback(request_id1)); | 782 GetGetFileInfoCallback(request_id1)); |
783 MessageLoop::current()->RunAllPending(); | 783 MessageLoop::current()->RunUntilIdle(); |
784 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, GetStatus(request_id1).result); | 784 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, GetStatus(request_id1).result); |
785 | 785 |
786 // Remove /mnt/memory/b recursively. | 786 // Remove /mnt/memory/b recursively. |
787 | 787 |
788 request_id1 = GetNextRequestId(); | 788 request_id1 = GetNextRequestId(); |
789 file_util()->Remove(FilePath("/mnt/memory/b"), true /* recursive */, | 789 file_util()->Remove(FilePath("/mnt/memory/b"), true /* recursive */, |
790 GetStatusCallback(request_id1)); | 790 GetStatusCallback(request_id1)); |
791 MessageLoop::current()->RunAllPending(); | 791 MessageLoop::current()->RunUntilIdle(); |
792 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 792 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
793 | 793 |
794 // ReadDirectory /mnt/memory/b -> not found | 794 // ReadDirectory /mnt/memory/b -> not found |
795 | 795 |
796 request_id1 = GetNextRequestId(); | 796 request_id1 = GetNextRequestId(); |
797 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), | 797 file_util()->ReadDirectory(FilePath("/mnt/memory/b"), |
798 GetReadDirectoryCallback(request_id1)); | 798 GetReadDirectoryCallback(request_id1)); |
799 MessageLoop::current()->RunAllPending(); | 799 MessageLoop::current()->RunUntilIdle(); |
800 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, GetStatus(request_id1).result); | 800 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, GetStatus(request_id1).result); |
801 | 801 |
802 // ReadDirectory /mnt/memory | 802 // ReadDirectory /mnt/memory |
803 | 803 |
804 request_id1 = GetNextRequestId(); | 804 request_id1 = GetNextRequestId(); |
805 file_util()->ReadDirectory(FilePath("/mnt/memory"), | 805 file_util()->ReadDirectory(FilePath("/mnt/memory"), |
806 GetReadDirectoryCallback(request_id1)); | 806 GetReadDirectoryCallback(request_id1)); |
807 | 807 |
808 MessageLoop::current()->RunAllPending(); | 808 MessageLoop::current()->RunUntilIdle(); |
809 | 809 |
810 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); | 810 ASSERT_EQ(base::PLATFORM_FILE_OK, GetStatus(request_id1).result); |
811 status = GetStatus(request_id1); | 811 status = GetStatus(request_id1); |
812 ASSERT_TRUE(status.completed); | 812 ASSERT_TRUE(status.completed); |
813 ASSERT_FALSE(status.called_after_completed); | 813 ASSERT_FALSE(status.called_after_completed); |
814 ASSERT_EQ(3u, status.entries.size()); | 814 ASSERT_EQ(3u, status.entries.size()); |
815 | 815 |
816 seen.clear(); | 816 seen.clear(); |
817 | 817 |
818 for (FileUtilAsync::FileList::const_iterator it = status.entries.begin(); | 818 for (FileUtilAsync::FileList::const_iterator it = status.entries.begin(); |
(...skipping 11 matching lines...) Expand all Loading... |
830 ASSERT_FALSE(it->is_directory); | 830 ASSERT_FALSE(it->is_directory); |
831 ASSERT_EQ(static_cast<int64>(kTestStringLength), it->size); | 831 ASSERT_EQ(static_cast<int64>(kTestStringLength), it->size); |
832 } else { | 832 } else { |
833 LOG(ERROR) << "Unexpected file: " << it->name; | 833 LOG(ERROR) << "Unexpected file: " << it->name; |
834 ASSERT_TRUE(false); | 834 ASSERT_TRUE(false); |
835 } | 835 } |
836 } | 836 } |
837 } | 837 } |
838 | 838 |
839 } // namespace fileapi | 839 } // namespace fileapi |
OLD | NEW |