OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 IN_PROC_BROWSER_TEST_F(GDataTest, Download) { | 76 IN_PROC_BROWSER_TEST_F(GDataTest, Download) { |
77 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; | 77 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; |
78 std::string contents; | 78 std::string contents; |
79 service_->DownloadFile( | 79 service_->DownloadFile( |
80 FilePath("/dummy/gdata/testfile.txt"), | 80 FilePath("/dummy/gdata/testfile.txt"), |
81 GetTestCachedFilePath(FilePath("cached_testfile.txt")), | 81 GetTestCachedFilePath(FilePath("cached_testfile.txt")), |
82 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), | 82 gdata_test_server_.GetURL("files/chromeos/gdata/testfile.txt"), |
83 base::Bind(&TestDownloadCallback, &result, &contents), | 83 base::Bind(&TestDownloadCallback, &result, &contents), |
84 gdata::GetDownloadDataCallback()); | 84 gdata::GetContentCallback()); |
85 content::RunMessageLoop(); | 85 content::RunMessageLoop(); |
86 | 86 |
87 EXPECT_EQ(gdata::HTTP_SUCCESS, result); | 87 EXPECT_EQ(gdata::HTTP_SUCCESS, result); |
88 FilePath expected_filepath = gdata_test_server_.document_root().Append( | 88 FilePath expected_filepath = gdata_test_server_.document_root().Append( |
89 FilePath(FILE_PATH_LITERAL("chromeos/gdata/testfile.txt"))); | 89 FilePath(FILE_PATH_LITERAL("chromeos/gdata/testfile.txt"))); |
90 std::string expected_contents; | 90 std::string expected_contents; |
91 file_util::ReadFileToString(expected_filepath, &expected_contents); | 91 file_util::ReadFileToString(expected_filepath, &expected_contents); |
92 EXPECT_EQ(expected_contents, contents); | 92 EXPECT_EQ(expected_contents, contents); |
93 } | 93 } |
94 | 94 |
95 IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) { | 95 IN_PROC_BROWSER_TEST_F(GDataTest, NonExistingDownload) { |
96 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; | 96 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; |
97 std::string dummy_contents; | 97 std::string dummy_contents; |
98 service_->DownloadFile( | 98 service_->DownloadFile( |
99 FilePath("/dummy/gdata/no-such-file.txt"), | 99 FilePath("/dummy/gdata/no-such-file.txt"), |
100 GetTestCachedFilePath(FilePath("cache_no-such-file.txt")), | 100 GetTestCachedFilePath(FilePath("cache_no-such-file.txt")), |
101 gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"), | 101 gdata_test_server_.GetURL("files/chromeos/gdata/no-such-file.txt"), |
102 base::Bind(&TestDownloadCallback, &result, &dummy_contents), | 102 base::Bind(&TestDownloadCallback, &result, &dummy_contents), |
103 gdata::GetDownloadDataCallback()); | 103 gdata::GetContentCallback()); |
104 content::RunMessageLoop(); | 104 content::RunMessageLoop(); |
105 | 105 |
106 EXPECT_EQ(gdata::HTTP_NOT_FOUND, result); | 106 EXPECT_EQ(gdata::HTTP_NOT_FOUND, result); |
107 // Do not verify the not found message. | 107 // Do not verify the not found message. |
108 } | 108 } |
109 | 109 |
110 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { | 110 IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { |
111 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; | 111 gdata::GDataErrorCode result = gdata::GDATA_OTHER_ERROR; |
112 base::Value* result_data = NULL; | 112 base::Value* result_data = NULL; |
113 service_->GetDocuments( | 113 service_->GetDocuments( |
(...skipping 27 matching lines...) Expand all Loading... |
141 std::string(), // search string | 141 std::string(), // search string |
142 std::string(), // directory resource ID | 142 std::string(), // directory resource ID |
143 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); | 143 base::Bind(&TestGetDocumentsCallback, &result, &result_data)); |
144 content::RunMessageLoop(); | 144 content::RunMessageLoop(); |
145 | 145 |
146 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); | 146 EXPECT_EQ(gdata::GDATA_PARSE_ERROR, result); |
147 EXPECT_FALSE(result_data); | 147 EXPECT_FALSE(result_data); |
148 } | 148 } |
149 | 149 |
150 } // namespace gdata | 150 } // namespace gdata |
OLD | NEW |