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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
6 // | 6 // |
7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 class HistoryTest : public testing::Test { | 976 class HistoryTest : public testing::Test { |
977 public: | 977 public: |
978 HistoryTest() | 978 HistoryTest() |
979 : got_thumbnail_callback_(false), | 979 : got_thumbnail_callback_(false), |
980 query_url_success_(false) { | 980 query_url_success_(false) { |
981 } | 981 } |
982 | 982 |
983 virtual ~HistoryTest() { | 983 virtual ~HistoryTest() { |
984 } | 984 } |
985 | 985 |
986 void OnDeleteURLsDone(CancelableRequestProvider::Handle handle) { | |
987 base::MessageLoop::current()->Quit(); | |
988 } | |
989 | |
990 void OnMostVisitedURLsAvailable(const MostVisitedURLList* url_list) { | 986 void OnMostVisitedURLsAvailable(const MostVisitedURLList* url_list) { |
991 most_visited_urls_ = *url_list; | 987 most_visited_urls_ = *url_list; |
992 base::MessageLoop::current()->Quit(); | 988 base::MessageLoop::current()->Quit(); |
993 } | 989 } |
994 | 990 |
995 protected: | 991 protected: |
996 friend class BackendDelegate; | 992 friend class BackendDelegate; |
997 | 993 |
998 // testing::Test | 994 // testing::Test |
999 virtual void SetUp() { | 995 virtual void SetUp() { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 // clear this before issuing a thumbnail request. | 1096 // clear this before issuing a thumbnail request. |
1101 bool got_thumbnail_callback_; | 1097 bool got_thumbnail_callback_; |
1102 std::vector<unsigned char> thumbnail_data_; | 1098 std::vector<unsigned char> thumbnail_data_; |
1103 | 1099 |
1104 // Set by the redirect callback when we get data. You should be sure to | 1100 // Set by the redirect callback when we get data. You should be sure to |
1105 // clear this before issuing a redirect request. | 1101 // clear this before issuing a redirect request. |
1106 history::RedirectList saved_redirects_; | 1102 history::RedirectList saved_redirects_; |
1107 | 1103 |
1108 // For history requests. | 1104 // For history requests. |
1109 base::CancelableTaskTracker tracker_; | 1105 base::CancelableTaskTracker tracker_; |
1110 CancelableRequestConsumer consumer_; | |
1111 | 1106 |
1112 // For saving URL info after a call to QueryURL | 1107 // For saving URL info after a call to QueryURL |
1113 bool query_url_success_; | 1108 bool query_url_success_; |
1114 URLRow query_url_row_; | 1109 URLRow query_url_row_; |
1115 VisitVector query_url_visits_; | 1110 VisitVector query_url_visits_; |
1116 }; | 1111 }; |
1117 | 1112 |
1118 TEST_F(HistoryTest, AddPage) { | 1113 TEST_F(HistoryTest, AddPage) { |
1119 ASSERT_TRUE(history_service_.get()); | 1114 ASSERT_TRUE(history_service_.get()); |
1120 // Add the page once from a child frame. | 1115 // Add the page once from a child frame. |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 std::vector<PageUsageData*> results; | 1854 std::vector<PageUsageData*> results; |
1860 db_->QuerySegmentUsage(segment_time, 10, &results); | 1855 db_->QuerySegmentUsage(segment_time, 10, &results); |
1861 ASSERT_EQ(1u, results.size()); | 1856 ASSERT_EQ(1u, results.size()); |
1862 EXPECT_EQ(url, results[0]->GetURL()); | 1857 EXPECT_EQ(url, results[0]->GetURL()); |
1863 EXPECT_EQ(segment_id, results[0]->GetID()); | 1858 EXPECT_EQ(segment_id, results[0]->GetID()); |
1864 EXPECT_EQ(title, results[0]->GetTitle()); | 1859 EXPECT_EQ(title, results[0]->GetTitle()); |
1865 STLDeleteElements(&results); | 1860 STLDeleteElements(&results); |
1866 } | 1861 } |
1867 | 1862 |
1868 } // namespace history | 1863 } // namespace history |
OLD | NEW |