Chromium Code Reviews| 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/chromeos/gdata/gdata_test_util.h" | 5 #include "chrome/browser/google_apis/gdata_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/threading/sequenced_worker_pool.h" | 11 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
|
satorux1
2012/09/16 15:46:33
Please refrain from making unnecessary changes lik
nhiroki
2012/09/16 16:42:02
Done.
| |
| 16 | |
| 17 namespace gdata { | 16 namespace gdata { |
| 18 namespace test_util { | 17 namespace test_util { |
| 19 | 18 |
| 20 // This class is used to monitor if any task is posted to a message loop. | 19 // This class is used to monitor if any task is posted to a message loop. |
| 21 class TaskObserver : public MessageLoop::TaskObserver { | 20 class TaskObserver : public MessageLoop::TaskObserver { |
| 22 public: | 21 public: |
| 23 TaskObserver() : posted_(false) {} | 22 TaskObserver() : posted_(false) {} |
| 24 virtual ~TaskObserver() {} | 23 virtual ~TaskObserver() {} |
| 25 | 24 |
| 26 // MessageLoop::TaskObserver overrides. | 25 // MessageLoop::TaskObserver overrides. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 53 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 52 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 54 | 53 |
| 55 TaskObserver task_observer; | 54 TaskObserver task_observer; |
| 56 MessageLoop::current()->AddTaskObserver(&task_observer); | 55 MessageLoop::current()->AddTaskObserver(&task_observer); |
| 57 MessageLoop::current()->RunAllPending(); | 56 MessageLoop::current()->RunAllPending(); |
| 58 MessageLoop::current()->RemoveTaskObserver(&task_observer); | 57 MessageLoop::current()->RemoveTaskObserver(&task_observer); |
| 59 if (!task_observer.posted()) | 58 if (!task_observer.posted()) |
| 60 break; | 59 break; |
| 61 } | 60 } |
| 62 } | 61 } |
| 63 | 62 |
|
satorux1
2012/09/16 15:46:33
ditto
nhiroki
2012/09/16 16:42:02
Done.
| |
| 64 | |
| 65 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { | 63 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path) { |
| 66 FilePath path = GetTestFilePath(relative_path); | 64 FilePath path = GetTestFilePath(relative_path); |
| 67 | 65 |
| 68 std::string error; | 66 std::string error; |
| 69 JSONFileValueSerializer serializer(path); | 67 JSONFileValueSerializer serializer(path); |
| 70 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); | 68 scoped_ptr<base::Value> value(serializer.Deserialize(NULL, &error)); |
| 71 EXPECT_TRUE(value.get()) << | 69 EXPECT_TRUE(value.get()) << |
| 72 "Parse error " << path.value() << ": " << error; | 70 "Parse error " << path.value() << ": " << error; |
| 73 return value.Pass(); | 71 return value.Pass(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 } // namespace test_util | 74 } // namespace test_util |
| 77 } // namespace gdata | 75 } // namespace gdata |
| OLD | NEW |