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 "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "chrome/browser/history/content_visit_delegate.h" |
24 #include "chrome/browser/history/history_service.h" | 25 #include "chrome/browser/history/history_service.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/history/in_memory_history_backend.h" | 27 #include "chrome/browser/history/in_memory_history_backend.h" |
27 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/importer/imported_favicon_usage.h" | 30 #include "chrome/common/importer/imported_favicon_usage.h" |
30 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
31 #include "components/history/core/browser/history_constants.h" | 32 #include "components/history/core/browser/history_constants.h" |
32 #include "components/history/core/browser/history_database_params.h" | 33 #include "components/history/core/browser/history_database_params.h" |
33 #include "components/history/core/browser/history_service_observer.h" | 34 #include "components/history/core/browser/history_service_observer.h" |
(...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3032 | 3033 |
3033 // Simple test that removes a bookmark. This test exercises the code paths in | 3034 // Simple test that removes a bookmark. This test exercises the code paths in |
3034 // History that block till bookmark bar model is loaded. | 3035 // History that block till bookmark bar model is loaded. |
3035 TEST_F(HistoryBackendTest, RemoveNotification) { | 3036 TEST_F(HistoryBackendTest, RemoveNotification) { |
3036 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 3037 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
3037 | 3038 |
3038 // Add a URL. | 3039 // Add a URL. |
3039 GURL url("http://www.google.com"); | 3040 GURL url("http://www.google.com"); |
3040 HistoryClientMock history_client; | 3041 HistoryClientMock history_client; |
3041 history_client.AddBookmark(url); | 3042 history_client.AddBookmark(url); |
3042 scoped_ptr<HistoryService> service( | 3043 scoped_ptr<HistoryService> service(new HistoryService( |
3043 new HistoryService(&history_client, profile.get())); | 3044 &history_client, scoped_ptr<history::VisitDelegate>())); |
3044 EXPECT_TRUE( | 3045 EXPECT_TRUE( |
3045 service->Init(profile->GetPrefs(), | 3046 service->Init(profile->GetPrefs(), |
3046 TestHistoryDatabaseParamsForPath(profile->GetPath()))); | 3047 TestHistoryDatabaseParamsForPath(profile->GetPath()))); |
3047 | 3048 |
3048 service->AddPage( | 3049 service->AddPage( |
3049 url, base::Time::Now(), NULL, 1, GURL(), RedirectList(), | 3050 url, base::Time::Now(), NULL, 1, GURL(), RedirectList(), |
3050 ui::PAGE_TRANSITION_TYPED, SOURCE_BROWSED, false); | 3051 ui::PAGE_TRANSITION_TYPED, SOURCE_BROWSED, false); |
3051 | 3052 |
3052 // This won't actually delete the URL, rather it'll empty out the visits. | 3053 // This won't actually delete the URL, rather it'll empty out the visits. |
3053 // This triggers blocking on the BookmarkModel. | 3054 // This triggers blocking on the BookmarkModel. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3287 // Verify that the second term is no longer returned as result, and also check | 3288 // Verify that the second term is no longer returned as result, and also check |
3288 // at the low level that it is gone for good. The term corresponding to the | 3289 // at the low level that it is gone for good. The term corresponding to the |
3289 // first URLRow should not be affected. | 3290 // first URLRow should not be affected. |
3290 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3291 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
3291 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3292 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
3292 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3293 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
3293 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3294 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
3294 } | 3295 } |
3295 | 3296 |
3296 } // namespace history | 3297 } // namespace history |
OLD | NEW |