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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 "Couldn't find " << path.value(); | 47 "Couldn't find " << path.value(); |
48 return path; | 48 return path; |
49 } | 49 } |
50 | 50 |
51 void RunBlockingPoolTask() { | 51 void RunBlockingPoolTask() { |
52 while (true) { | 52 while (true) { |
53 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 53 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
54 | 54 |
55 TaskObserver task_observer; | 55 TaskObserver task_observer; |
56 MessageLoop::current()->AddTaskObserver(&task_observer); | 56 MessageLoop::current()->AddTaskObserver(&task_observer); |
57 MessageLoop::current()->RunAllPending(); | 57 MessageLoop::current()->RunUntilIdle(); |
58 MessageLoop::current()->RemoveTaskObserver(&task_observer); | 58 MessageLoop::current()->RemoveTaskObserver(&task_observer); |
59 if (!task_observer.posted()) | 59 if (!task_observer.posted()) |
60 break; | 60 break; |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 | 64 |
65 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { | 65 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { |
66 FilePath path = GetTestFilePath(relative_path); | 66 FilePath path = GetTestFilePath(relative_path); |
67 | 67 |
68 std::string error; | 68 std::string error; |
69 JSONFileValueSerializer serializer(path); | 69 JSONFileValueSerializer serializer(path); |
70 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); | 70 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); |
71 EXPECT_TRUE(value.get()) << | 71 EXPECT_TRUE(value.get()) << |
72 "Parse error " << path.value() << ": " << error; | 72 "Parse error " << path.value() << ": " << error; |
73 return value.Pass(); | 73 return value.Pass(); |
74 } | 74 } |
75 | 75 |
76 } // namespace test_util | 76 } // namespace test_util |
77 } // namespace google_apis | 77 } // namespace google_apis |
OLD | NEW |