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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 14 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
14 #include "chrome/browser/google_apis/test_server/http_server.h" | 15 #include "chrome/browser/google_apis/test_server/http_server.h" |
15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "googleurl/src/gurl.h" |
17 | 19 |
18 namespace google_apis { | 20 namespace google_apis { |
19 namespace test_util { | 21 namespace test_util { |
20 | 22 |
21 // This class is used to monitor if any task is posted to a message loop. | 23 // This class is used to monitor if any task is posted to a message loop. |
22 class TaskObserver : public MessageLoop::TaskObserver { | 24 class TaskObserver : public MessageLoop::TaskObserver { |
23 public: | 25 public: |
24 TaskObserver() : posted_(false) {} | 26 TaskObserver() : posted_(false) {} |
25 virtual ~TaskObserver() {} | 27 virtual ~TaskObserver() {} |
26 | 28 |
(...skipping 13 matching lines...) Expand all Loading... |
40 | 42 |
41 FilePath GetTestFilePath(const std::string& relative_path) { | 43 FilePath GetTestFilePath(const std::string& relative_path) { |
42 FilePath path; | 44 FilePath path; |
43 std::string error; | 45 std::string error; |
44 PathService::Get(chrome::DIR_TEST_DATA, &path); | 46 PathService::Get(chrome::DIR_TEST_DATA, &path); |
45 path = path.AppendASCII("chromeos") | 47 path = path.AppendASCII("chromeos") |
46 .Append(FilePath::FromUTF8Unsafe(relative_path)); | 48 .Append(FilePath::FromUTF8Unsafe(relative_path)); |
47 return path; | 49 return path; |
48 } | 50 } |
49 | 51 |
| 52 GURL GetBaseUrlForTesting(int port) { |
| 53 return GURL(base::StringPrintf("http://127.0.0.1:%d/", port)); |
| 54 } |
| 55 |
50 void RunBlockingPoolTask() { | 56 void RunBlockingPoolTask() { |
51 while (true) { | 57 while (true) { |
52 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 58 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
53 | 59 |
54 TaskObserver task_observer; | 60 TaskObserver task_observer; |
55 MessageLoop::current()->AddTaskObserver(&task_observer); | 61 MessageLoop::current()->AddTaskObserver(&task_observer); |
56 MessageLoop::current()->RunUntilIdle(); | 62 MessageLoop::current()->RunUntilIdle(); |
57 MessageLoop::current()->RemoveTaskObserver(&task_observer); | 63 MessageLoop::current()->RemoveTaskObserver(&task_observer); |
58 if (!task_observer.posted()) | 64 if (!task_observer.posted()) |
59 break; | 65 break; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 scoped_ptr<test_server::HttpResponse> http_response( | 134 scoped_ptr<test_server::HttpResponse> http_response( |
129 new test_server::HttpResponse); | 135 new test_server::HttpResponse); |
130 http_response->set_code(test_server::SUCCESS); | 136 http_response->set_code(test_server::SUCCESS); |
131 http_response->set_content(content); | 137 http_response->set_content(content); |
132 http_response->set_content_type(content_type); | 138 http_response->set_content_type(content_type); |
133 return http_response.Pass(); | 139 return http_response.Pass(); |
134 } | 140 } |
135 | 141 |
136 } // namespace test_util | 142 } // namespace test_util |
137 } // namespace google_apis | 143 } // namespace google_apis |
OLD | NEW |