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 "base/values.h" | 5 #include "base/values.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "chrome/browser/extensions/api/top_sites/top_sites_api.h" | 7 #include "chrome/browser/extensions/api/top_sites/top_sites_api.h" |
8 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
9 #include "chrome/browser/history/top_sites_factory.h" | 9 #include "chrome/browser/history/top_sites_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // By this point, we know topsites has loaded. We can run the tests now. | 46 // By this point, we know topsites has loaded. We can run the tests now. |
47 } | 47 } |
48 | 48 |
49 size_t top_sites_prepopulated_pages_size() const { | 49 size_t top_sites_prepopulated_pages_size() const { |
50 return top_sites_prepopulated_pages_size_; | 50 return top_sites_prepopulated_pages_size_; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 void OnTopSitesAvailable(const history::MostVisitedURLList& data) { | 54 void OnTopSitesAvailable(const history::MostVisitedURLList& data) { |
55 if (waiting_) { | 55 if (waiting_) { |
56 base::MessageLoop::current()->Quit(); | 56 base::MessageLoop::current()->QuitWhenIdle(); |
57 waiting_ = false; | 57 waiting_ = false; |
58 } | 58 } |
59 top_sites_inited_ = true; | 59 top_sites_inited_ = true; |
60 } | 60 } |
61 | 61 |
62 size_t top_sites_prepopulated_pages_size_; | 62 size_t top_sites_prepopulated_pages_size_; |
63 bool top_sites_inited_; | 63 bool top_sites_inited_; |
64 bool waiting_; | 64 bool waiting_; |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 IN_PROC_BROWSER_TEST_F(TopSitesExtensionTest, GetTopSites) { | 69 IN_PROC_BROWSER_TEST_F(TopSitesExtensionTest, GetTopSites) { |
70 scoped_refptr<TopSitesGetFunction> get_top_sites_function( | 70 scoped_refptr<TopSitesGetFunction> get_top_sites_function( |
71 new TopSitesGetFunction()); | 71 new TopSitesGetFunction()); |
72 // Without a callback the function will not generate a result. | 72 // Without a callback the function will not generate a result. |
73 get_top_sites_function->set_has_callback(true); | 73 get_top_sites_function->set_has_callback(true); |
74 | 74 |
75 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( | 75 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( |
76 get_top_sites_function.get(), "[]", browser())); | 76 get_top_sites_function.get(), "[]", browser())); |
77 base::ListValue* list; | 77 base::ListValue* list; |
78 ASSERT_TRUE(result->GetAsList(&list)); | 78 ASSERT_TRUE(result->GetAsList(&list)); |
79 EXPECT_GE(list->GetSize(), top_sites_prepopulated_pages_size()); | 79 EXPECT_GE(list->GetSize(), top_sites_prepopulated_pages_size()); |
80 } | 80 } |
81 | 81 |
82 } // namespace extensions | 82 } // namespace extensions |
OLD | NEW |