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

Side by Side Diff: components/drive/local_file_reader_unittest.cc

Issue 2317993003: //chrome/browser and //components A-E: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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
OLDNEW
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 "components/drive/local_file_reader.h" 5 #include "components/drive/local_file_reader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 base::MessageLoop message_loop_; 58 base::MessageLoop message_loop_;
59 base::ScopedTempDir temp_dir_; 59 base::ScopedTempDir temp_dir_;
60 std::unique_ptr<base::Thread> worker_thread_; 60 std::unique_ptr<base::Thread> worker_thread_;
61 std::unique_ptr<LocalFileReader> file_reader_; 61 std::unique_ptr<LocalFileReader> file_reader_;
62 }; 62 };
63 63
64 TEST_F(LocalFileReaderTest, NonExistingFile) { 64 TEST_F(LocalFileReaderTest, NonExistingFile) {
65 const base::FilePath kTestFile = 65 const base::FilePath kTestFile =
66 temp_dir_.path().AppendASCII("non-existing"); 66 temp_dir_.GetPath().AppendASCII("non-existing");
67 67
68 net::TestCompletionCallback callback; 68 net::TestCompletionCallback callback;
69 file_reader_->Open(kTestFile, 0, callback.callback()); 69 file_reader_->Open(kTestFile, 0, callback.callback());
70 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, callback.WaitForResult()); 70 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, callback.WaitForResult());
71 } 71 }
72 72
73 TEST_F(LocalFileReaderTest, FullRead) { 73 TEST_F(LocalFileReaderTest, FullRead) {
74 base::FilePath test_file; 74 base::FilePath test_file;
75 std::string expected_content; 75 std::string expected_content;
76 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize( 76 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize(
77 temp_dir_.path(), 1024, &test_file, &expected_content)); 77 temp_dir_.GetPath(), 1024, &test_file, &expected_content));
78 78
79 net::TestCompletionCallback callback; 79 net::TestCompletionCallback callback;
80 file_reader_->Open(test_file, 0, callback.callback()); 80 file_reader_->Open(test_file, 0, callback.callback());
81 ASSERT_EQ(net::OK, callback.WaitForResult()); 81 ASSERT_EQ(net::OK, callback.WaitForResult());
82 82
83 LocalFileReaderAdapter adapter(file_reader_.get()); 83 LocalFileReaderAdapter adapter(file_reader_.get());
84 std::string content; 84 std::string content;
85 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); 85 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content));
86 EXPECT_EQ(expected_content, content); 86 EXPECT_EQ(expected_content, content);
87 } 87 }
88 88
89 TEST_F(LocalFileReaderTest, OpenWithOffset) { 89 TEST_F(LocalFileReaderTest, OpenWithOffset) {
90 base::FilePath test_file; 90 base::FilePath test_file;
91 std::string expected_content; 91 std::string expected_content;
92 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize( 92 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize(
93 temp_dir_.path(), 1024, &test_file, &expected_content)); 93 temp_dir_.GetPath(), 1024, &test_file, &expected_content));
94 94
95 size_t offset = expected_content.size() / 2; 95 size_t offset = expected_content.size() / 2;
96 expected_content.erase(0, offset); 96 expected_content.erase(0, offset);
97 97
98 net::TestCompletionCallback callback; 98 net::TestCompletionCallback callback;
99 file_reader_->Open(test_file, static_cast<int64_t>(offset), 99 file_reader_->Open(test_file, static_cast<int64_t>(offset),
100 callback.callback()); 100 callback.callback());
101 ASSERT_EQ(net::OK, callback.WaitForResult()); 101 ASSERT_EQ(net::OK, callback.WaitForResult());
102 102
103 LocalFileReaderAdapter adapter(file_reader_.get()); 103 LocalFileReaderAdapter adapter(file_reader_.get());
104 std::string content; 104 std::string content;
105 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); 105 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content));
106 EXPECT_EQ(expected_content, content); 106 EXPECT_EQ(expected_content, content);
107 } 107 }
108 108
109 } // namespace util 109 } // namespace util
110 } // namespace drive 110 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/job_scheduler_unittest.cc ('k') | components/drive/remove_stale_cache_files_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698