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

Side by Side Diff: chrome/browser/profiles/profile_statistics_unittest.cc

Issue 2915053002: Replace profile statistics preference count with AutofillCounter (Closed)
Patch Set: change to SetBooleanWithoutPathExpansion Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/profiles/profile_statistics.h" 5 #include "chrome/browser/profiles/profile_statistics.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 TestingProfileManager* manager() { return &manager_; } 90 TestingProfileManager* manager() { return &manager_; }
91 91
92 private: 92 private:
93 content::TestBrowserThreadBundle thread_bundle_; 93 content::TestBrowserThreadBundle thread_bundle_;
94 TestingProfileManager manager_; 94 TestingProfileManager manager_;
95 }; 95 };
96 96
97 TEST_F(ProfileStatisticsTest, WaitOrCountBookmarks) { 97 TEST_F(ProfileStatisticsTest, WaitOrCountBookmarks) {
98 TestingProfile* profile = manager()->CreateTestingProfile("Test 1"); 98 TestingProfile* profile = manager()->CreateTestingProfile("Test 1");
99 ASSERT_TRUE(profile); 99 ASSERT_TRUE(profile);
100 // We need a history service and a password store for the test to succeed. 100 // We need history, autofill and password services for the test to succeed.
101 ASSERT_TRUE(profile->CreateHistoryService(true, false)); 101 ASSERT_TRUE(profile->CreateHistoryService(true, false));
102 profile->CreateWebDataService();
102 PasswordStoreFactory::GetInstance()->SetTestingFactory( 103 PasswordStoreFactory::GetInstance()->SetTestingFactory(
103 profile, 104 profile,
104 password_manager::BuildPasswordStore< 105 password_manager::BuildPasswordStore<
105 content::BrowserContext, password_manager::TestPasswordStore>); 106 content::BrowserContext, password_manager::TestPasswordStore>);
106 107
107 bookmarks::BookmarkModel* bookmark_model = 108 bookmarks::BookmarkModel* bookmark_model =
108 CreateBookmarkModelWithoutLoad(profile); 109 CreateBookmarkModelWithoutLoad(profile);
109 ASSERT_TRUE(bookmark_model); 110 ASSERT_TRUE(bookmark_model);
110 111
111 // Run ProfileStatisticsAggregator::WaitOrCountBookmarks. 112 // Run ProfileStatisticsAggregator::WaitOrCountBookmarks.
112 BookmarkStatHelper bookmark_stat_helper; 113 BookmarkStatHelper bookmark_stat_helper;
113 base::RunLoop run_loop_aggregator_done; 114 base::RunLoop run_loop_aggregator_done;
114 115
115 scoped_refptr<ProfileStatisticsAggregator> aggregator = 116 ProfileStatisticsAggregator aggregator(
116 new ProfileStatisticsAggregator(profile, 117 profile, run_loop_aggregator_done.QuitClosure());
117 run_loop_aggregator_done.QuitClosure()); 118 aggregator.AddCallbackAndStartAggregator(
118 aggregator->AddCallbackAndStartAggregator(
119 base::Bind(&BookmarkStatHelper::StatsCallback, 119 base::Bind(&BookmarkStatHelper::StatsCallback,
120 base::Unretained(&bookmark_stat_helper))); 120 base::Unretained(&bookmark_stat_helper)));
121 121
122 // Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run. 122 // Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run.
123 base::RunLoop run_loop1; 123 base::RunLoop run_loop1;
124 run_loop1.RunUntilIdle(); 124 run_loop1.RunUntilIdle();
125 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled()); 125 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled());
126 126
127 // Run ProfileStatisticsAggregator::WaitOrCountBookmarks again. 127 // Run ProfileStatisticsAggregator::WaitOrCountBookmarks again.
128 aggregator->AddCallbackAndStartAggregator( 128 aggregator.AddCallbackAndStartAggregator(
129 profiles::ProfileStatisticsCallback()); 129 profiles::ProfileStatisticsCallback());
130 // Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run. 130 // Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run.
131 base::RunLoop run_loop2; 131 base::RunLoop run_loop2;
132 run_loop2.RunUntilIdle(); 132 run_loop2.RunUntilIdle();
133 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled()); 133 EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled());
134 134
135 // Load the bookmark model. When the model is loaded (asynchronously), the 135 // Load the bookmark model. When the model is loaded (asynchronously), the
136 // observer added by WaitOrCountBookmarks is run. 136 // observer added by WaitOrCountBookmarks is run.
137 LoadBookmarkModel(profile, bookmark_model); 137 LoadBookmarkModel(profile, bookmark_model);
138 138
139 run_loop_aggregator_done.Run(); 139 run_loop_aggregator_done.Run();
140 EXPECT_EQ(1, bookmark_stat_helper.GetNumOfTimesCalled()); 140 EXPECT_EQ(1, bookmark_stat_helper.GetNumOfTimesCalled());
141 } 141 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_statistics_common.cc ('k') | chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698