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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 EXPECT_TRUE(found) | 972 EXPECT_TRUE(found) |
973 << "Error \"" << cur_reason.name << "\" not found in historical list." | 973 << "Error \"" << cur_reason.name << "\" not found in historical list." |
974 << std::endl | 974 << std::endl |
975 << "Please add it."; | 975 << "Please add it."; |
976 } | 976 } |
977 } | 977 } |
978 | 978 |
979 class HistoryTest : public testing::Test { | 979 class HistoryTest : public testing::Test { |
980 public: | 980 public: |
981 HistoryTest() | 981 HistoryTest() : query_url_success_(false) { |
982 : got_thumbnail_callback_(false), | |
983 query_url_success_(false) { | |
984 } | 982 } |
985 | 983 |
986 ~HistoryTest() override {} | 984 ~HistoryTest() override {} |
987 | 985 |
988 void OnMostVisitedURLsAvailable(const MostVisitedURLList* url_list) { | 986 void OnMostVisitedURLsAvailable(const MostVisitedURLList* url_list) { |
989 most_visited_urls_ = *url_list; | 987 most_visited_urls_ = *url_list; |
990 base::MessageLoop::current()->Quit(); | 988 base::MessageLoop::current()->Quit(); |
991 } | 989 } |
992 | 990 |
993 protected: | 991 protected: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 MostVisitedURLList most_visited_urls_; | 1086 MostVisitedURLList most_visited_urls_; |
1089 | 1087 |
1090 // When non-NULL, this will be deleted on tear down and we will block until | 1088 // When non-NULL, this will be deleted on tear down and we will block until |
1091 // the backend thread has completed. This allows tests for the history | 1089 // the backend thread has completed. This allows tests for the history |
1092 // service to use this feature, but other tests to ignore this. | 1090 // service to use this feature, but other tests to ignore this. |
1093 scoped_ptr<history::HistoryService> history_service_; | 1091 scoped_ptr<history::HistoryService> history_service_; |
1094 | 1092 |
1095 // names of the database files | 1093 // names of the database files |
1096 base::FilePath history_dir_; | 1094 base::FilePath history_dir_; |
1097 | 1095 |
1098 // Set by the thumbnail callback when we get data, you should be sure to | |
1099 // clear this before issuing a thumbnail request. | |
1100 bool got_thumbnail_callback_; | |
1101 std::vector<unsigned char> thumbnail_data_; | |
1102 | |
1103 // Set by the redirect callback when we get data. You should be sure to | 1096 // Set by the redirect callback when we get data. You should be sure to |
1104 // clear this before issuing a redirect request. | 1097 // clear this before issuing a redirect request. |
1105 history::RedirectList saved_redirects_; | 1098 history::RedirectList saved_redirects_; |
1106 | 1099 |
1107 // For history requests. | 1100 // For history requests. |
1108 base::CancelableTaskTracker tracker_; | 1101 base::CancelableTaskTracker tracker_; |
1109 | 1102 |
1110 // For saving URL info after a call to QueryURL | 1103 // For saving URL info after a call to QueryURL |
1111 bool query_url_success_; | 1104 bool query_url_success_; |
1112 URLRow query_url_row_; | 1105 URLRow query_url_row_; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 std::vector<PageUsageData*> results; | 1858 std::vector<PageUsageData*> results; |
1866 db_->QuerySegmentUsage(segment_time, 10, &results); | 1859 db_->QuerySegmentUsage(segment_time, 10, &results); |
1867 ASSERT_EQ(1u, results.size()); | 1860 ASSERT_EQ(1u, results.size()); |
1868 EXPECT_EQ(url, results[0]->GetURL()); | 1861 EXPECT_EQ(url, results[0]->GetURL()); |
1869 EXPECT_EQ(segment_id, results[0]->GetID()); | 1862 EXPECT_EQ(segment_id, results[0]->GetID()); |
1870 EXPECT_EQ(title, results[0]->GetTitle()); | 1863 EXPECT_EQ(title, results[0]->GetTitle()); |
1871 STLDeleteElements(&results); | 1864 STLDeleteElements(&results); |
1872 } | 1865 } |
1873 | 1866 |
1874 } // namespace history | 1867 } // namespace history |
OLD | NEW |