OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/drive_file_stream_reader.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/browser/chromeos/drive/fake_file_system.h" | 14 #include "chrome/browser/chromeos/drive/fake_file_system.h" |
15 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
16 #include "chrome/browser/chromeos/drive/local_file_reader.h" | 16 #include "chrome/browser/chromeos/drive/local_file_reader.h" |
17 #include "chrome/browser/chromeos/drive/test_util.h" | 17 #include "chrome/browser/chromeos/drive/test_util.h" |
18 #include "chrome/browser/drive/fake_drive_service.h" | 18 #include "chrome/browser/drive/fake_drive_service.h" |
19 #include "chrome/browser/drive/test_util.h" | 19 #include "chrome/browser/drive/test_util.h" |
20 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "content/public/test/test_utils.h" |
21 #include "google_apis/drive/drive_api_parser.h" | 22 #include "google_apis/drive/drive_api_parser.h" |
22 #include "google_apis/drive/test_util.h" | 23 #include "google_apis/drive/test_util.h" |
23 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
24 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
25 #include "net/base/test_completion_callback.h" | 26 #include "net/base/test_completion_callback.h" |
26 #include "net/http/http_byte_range.h" | 27 #include "net/http/http_byte_range.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
28 | 29 |
29 namespace drive { | 30 namespace drive { |
30 namespace internal { | 31 namespace internal { |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 { | 495 { |
495 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 496 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
496 scoped_ptr<google_apis::FileResource> entry; | 497 scoped_ptr<google_apis::FileResource> entry; |
497 fake_drive_service_->AddNewFile( | 498 fake_drive_service_->AddNewFile( |
498 "text/plain", | 499 "text/plain", |
499 "", // empty | 500 "", // empty |
500 fake_drive_service_->GetRootResourceId(), | 501 fake_drive_service_->GetRootResourceId(), |
501 "EmptyFile.txt", | 502 "EmptyFile.txt", |
502 false, // shared_with_me | 503 false, // shared_with_me |
503 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); | 504 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
504 drive::test_util::RunBlockingPoolTask(); | 505 content::RunAllBlockingPoolTasksUntilIdle(); |
505 ASSERT_EQ(google_apis::HTTP_CREATED, error); | 506 ASSERT_EQ(google_apis::HTTP_CREATED, error); |
506 ASSERT_TRUE(entry); | 507 ASSERT_TRUE(entry); |
507 ASSERT_EQ(0, entry->file_size()); | 508 ASSERT_EQ(0, entry->file_size()); |
508 } | 509 } |
509 | 510 |
510 const base::FilePath kDriveFile = | 511 const base::FilePath kDriveFile = |
511 util::GetDriveMyDriveRootPath().AppendASCII("EmptyFile.txt"); | 512 util::GetDriveMyDriveRootPath().AppendASCII("EmptyFile.txt"); |
512 // Create the reader, and initialize it. | 513 // Create the reader, and initialize it. |
513 // In this case, the file is not yet locally cached. | 514 // In this case, the file is not yet locally cached. |
514 scoped_ptr<DriveFileStreamReader> reader(new DriveFileStreamReader( | 515 scoped_ptr<DriveFileStreamReader> reader(new DriveFileStreamReader( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 ASSERT_TRUE(entry); | 560 ASSERT_TRUE(entry); |
560 EXPECT_TRUE(reader->IsInitialized()); | 561 EXPECT_TRUE(reader->IsInitialized()); |
561 | 562 |
562 // Read data from the reader, again. | 563 // Read data from the reader, again. |
563 std::string second_content; | 564 std::string second_content; |
564 ASSERT_EQ(net::OK, test_util::ReadAllData(reader.get(), &second_content)); | 565 ASSERT_EQ(net::OK, test_util::ReadAllData(reader.get(), &second_content)); |
565 EXPECT_EQ(0u, second_content.size()); | 566 EXPECT_EQ(0u, second_content.size()); |
566 } | 567 } |
567 | 568 |
568 } // namespace drive | 569 } // namespace drive |
OLD | NEW |