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

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

Issue 2649163003: [LanguageModel] Clear the model when clearing full history (Closed)
Patch Set: Martin's comments Created 3 years, 11 months 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chrome_browsing_data_remover_delegate.h" 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/autofill/personal_data_manager_factory.h" 11 #include "chrome/browser/autofill/personal_data_manager_factory.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" 13 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" 15 #include "chrome/browser/browsing_data/browsing_data_remover.h"
16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
17 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" 17 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h"
18 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 18 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
19 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 19 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
21 #include "chrome/browser/domain_reliability/service_factory.h" 21 #include "chrome/browser/domain_reliability/service_factory.h"
22 #include "chrome/browser/download/chrome_download_manager_delegate.h" 22 #include "chrome/browser/download/chrome_download_manager_delegate.h"
23 #include "chrome/browser/favicon/favicon_service_factory.h" 23 #include "chrome/browser/favicon/favicon_service_factory.h"
24 #include "chrome/browser/history/history_service_factory.h" 24 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/password_manager/password_store_factory.h" 25 #include "chrome/browser/password_manager/password_store_factory.h"
26 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" 26 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
28 #include "chrome/browser/storage/durable_storage_permission_context.h" 28 #include "chrome/browser/storage/durable_storage_permission_context.h"
29 #include "chrome/browser/translate/language_model_factory.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/test/base/testing_browser_process.h" 31 #include "chrome/test/base/testing_browser_process.h"
31 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
32 #include "components/autofill/core/browser/autofill_profile.h" 33 #include "components/autofill/core/browser/autofill_profile.h"
33 #include "components/autofill/core/browser/autofill_test_utils.h" 34 #include "components/autofill/core/browser/autofill_test_utils.h"
34 #include "components/autofill/core/browser/credit_card.h" 35 #include "components/autofill/core/browser/credit_card.h"
35 #include "components/autofill/core/browser/personal_data_manager.h" 36 #include "components/autofill/core/browser/personal_data_manager.h"
36 #include "components/autofill/core/browser/personal_data_manager_observer.h" 37 #include "components/autofill/core/browser/personal_data_manager_observer.h"
37 #include "components/autofill/core/common/autofill_constants.h" 38 #include "components/autofill/core/common/autofill_constants.h"
38 #include "components/bookmarks/browser/bookmark_model.h" 39 #include "components/bookmarks/browser/bookmark_model.h"
39 #include "components/bookmarks/test/bookmark_test_helpers.h" 40 #include "components/bookmarks/test/bookmark_test_helpers.h"
40 #include "components/browsing_data/core/browsing_data_utils.h" 41 #include "components/browsing_data/core/browsing_data_utils.h"
41 #include "components/content_settings/core/browser/host_content_settings_map.h" 42 #include "components/content_settings/core/browser/host_content_settings_map.h"
42 #include "components/content_settings/core/common/content_settings.h" 43 #include "components/content_settings/core/common/content_settings.h"
43 #include "components/content_settings/core/common/content_settings_pattern.h" 44 #include "components/content_settings/core/common/content_settings_pattern.h"
44 #include "components/domain_reliability/clear_mode.h" 45 #include "components/domain_reliability/clear_mode.h"
45 #include "components/domain_reliability/monitor.h" 46 #include "components/domain_reliability/monitor.h"
46 #include "components/domain_reliability/service.h" 47 #include "components/domain_reliability/service.h"
47 #include "components/favicon/core/favicon_service.h" 48 #include "components/favicon/core/favicon_service.h"
48 #include "components/history/core/browser/history_service.h" 49 #include "components/history/core/browser/history_service.h"
49 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" 50 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
50 #include "components/omnibox/browser/omnibox_pref_names.h" 51 #include "components/omnibox/browser/omnibox_pref_names.h"
51 #include "components/os_crypt/os_crypt_mocker.h" 52 #include "components/os_crypt/os_crypt_mocker.h"
52 #include "components/password_manager/core/browser/mock_password_store.h" 53 #include "components/password_manager/core/browser/mock_password_store.h"
53 #include "components/password_manager/core/browser/password_manager_test_utils.h " 54 #include "components/password_manager/core/browser/password_manager_test_utils.h "
54 #include "components/password_manager/core/browser/password_store_consumer.h" 55 #include "components/password_manager/core/browser/password_store_consumer.h"
55 #include "components/prefs/testing_pref_service.h" 56 #include "components/prefs/testing_pref_service.h"
57 #include "components/translate/core/browser/language_model.h"
56 #include "content/public/test/mock_download_manager.h" 58 #include "content/public/test/mock_download_manager.h"
57 #include "content/public/test/test_browser_thread_bundle.h" 59 #include "content/public/test/test_browser_thread_bundle.h"
58 #include "content/public/test/test_utils.h" 60 #include "content/public/test/test_utils.h"
59 #include "net/cookies/cookie_store.h" 61 #include "net/cookies/cookie_store.h"
60 #include "net/http/http_transaction_factory.h" 62 #include "net/http/http_transaction_factory.h"
61 #include "net/url_request/url_request_context.h" 63 #include "net/url_request/url_request_context.h"
62 #include "net/url_request/url_request_context_getter.h" 64 #include "net/url_request/url_request_context_getter.h"
63 #include "third_party/skia/include/core/SkBitmap.h" 65 #include "third_party/skia/include/core/SkBitmap.h"
64 #include "ui/gfx/favicon_size.h" 66 #include "ui/gfx/favicon_size.h"
65 67
(...skipping 17 matching lines...) Expand all
83 85
84 using domain_reliability::CLEAR_BEACONS; 86 using domain_reliability::CLEAR_BEACONS;
85 using domain_reliability::CLEAR_CONTEXTS; 87 using domain_reliability::CLEAR_CONTEXTS;
86 using domain_reliability::DomainReliabilityClearMode; 88 using domain_reliability::DomainReliabilityClearMode;
87 using domain_reliability::DomainReliabilityMonitor; 89 using domain_reliability::DomainReliabilityMonitor;
88 using domain_reliability::DomainReliabilityService; 90 using domain_reliability::DomainReliabilityService;
89 using domain_reliability::DomainReliabilityServiceFactory; 91 using domain_reliability::DomainReliabilityServiceFactory;
90 using testing::_; 92 using testing::_;
91 using testing::ByRef; 93 using testing::ByRef;
92 using testing::Eq; 94 using testing::Eq;
95 using testing::FloatEq;
93 using testing::Invoke; 96 using testing::Invoke;
94 using testing::IsEmpty; 97 using testing::IsEmpty;
95 using testing::Matcher; 98 using testing::Matcher;
96 using testing::MakeMatcher; 99 using testing::MakeMatcher;
97 using testing::MatcherInterface; 100 using testing::MatcherInterface;
98 using testing::MatchResultListener; 101 using testing::MatchResultListener;
99 using testing::Not; 102 using testing::Not;
100 using testing::Return; 103 using testing::Return;
101 using testing::SizeIs; 104 using testing::SizeIs;
102 using testing::WithArgs; 105 using testing::WithArgs;
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 completion_observer.BlockUntilCompletion(); 1738 completion_observer.BlockUntilCompletion();
1736 1739
1737 // There should be only 1 recently visited bookmarks. 1740 // There should be only 1 recently visited bookmarks.
1738 std::vector<const bookmarks::BookmarkNode*> remaining_nodes = 1741 std::vector<const bookmarks::BookmarkNode*> remaining_nodes =
1739 ntp_snippets::GetRecentlyVisitedBookmarks( 1742 ntp_snippets::GetRecentlyVisitedBookmarks(
1740 bookmark_model, 3, base::Time::UnixEpoch(), 1743 bookmark_model, 3, base::Time::UnixEpoch(),
1741 /*consider_visits_from_desktop=*/true); 1744 /*consider_visits_from_desktop=*/true);
1742 EXPECT_THAT(remaining_nodes, SizeIs(1)); 1745 EXPECT_THAT(remaining_nodes, SizeIs(1));
1743 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/")); 1746 EXPECT_THAT(remaining_nodes[0]->url().spec(), Eq("http://foo-2.org/"));
1744 } 1747 }
1748
1749 // Test that the remover clears language model data (normally added by the
1750 // ChromeTranslateClient).
1751 TEST_F(ChromeBrowsingDataRemoverDelegateTest,
1752 LanguageModelClearedOnClearingCompleteHistory) {
1753 translate::LanguageModel* language_model =
1754 LanguageModelFactory::GetInstance()->GetForBrowserContext(GetProfile());
1755
1756 // Simulate browsing.
1757 for (int i = 0; i < 100; i++) {
1758 language_model->OnPageVisited("en");
1759 language_model->OnPageVisited("en");
1760 language_model->OnPageVisited("en");
1761 language_model->OnPageVisited("es");
1762 }
1763
1764 // Clearing a part of the history has no effect.
1765 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(),
1766 BrowsingDataRemover::REMOVE_HISTORY, false);
1767
1768 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(2));
1769 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.75));
jkrcal 2017/01/25 08:48:54 Furthermore, I've changed the ratio of the languag
msramek 2017/01/25 11:54:59 Acknowledged.
1770 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.25));
1771
1772 // Clearing the full history does the trick.
1773 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
1774 BrowsingDataRemover::REMOVE_HISTORY, false);
1775
1776 EXPECT_THAT(language_model->GetTopLanguages(), SizeIs(0));
1777 EXPECT_THAT(language_model->GetLanguageFrequency("en"), FloatEq(0.0));
1778 EXPECT_THAT(language_model->GetLanguageFrequency("es"), FloatEq(0.0));
1779 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698