| 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 "chrome/browser/google_apis/test_util.h" | 5 #include "chrome/browser/google_apis/test_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/pending_task.h" | 12 #include "base/pending_task.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/run_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 19 #include "chrome/browser/google_apis/drive_api_parser.h" | 20 #include "chrome/browser/google_apis/drive_api_parser.h" |
| 20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 21 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 21 #include "chrome/browser/google_apis/gdata_wapi_requests.h" | 22 #include "chrome/browser/google_apis/gdata_wapi_requests.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 GURL GetBaseUrlForTesting(int port) { | 73 GURL GetBaseUrlForTesting(int port) { |
| 73 return GURL(base::StringPrintf("http://127.0.0.1:%d/", port)); | 74 return GURL(base::StringPrintf("http://127.0.0.1:%d/", port)); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void RunBlockingPoolTask() { | 77 void RunBlockingPoolTask() { |
| 77 while (true) { | 78 while (true) { |
| 78 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 79 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 79 | 80 |
| 80 TaskObserver task_observer; | 81 TaskObserver task_observer; |
| 81 base::MessageLoop::current()->AddTaskObserver(&task_observer); | 82 base::MessageLoop::current()->AddTaskObserver(&task_observer); |
| 82 base::MessageLoop::current()->RunUntilIdle(); | 83 base::RunLoop().RunUntilIdle(); |
| 83 base::MessageLoop::current()->RemoveTaskObserver(&task_observer); | 84 base::MessageLoop::current()->RemoveTaskObserver(&task_observer); |
| 84 if (!task_observer.posted()) | 85 if (!task_observer.posted()) |
| 85 break; | 86 break; |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 void RunAndQuit(const base::Closure& closure) { | 90 void RunAndQuit(base::RunLoop* run_loop, const base::Closure& closure) { |
| 90 closure.Run(); | 91 closure.Run(); |
| 91 base::MessageLoop::current()->Quit(); | 92 run_loop->Quit(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 bool WriteStringToFile(const base::FilePath& file_path, | 95 bool WriteStringToFile(const base::FilePath& file_path, |
| 95 const std::string& content) { | 96 const std::string& content) { |
| 96 int result = file_util::WriteFile(file_path, content.data(), content.size()); | 97 int result = file_util::WriteFile(file_path, content.data(), content.size()); |
| 97 return content.size() == static_cast<size_t>(result); | 98 return content.size() == static_cast<size_t>(result); |
| 98 } | 99 } |
| 99 | 100 |
| 100 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir, | 101 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir, |
| 101 size_t size, | 102 size_t size, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return result; | 236 return result; |
| 236 } | 237 } |
| 237 | 238 |
| 238 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error, | 239 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error, |
| 239 scoped_ptr<std::string> data) { | 240 scoped_ptr<std::string> data) { |
| 240 data_.push_back(data.release()); | 241 data_.push_back(data.release()); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace test_util | 244 } // namespace test_util |
| 244 } // namespace google_apis | 245 } // namespace google_apis |
| OLD | NEW |