| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/history/text_database_manager.h" | 9 #include "chrome/browser/history/text_database_manager.h" |
| 10 #include "chrome/browser/history/visit_database.h" | 10 #include "chrome/browser/history/visit_database.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // Put the visits in two different months so it will query across databases. | 70 // Put the visits in two different months so it will query across databases. |
| 71 exploded.year = 2008; | 71 exploded.year = 2008; |
| 72 exploded.month = 1; | 72 exploded.month = 1; |
| 73 exploded.day_of_month = 3; | 73 exploded.day_of_month = 3; |
| 74 | 74 |
| 75 VisitRow visit_row; | 75 VisitRow visit_row; |
| 76 visit_row.url_id = 1; | 76 visit_row.url_id = 1; |
| 77 visit_row.visit_time = Time::FromUTCExploded(exploded); | 77 visit_row.visit_time = Time::FromUTCExploded(exploded); |
| 78 visit_row.referring_visit = 0; | 78 visit_row.referring_visit = 0; |
| 79 visit_row.transition = 0; | 79 visit_row.transition = content::PageTransitionFromInt(0); |
| 80 visit_row.segment_id = 0; | 80 visit_row.segment_id = 0; |
| 81 visit_row.is_indexed = false; | 81 visit_row.is_indexed = false; |
| 82 visit_db->AddVisit(&visit_row, SOURCE_BROWSED); | 82 visit_db->AddVisit(&visit_row, SOURCE_BROWSED); |
| 83 | 83 |
| 84 times->push_back(visit_row.visit_time); | 84 times->push_back(visit_row.visit_time); |
| 85 manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id, | 85 manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id, |
| 86 visit_row.visit_time, UTF8ToUTF16(kTitle1), | 86 visit_row.visit_time, UTF8ToUTF16(kTitle1), |
| 87 UTF8ToUTF16(kBody1)); | 87 UTF8ToUTF16(kBody1)); |
| 88 | 88 |
| 89 exploded.day_of_month++; | 89 exploded.day_of_month++; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 InMemDB visit_db; | 232 InMemDB visit_db; |
| 233 TextDatabaseManager manager(dir_, &visit_db, &visit_db); | 233 TextDatabaseManager manager(dir_, &visit_db, &visit_db); |
| 234 ASSERT_TRUE(manager.Init(NULL)); | 234 ASSERT_TRUE(manager.Init(NULL)); |
| 235 | 235 |
| 236 // First add a visit to a page. We can just make up a URL ID since there is | 236 // First add a visit to a page. We can just make up a URL ID since there is |
| 237 // not actually any URL database around. | 237 // not actually any URL database around. |
| 238 VisitRow visit; | 238 VisitRow visit; |
| 239 visit.url_id = 1; | 239 visit.url_id = 1; |
| 240 visit.visit_time = Time::Now(); | 240 visit.visit_time = Time::Now(); |
| 241 visit.referring_visit = 0; | 241 visit.referring_visit = 0; |
| 242 visit.transition = PageTransition::LINK; | 242 visit.transition = content::PAGE_TRANSITION_LINK; |
| 243 visit.segment_id = 0; | 243 visit.segment_id = 0; |
| 244 visit.is_indexed = false; | 244 visit.is_indexed = false; |
| 245 visit_db.AddVisit(&visit, SOURCE_BROWSED); | 245 visit_db.AddVisit(&visit, SOURCE_BROWSED); |
| 246 | 246 |
| 247 // Add a full text indexed entry for that visit. | 247 // Add a full text indexed entry for that visit. |
| 248 const GURL url(kURL2); | 248 const GURL url(kURL2); |
| 249 manager.AddPageURL(url, visit.url_id, visit.visit_id, visit.visit_time); | 249 manager.AddPageURL(url, visit.url_id, visit.visit_id, visit.visit_time); |
| 250 manager.AddPageContents(url, UTF8ToUTF16(kBody2)); | 250 manager.AddPageContents(url, UTF8ToUTF16(kBody2)); |
| 251 manager.AddPageTitle(url, UTF8ToUTF16(kTitle2)); | 251 manager.AddPageTitle(url, UTF8ToUTF16(kTitle2)); |
| 252 | 252 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); | 528 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); |
| 529 EXPECT_TRUE(ResultsHaveURL(results, kURL1)); | 529 EXPECT_TRUE(ResultsHaveURL(results, kURL1)); |
| 530 | 530 |
| 531 // Try to query some more, there should be no results. | 531 // Try to query some more, there should be no results. |
| 532 options.end_time = first_time_searched; | 532 options.end_time = first_time_searched; |
| 533 manager.GetTextMatches(foo, options, &results, &first_time_searched); | 533 manager.GetTextMatches(foo, options, &results, &first_time_searched); |
| 534 EXPECT_EQ(0U, results.size()); | 534 EXPECT_EQ(0U, results.size()); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } // namespace history | 537 } // namespace history |
| OLD | NEW |