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" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 TaskObserver task_observer; | 79 TaskObserver task_observer; |
80 MessageLoop::current()->AddTaskObserver(&task_observer); | 80 MessageLoop::current()->AddTaskObserver(&task_observer); |
81 MessageLoop::current()->RunUntilIdle(); | 81 MessageLoop::current()->RunUntilIdle(); |
82 MessageLoop::current()->RemoveTaskObserver(&task_observer); | 82 MessageLoop::current()->RemoveTaskObserver(&task_observer); |
83 if (!task_observer.posted()) | 83 if (!task_observer.posted()) |
84 break; | 84 break; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
| 88 void RunAndQuit(const base::Closure& closure) { |
| 89 closure.Run(); |
| 90 MessageLoop::current()->Quit(); |
| 91 } |
| 92 |
88 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { | 93 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { |
89 base::FilePath path = GetTestFilePath(relative_path); | 94 base::FilePath path = GetTestFilePath(relative_path); |
90 | 95 |
91 std::string error; | 96 std::string error; |
92 JSONFileValueSerializer serializer(path); | 97 JSONFileValueSerializer serializer(path); |
93 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); | 98 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); |
94 LOG_IF(WARNING, !value.get()) << "Failed to parse " << path.value() | 99 LOG_IF(WARNING, !value.get()) << "Failed to parse " << path.value() |
95 << ": " << error; | 100 << ": " << error; |
96 return value.Pass(); | 101 return value.Pass(); |
97 } | 102 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 base::SplitString(range, '-', &parts); | 310 base::SplitString(range, '-', &parts); |
306 if (parts.size() != 2U) | 311 if (parts.size() != 2U) |
307 return false; | 312 return false; |
308 | 313 |
309 return (base::StringToInt64(parts[0], start_position) && | 314 return (base::StringToInt64(parts[0], start_position) && |
310 base::StringToInt64(parts[1], end_position)); | 315 base::StringToInt64(parts[1], end_position)); |
311 } | 316 } |
312 | 317 |
313 } // namespace test_util | 318 } // namespace test_util |
314 } // namespace google_apis | 319 } // namespace google_apis |
OLD | NEW |