Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(977)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 2566123002: Last visit dates of bookmarks - fix browsing data removal on desktop (Closed)
Patch Set: Adding a unittest Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "chrome/test/base/testing_browser_process.h" 48 #include "chrome/test/base/testing_browser_process.h"
49 #include "chrome/test/base/testing_profile.h" 49 #include "chrome/test/base/testing_profile.h"
50 #include "components/autofill/core/browser/autofill_profile.h" 50 #include "components/autofill/core/browser/autofill_profile.h"
51 #include "components/autofill/core/browser/autofill_test_utils.h" 51 #include "components/autofill/core/browser/autofill_test_utils.h"
52 #include "components/autofill/core/browser/credit_card.h" 52 #include "components/autofill/core/browser/credit_card.h"
53 #include "components/autofill/core/browser/personal_data_manager.h" 53 #include "components/autofill/core/browser/personal_data_manager.h"
54 #include "components/autofill/core/browser/personal_data_manager_observer.h" 54 #include "components/autofill/core/browser/personal_data_manager_observer.h"
55 #include "components/autofill/core/common/autofill_constants.h" 55 #include "components/autofill/core/common/autofill_constants.h"
56 #include "components/bookmarks/browser/bookmark_model.h" 56 #include "components/bookmarks/browser/bookmark_model.h"
57 #include "components/bookmarks/test/bookmark_test_helpers.h" 57 #include "components/bookmarks/test/bookmark_test_helpers.h"
58 #include "components/bookmarks/test/test_bookmark_client.h"
58 #include "components/browsing_data/core/browsing_data_utils.h" 59 #include "components/browsing_data/core/browsing_data_utils.h"
59 #include "components/content_settings/core/browser/host_content_settings_map.h" 60 #include "components/content_settings/core/browser/host_content_settings_map.h"
60 #include "components/content_settings/core/common/content_settings.h" 61 #include "components/content_settings/core/common/content_settings.h"
61 #include "components/content_settings/core/common/content_settings_pattern.h" 62 #include "components/content_settings/core/common/content_settings_pattern.h"
62 #include "components/domain_reliability/clear_mode.h" 63 #include "components/domain_reliability/clear_mode.h"
63 #include "components/domain_reliability/monitor.h" 64 #include "components/domain_reliability/monitor.h"
64 #include "components/domain_reliability/service.h" 65 #include "components/domain_reliability/service.h"
65 #include "components/favicon/core/favicon_service.h" 66 #include "components/favicon/core/favicon_service.h"
66 #include "components/history/core/browser/history_service.h" 67 #include "components/history/core/browser/history_service.h"
68 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
67 #include "components/omnibox/browser/omnibox_pref_names.h" 69 #include "components/omnibox/browser/omnibox_pref_names.h"
68 #include "components/os_crypt/os_crypt_mocker.h" 70 #include "components/os_crypt/os_crypt_mocker.h"
69 #include "components/password_manager/core/browser/mock_password_store.h" 71 #include "components/password_manager/core/browser/mock_password_store.h"
70 #include "components/password_manager/core/browser/password_manager_test_utils.h " 72 #include "components/password_manager/core/browser/password_manager_test_utils.h "
71 #include "components/password_manager/core/browser/password_store_consumer.h" 73 #include "components/password_manager/core/browser/password_store_consumer.h"
72 #include "components/prefs/testing_pref_service.h" 74 #include "components/prefs/testing_pref_service.h"
73 #include "content/public/browser/browser_context.h" 75 #include "content/public/browser/browser_context.h"
74 #include "content/public/browser/cookie_store_factory.h" 76 #include "content/public/browser/cookie_store_factory.h"
75 #include "content/public/browser/dom_storage_context.h" 77 #include "content/public/browser/dom_storage_context.h"
76 #include "content/public/browser/local_storage_usage_info.h" 78 #include "content/public/browser/local_storage_usage_info.h"
(...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 EXPECT_TRUE(remover->is_removing()); 3039 EXPECT_TRUE(remover->is_removing());
3038 3040
3039 // Add one more deletion and wait for it. 3041 // Add one more deletion and wait for it.
3040 BlockUntilBrowsingDataRemoved( 3042 BlockUntilBrowsingDataRemoved(
3041 browsing_data::ALL_TIME, 3043 browsing_data::ALL_TIME,
3042 BrowsingDataRemover::REMOVE_COOKIES, 3044 BrowsingDataRemover::REMOVE_COOKIES,
3043 BrowsingDataHelper::UNPROTECTED_WEB); 3045 BrowsingDataHelper::UNPROTECTED_WEB);
3044 3046
3045 EXPECT_FALSE(remover->is_removing()); 3047 EXPECT_FALSE(remover->is_removing());
3046 } 3048 }
3049
3050 // Test that the remover clears bookmark meta data (normally added in a tab
3051 // helper).
3052 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) {
3053 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model =
3054 bookmarks::TestBookmarkClient::CreateModel();
3055
3056 // Create a couple of bookmarks.
3057 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0,
3058 base::string16(),
3059 GURL("http://foo.org/desktop"));
3060 bookmark_model->AddURL(bookmark_model->mobile_node(), 0,
3061 base::string16(),
3062 GURL("http://foo.org/mobile"));
3063
3064 // Simulate their visits.
3065 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(
3066 bookmark_model.get(), GURL("http://foo.org/desktop"),
3067 /*is_mobile_platform=*/false);
3068 ntp_snippets::UpdateBookmarkOnURLVisitedInMainFrame(
3069 bookmark_model.get(), GURL("http://foo.org/mobile"),
3070 /*is_mobile_platform=*/true);
3071
3072 // There should be some recently visited bookmarks.
3073 EXPECT_FALSE(ntp_snippets::GetRecentlyVisitedBookmarks(
3074 bookmark_model.get(), 2, base::Time::UnixEpoch(),
3075 /*consider_visits_from_desktop=*/false)
3076 .empty());
3077
3078 // Inject the bookmark model into the remover.
3079 BrowsingDataRemover* remover =
3080 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile());
3081 remover->OverrideBookmarkModelForTesting(bookmark_model.get());
3082
3083 BrowsingDataRemoverCompletionObserver completion_observer(remover);
3084 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(),
3085 BrowsingDataRemover::REMOVE_HISTORY,
3086 BrowsingDataHelper::ALL, &completion_observer);
3087 completion_observer.BlockUntilCompletion();
3088
3089 // There should be no recently visited bookmarks.
3090 EXPECT_TRUE(ntp_snippets::GetRecentlyVisitedBookmarks(
3091 bookmark_model.get(), 2, base::Time::UnixEpoch(),
3092 /*consider_visits_from_desktop=*/false)
3093 .empty());
3094 EXPECT_TRUE(ntp_snippets::GetRecentlyVisitedBookmarks(
3095 bookmark_model.get(), 2, base::Time::UnixEpoch(),
3096 /*consider_visits_from_desktop=*/true)
3097 .empty());
3098 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698