| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/run_loop.h" |
| 7 #include "base/values.h" | 8 #include "base/values.h" |
| 8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "chrome/browser/extensions/api/top_sites/top_sites_api.h" | 10 #include "chrome/browser/extensions/api/top_sites/top_sites_api.h" |
| 10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 11 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 11 #include "chrome/browser/history/top_sites_factory.h" | 12 #include "chrome/browser/history/top_sites_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "components/history/core/browser/top_sites.h" | 16 #include "components/history/core/browser/top_sites.h" |
| 16 | 17 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 35 top_sites->GetPrepopulatedPages().size(); | 36 top_sites->GetPrepopulatedPages().size(); |
| 36 | 37 |
| 37 // This may return async or sync. If sync, top_sites_inited_ will be true | 38 // This may return async or sync. If sync, top_sites_inited_ will be true |
| 38 // before we get to the conditional below. Otherwise, we'll run a nested | 39 // before we get to the conditional below. Otherwise, we'll run a nested |
| 39 // message loop until the async callback. | 40 // message loop until the async callback. |
| 40 top_sites->GetMostVisitedURLs( | 41 top_sites->GetMostVisitedURLs( |
| 41 base::Bind(&TopSitesExtensionTest::OnTopSitesAvailable, this), false); | 42 base::Bind(&TopSitesExtensionTest::OnTopSitesAvailable, this), false); |
| 42 | 43 |
| 43 if (!top_sites_inited_) { | 44 if (!top_sites_inited_) { |
| 44 waiting_ = true; | 45 waiting_ = true; |
| 45 base::MessageLoop::current()->Run(); | 46 base::RunLoop().Run(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 // By this point, we know topsites has loaded. We can run the tests now. | 49 // By this point, we know topsites has loaded. We can run the tests now. |
| 49 } | 50 } |
| 50 | 51 |
| 51 size_t top_sites_prepopulated_pages_size() const { | 52 size_t top_sites_prepopulated_pages_size() const { |
| 52 return top_sites_prepopulated_pages_size_; | 53 return top_sites_prepopulated_pages_size_; |
| 53 } | 54 } |
| 54 | 55 |
| 55 private: | 56 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 get_top_sites_function->set_has_callback(true); | 76 get_top_sites_function->set_has_callback(true); |
| 76 | 77 |
| 77 std::unique_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 78 std::unique_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
| 78 get_top_sites_function.get(), "[]", browser())); | 79 get_top_sites_function.get(), "[]", browser())); |
| 79 base::ListValue* list; | 80 base::ListValue* list; |
| 80 ASSERT_TRUE(result->GetAsList(&list)); | 81 ASSERT_TRUE(result->GetAsList(&list)); |
| 81 EXPECT_GE(list->GetSize(), top_sites_prepopulated_pages_size()); | 82 EXPECT_GE(list->GetSize(), top_sites_prepopulated_pages_size()); |
| 82 } | 83 } |
| 83 | 84 |
| 84 } // namespace extensions | 85 } // namespace extensions |
| OLD | NEW |