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

Unified Diff: chrome/browser/google_apis/fake_drive_service_unittest.cc

Issue 14362022: Extract testing utility TestGetContentCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/fake_drive_service_unittest.cc
diff --git a/chrome/browser/google_apis/fake_drive_service_unittest.cc b/chrome/browser/google_apis/fake_drive_service_unittest.cc
index 7a5b43d7e44a3493c25ec9ee9dba7771b249084b..4699e0045ad1fad053f867c059e4f58775cc1794 100644
--- a/chrome/browser/google_apis/fake_drive_service_unittest.cc
+++ b/chrome/browser/google_apis/fake_drive_service_unittest.cc
@@ -91,14 +91,6 @@ class FakeDriveServiceTest : public testing::Test {
FakeDriveService fake_service_;
};
-void AppendGetContentCallbackResult(
- std::vector<std::string>* values,
- GDataErrorCode error,
- scoped_ptr<std::string> content) {
- DCHECK_EQ(error, HTTP_SUCCESS); // Should always HTTP_SUCCESS.
- values->push_back(*content);
-}
-
void AppendProgressCallbackResult(std::vector<int64>* values, int64 progress) {
values->push_back(progress);
}
@@ -864,13 +856,13 @@ TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) {
temp_dir.path().AppendASCII("whatever.txt");
GDataErrorCode error = GDATA_OTHER_ERROR;
base::FilePath output_file_path;
- std::vector<std::string> content_buffer;
+ test_util::TestGetContentCallback get_content_callback;
fake_service_.DownloadFile(
base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
kOutputFilePath,
kContentUrl,
test_util::CreateCopyResultCallback(&error, &output_file_path),
- base::Bind(&AppendGetContentCallbackResult, &content_buffer),
+ get_content_callback.callback(),
base::Bind(&test_util::AppendProgressCallbackResult,
&download_progress_values));
message_loop_.RunUntilIdle();
@@ -885,12 +877,7 @@ TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) {
EXPECT_TRUE(base::STLIsSorted(download_progress_values));
EXPECT_GE(download_progress_values.front().first, 0);
EXPECT_LE(download_progress_values.back().first, 10);
-
- std::string concatenated_content;
- for (size_t i = 0; i < content_buffer.size(); ++i) {
- concatenated_content += content_buffer[i];
- }
- EXPECT_EQ(content, concatenated_content);
+ EXPECT_EQ(content, get_content_callback.GetConcatenatedData());
}
TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) {
« no previous file with comments | « no previous file | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698