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

Side by Side Diff: chrome/browser/net/predictor_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 <time.h> 5 #include <time.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 FROM_HERE, 131 FROM_HERE,
132 MessageLoop::QuitClosure(), 132 MessageLoop::QuitClosure(),
133 base::TimeDelta::FromMilliseconds(500)); 133 base::TimeDelta::FromMilliseconds(500));
134 MessageLoop::current()->Run(); 134 MessageLoop::current()->Run();
135 135
136 EXPECT_FALSE(testing_master.WasFound(localhost)); 136 EXPECT_FALSE(testing_master.WasFound(localhost));
137 137
138 testing_master.Shutdown(); 138 testing_master.Shutdown();
139 139
140 // Clean up after ourselves. 140 // Clean up after ourselves.
141 MessageLoop::current()->RunAllPending(); 141 MessageLoop::current()->RunUntilIdle();
142 } 142 }
143 143
144 TEST_F(PredictorTest, SingleLookupTest) { 144 TEST_F(PredictorTest, SingleLookupTest) {
145 Predictor testing_master(true); 145 Predictor testing_master(true);
146 testing_master.SetHostResolver(host_resolver_.get()); 146 testing_master.SetHostResolver(host_resolver_.get());
147 147
148 GURL goog("http://www.google.com:80"); 148 GURL goog("http://www.google.com:80");
149 149
150 UrlList names; 150 UrlList names;
151 names.push_back(goog); 151 names.push_back(goog);
152 152
153 // Try to flood the predictor with many concurrent requests. 153 // Try to flood the predictor with many concurrent requests.
154 for (int i = 0; i < 10; i++) 154 for (int i = 0; i < 10; i++)
155 testing_master.ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED); 155 testing_master.ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED);
156 156
157 WaitForResolution(&testing_master, names); 157 WaitForResolution(&testing_master, names);
158 158
159 EXPECT_TRUE(testing_master.WasFound(goog)); 159 EXPECT_TRUE(testing_master.WasFound(goog));
160 160
161 MessageLoop::current()->RunAllPending(); 161 MessageLoop::current()->RunUntilIdle();
162 162
163 EXPECT_GT(testing_master.peak_pending_lookups(), names.size() / 2); 163 EXPECT_GT(testing_master.peak_pending_lookups(), names.size() / 2);
164 EXPECT_LE(testing_master.peak_pending_lookups(), names.size()); 164 EXPECT_LE(testing_master.peak_pending_lookups(), names.size());
165 EXPECT_LE(testing_master.peak_pending_lookups(), 165 EXPECT_LE(testing_master.peak_pending_lookups(),
166 testing_master.max_concurrent_dns_lookups()); 166 testing_master.max_concurrent_dns_lookups());
167 167
168 testing_master.Shutdown(); 168 testing_master.Shutdown();
169 } 169 }
170 170
171 TEST_F(PredictorTest, ConcurrentLookupTest) { 171 TEST_F(PredictorTest, ConcurrentLookupTest) {
(...skipping 24 matching lines...) Expand all
196 196
197 WaitForResolution(&testing_master, names); 197 WaitForResolution(&testing_master, names);
198 198
199 EXPECT_TRUE(testing_master.WasFound(goog)); 199 EXPECT_TRUE(testing_master.WasFound(goog));
200 EXPECT_TRUE(testing_master.WasFound(goog3)); 200 EXPECT_TRUE(testing_master.WasFound(goog3));
201 EXPECT_TRUE(testing_master.WasFound(goog2)); 201 EXPECT_TRUE(testing_master.WasFound(goog2));
202 EXPECT_TRUE(testing_master.WasFound(goog4)); 202 EXPECT_TRUE(testing_master.WasFound(goog4));
203 EXPECT_FALSE(testing_master.WasFound(bad1)); 203 EXPECT_FALSE(testing_master.WasFound(bad1));
204 EXPECT_FALSE(testing_master.WasFound(bad2)); 204 EXPECT_FALSE(testing_master.WasFound(bad2));
205 205
206 MessageLoop::current()->RunAllPending(); 206 MessageLoop::current()->RunUntilIdle();
207 207
208 EXPECT_FALSE(testing_master.WasFound(bad1)); 208 EXPECT_FALSE(testing_master.WasFound(bad1));
209 EXPECT_FALSE(testing_master.WasFound(bad2)); 209 EXPECT_FALSE(testing_master.WasFound(bad2));
210 210
211 EXPECT_LE(testing_master.peak_pending_lookups(), names.size()); 211 EXPECT_LE(testing_master.peak_pending_lookups(), names.size());
212 EXPECT_LE(testing_master.peak_pending_lookups(), 212 EXPECT_LE(testing_master.peak_pending_lookups(),
213 testing_master.max_concurrent_dns_lookups()); 213 testing_master.max_concurrent_dns_lookups());
214 214
215 testing_master.Shutdown(); 215 testing_master.Shutdown();
216 } 216 }
217 217
218 TEST_F(PredictorTest, MassiveConcurrentLookupTest) { 218 TEST_F(PredictorTest, MassiveConcurrentLookupTest) {
219 host_resolver_->rules()->AddSimulatedFailure("*.notfound"); 219 host_resolver_->rules()->AddSimulatedFailure("*.notfound");
220 220
221 Predictor testing_master(true); 221 Predictor testing_master(true);
222 testing_master.SetHostResolver(host_resolver_.get()); 222 testing_master.SetHostResolver(host_resolver_.get());
223 223
224 UrlList names; 224 UrlList names;
225 for (int i = 0; i < 100; i++) 225 for (int i = 0; i < 100; i++)
226 names.push_back(GURL( 226 names.push_back(GURL(
227 "http://host" + base::IntToString(i) + ".notfound:80")); 227 "http://host" + base::IntToString(i) + ".notfound:80"));
228 228
229 // Try to flood the predictor with many concurrent requests. 229 // Try to flood the predictor with many concurrent requests.
230 for (int i = 0; i < 10; i++) 230 for (int i = 0; i < 10; i++)
231 testing_master.ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED); 231 testing_master.ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED);
232 232
233 WaitForResolution(&testing_master, names); 233 WaitForResolution(&testing_master, names);
234 234
235 MessageLoop::current()->RunAllPending(); 235 MessageLoop::current()->RunUntilIdle();
236 236
237 EXPECT_LE(testing_master.peak_pending_lookups(), names.size()); 237 EXPECT_LE(testing_master.peak_pending_lookups(), names.size());
238 EXPECT_LE(testing_master.peak_pending_lookups(), 238 EXPECT_LE(testing_master.peak_pending_lookups(),
239 testing_master.max_concurrent_dns_lookups()); 239 testing_master.max_concurrent_dns_lookups());
240 240
241 testing_master.Shutdown(); 241 testing_master.Shutdown();
242 } 242 }
243 243
244 //------------------------------------------------------------------------------ 244 //------------------------------------------------------------------------------
245 // Functions to help synthesize and test serializations of subresource referrer 245 // Functions to help synthesize and test serializations of subresource referrer
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 EXPECT_EQ(2U, referral_list.GetSize()); 675 EXPECT_EQ(2U, referral_list.GetSize());
676 676
677 predictor.DiscardAllResults(); 677 predictor.DiscardAllResults();
678 predictor.SerializeReferrers(&referral_list); 678 predictor.SerializeReferrers(&referral_list);
679 EXPECT_EQ(1U, referral_list.GetSize()); 679 EXPECT_EQ(1U, referral_list.GetSize());
680 680
681 predictor.Shutdown(); 681 predictor.Shutdown();
682 } 682 }
683 683
684 } // namespace chrome_browser_net 684 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/network_stats_unittest.cc ('k') | chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698