Chromium Code Reviews| 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/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "components/bookmarks/test/bookmark_test_helpers.h" | 57 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 58 #include "components/browsing_data/core/browsing_data_utils.h" | 58 #include "components/browsing_data/core/browsing_data_utils.h" |
| 59 #include "components/content_settings/core/browser/host_content_settings_map.h" | 59 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 60 #include "components/content_settings/core/common/content_settings.h" | 60 #include "components/content_settings/core/common/content_settings.h" |
| 61 #include "components/content_settings/core/common/content_settings_pattern.h" | 61 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 62 #include "components/domain_reliability/clear_mode.h" | 62 #include "components/domain_reliability/clear_mode.h" |
| 63 #include "components/domain_reliability/monitor.h" | 63 #include "components/domain_reliability/monitor.h" |
| 64 #include "components/domain_reliability/service.h" | 64 #include "components/domain_reliability/service.h" |
| 65 #include "components/favicon/core/favicon_service.h" | 65 #include "components/favicon/core/favicon_service.h" |
| 66 #include "components/history/core/browser/history_service.h" | 66 #include "components/history/core/browser/history_service.h" |
| 67 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | |
| 67 #include "components/omnibox/browser/omnibox_pref_names.h" | 68 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 68 #include "components/os_crypt/os_crypt_mocker.h" | 69 #include "components/os_crypt/os_crypt_mocker.h" |
| 69 #include "components/password_manager/core/browser/mock_password_store.h" | 70 #include "components/password_manager/core/browser/mock_password_store.h" |
| 70 #include "components/password_manager/core/browser/password_manager_test_utils.h " | 71 #include "components/password_manager/core/browser/password_manager_test_utils.h " |
| 71 #include "components/password_manager/core/browser/password_store_consumer.h" | 72 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 72 #include "components/prefs/testing_pref_service.h" | 73 #include "components/prefs/testing_pref_service.h" |
| 73 #include "content/public/browser/browser_context.h" | 74 #include "content/public/browser/browser_context.h" |
| 74 #include "content/public/browser/cookie_store_factory.h" | 75 #include "content/public/browser/cookie_store_factory.h" |
| 75 #include "content/public/browser/dom_storage_context.h" | 76 #include "content/public/browser/dom_storage_context.h" |
| 76 #include "content/public/browser/local_storage_usage_info.h" | 77 #include "content/public/browser/local_storage_usage_info.h" |
| (...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3037 EXPECT_TRUE(remover->is_removing()); | 3038 EXPECT_TRUE(remover->is_removing()); |
| 3038 | 3039 |
| 3039 // Add one more deletion and wait for it. | 3040 // Add one more deletion and wait for it. |
| 3040 BlockUntilBrowsingDataRemoved( | 3041 BlockUntilBrowsingDataRemoved( |
| 3041 browsing_data::ALL_TIME, | 3042 browsing_data::ALL_TIME, |
| 3042 BrowsingDataRemover::REMOVE_COOKIES, | 3043 BrowsingDataRemover::REMOVE_COOKIES, |
| 3043 BrowsingDataHelper::UNPROTECTED_WEB); | 3044 BrowsingDataHelper::UNPROTECTED_WEB); |
| 3044 | 3045 |
| 3045 EXPECT_FALSE(remover->is_removing()); | 3046 EXPECT_FALSE(remover->is_removing()); |
| 3046 } | 3047 } |
| 3048 | |
| 3049 // Test that the remover clears bookmark meta data (normally added in a tab | |
| 3050 // helper). | |
| 3051 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { | |
| 3052 TestingProfile profile; | |
| 3053 profile.CreateBookmarkModel(true); | |
| 3054 | |
| 3055 bookmarks::BookmarkModel* bookmark_model = | |
| 3056 BookmarkModelFactory::GetForBrowserContext(&profile); | |
| 3057 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | |
| 3058 | |
| 3059 // Create a couple of bookmarks. | |
| 3060 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, | |
| 3061 base::string16(), | |
| 3062 GURL("http://foo.org/desktop")); | |
| 3063 bookmark_model->AddURL(bookmark_model->mobile_node(), 0, | |
| 3064 base::string16(), | |
| 3065 GURL("http://foo.org/mobile")); | |
| 3066 | |
| 3067 // Simulate their visits. | |
| 3068 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( | |
| 3069 bookmark_model, GURL("http://foo.org/desktop"), | |
| 3070 /*is_mobile_platform=*/false); | |
| 3071 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame( | |
| 3072 bookmark_model, GURL("http://foo.org/mobile"), | |
| 3073 /*is_mobile_platform=*/true); | |
| 3074 | |
| 3075 // There should be some recently visited bookmarks. | |
| 3076 EXPECT_FALSE(ntp_snippets::GetRecentlyVisitedBookmarks( | |
|
tschumann
2016/12/13 09:03:31
nit: using EXPECT_THAT() with gmock matchers, you
jkrcal
2016/12/13 10:21:15
Done.
Well, this 3K+ lines unittest file did not
msramek
2016/12/13 10:34:39
It's fine. I personally do find simple statements
| |
| 3077 bookmark_model, 2, base::Time::UnixEpoch(), | |
| 3078 /*consider_visits_from_desktop=*/false) | |
| 3079 .empty()); | |
| 3080 | |
| 3081 // Inject the bookmark model into the remover. | |
| 3082 BrowsingDataRemover* remover = | |
| 3083 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); | |
| 3084 remover->OverrideBookmarkModelForTesting(bookmark_model); | |
|
msramek
2016/12/13 09:27:36
You forgot this line, it's what makes the tests re
jkrcal
2016/12/13 10:21:15
Huh :) Sometimes CL-upload-without-local-compile h
| |
| 3085 | |
| 3086 BrowsingDataRemoverCompletionObserver completion_observer(remover); | |
| 3087 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | |
| 3088 BrowsingDataRemover::REMOVE_HISTORY, | |
| 3089 BrowsingDataHelper::ALL, &completion_observer); | |
| 3090 completion_observer.BlockUntilCompletion(); | |
| 3091 | |
| 3092 // There should be no recently visited bookmarks. | |
| 3093 EXPECT_TRUE(ntp_snippets::GetRecentlyVisitedBookmarks( | |
| 3094 bookmark_model, 2, base::Time::UnixEpoch(), | |
| 3095 /*consider_visits_from_desktop=*/false) | |
| 3096 .empty()); | |
| 3097 EXPECT_TRUE(ntp_snippets::GetRecentlyVisitedBookmarks( | |
| 3098 bookmark_model, 2, base::Time::UnixEpoch(), | |
| 3099 /*consider_visits_from_desktop=*/true) | |
| 3100 .empty()); | |
| 3101 } | |
| OLD | NEW |