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

Side by Side Diff: chrome/renderer/net/net_error_helper_core_unittest.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/uma_histogram_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/net/net_error_helper_core.h" 5 #include "chrome/renderer/net/net_error_helper_core.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/statistics_recorder.h" 14 #include "base/metrics/statistics_recorder.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/test/histogram_tester.h"
16 #include "base/timer/mock_timer.h" 17 #include "base/timer/mock_timer.h"
17 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "chrome/common/net/net_error_info.h" 20 #include "chrome/common/net/net_error_info.h"
20 #include "chrome/test/base/uma_histogram_helper.h"
21 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/WebKit/public/platform/WebURLError.h" 24 #include "third_party/WebKit/public/platform/WebURLError.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 namespace { 27 namespace {
28 28
29 using blink::WebURLError; 29 using blink::WebURLError;
30 using chrome_common_net::DnsProbeStatus; 30 using chrome_common_net::DnsProbeStatus;
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 } 2223 }
2224 2224
2225 TEST_F(NetErrorHelperCoreAutoReloadTest, ShownWhileNotReloading) { 2225 TEST_F(NetErrorHelperCoreAutoReloadTest, ShownWhileNotReloading) {
2226 SetUpCore(true, true, false); 2226 SetUpCore(true, true, false);
2227 DoErrorLoad(net::ERR_CONNECTION_RESET); 2227 DoErrorLoad(net::ERR_CONNECTION_RESET);
2228 EXPECT_FALSE(timer()->IsRunning()); 2228 EXPECT_FALSE(timer()->IsRunning());
2229 core()->OnWasShown(); 2229 core()->OnWasShown();
2230 EXPECT_TRUE(timer()->IsRunning()); 2230 EXPECT_TRUE(timer()->IsRunning());
2231 } 2231 }
2232 2232
2233 // Return the count for the named histogram, or 0 if there is no histogram by
2234 // that name. This function is error-tolerant because histograms that have no
2235 // data points may not be registered, and the unit tests below still need to be
2236 // able to check that they haven't changed.
2237 int GetHistogramCount(const char *name) {
2238 base::HistogramBase* histogram =
2239 base::StatisticsRecorder::FindHistogram(name);
2240 if (!histogram)
2241 return 0;
2242 scoped_ptr<base::HistogramSamples> samples = histogram->SnapshotSamples();
2243 if (!samples)
2244 return 0;
2245 return samples->TotalCount();
2246 }
2247
2248 void ExpectHistogramDelta(const char *name, int old_count, int delta) {
2249 int new_count = GetHistogramCount(name);
2250 EXPECT_EQ(old_count + delta, new_count) << "For histogram " << name;
2251 }
2252
2253 class NetErrorHelperCoreHistogramTest 2233 class NetErrorHelperCoreHistogramTest
2254 : public NetErrorHelperCoreAutoReloadTest { 2234 : public NetErrorHelperCoreAutoReloadTest {
2255 public: 2235 public:
2256 virtual void SetUp() OVERRIDE { 2236 virtual void SetUp() OVERRIDE {
2257 NetErrorHelperCoreAutoReloadTest::SetUp(); 2237 NetErrorHelperCoreAutoReloadTest::SetUp();
2258 StoreOldCounts();
2259 }
2260
2261 void ExpectDelta(const char *name, int delta) {
2262 DCHECK(old_counts_.count(name) == 1);
2263 ExpectHistogramDelta(name, old_counts_[name], delta);
2264 } 2238 }
2265 2239
2266 static const char kCountAtStop[]; 2240 static const char kCountAtStop[];
2267 static const char kErrorAtStop[]; 2241 static const char kErrorAtStop[];
2268 static const char kCountAtSuccess[]; 2242 static const char kCountAtSuccess[];
2269 static const char kErrorAtSuccess[]; 2243 static const char kErrorAtSuccess[];
2270 static const char kErrorAtFirstSuccess[]; 2244 static const char kErrorAtFirstSuccess[];
2271 2245
2272 private: 2246 protected:
2273 void StoreOldCounts() { 2247 base::HistogramTester histogram_tester_;
2274 for (size_t i = 0; kHistogramNames[i]; i++)
2275 old_counts_[kHistogramNames[i]] = GetHistogramCount(kHistogramNames[i]);
2276 }
2277
2278 static const char *kHistogramNames[];
2279
2280 std::map<std::string, int> old_counts_;
2281 }; 2248 };
2282 2249
2283 const char NetErrorHelperCoreHistogramTest::kCountAtStop[] = 2250 const char NetErrorHelperCoreHistogramTest::kCountAtStop[] =
2284 "Net.AutoReload.CountAtStop"; 2251 "Net.AutoReload.CountAtStop";
2285 const char NetErrorHelperCoreHistogramTest::kErrorAtStop[] = 2252 const char NetErrorHelperCoreHistogramTest::kErrorAtStop[] =
2286 "Net.AutoReload.ErrorAtStop"; 2253 "Net.AutoReload.ErrorAtStop";
2287 const char NetErrorHelperCoreHistogramTest::kCountAtSuccess[] = 2254 const char NetErrorHelperCoreHistogramTest::kCountAtSuccess[] =
2288 "Net.AutoReload.CountAtSuccess"; 2255 "Net.AutoReload.CountAtSuccess";
2289 const char NetErrorHelperCoreHistogramTest::kErrorAtSuccess[] = 2256 const char NetErrorHelperCoreHistogramTest::kErrorAtSuccess[] =
2290 "Net.AutoReload.ErrorAtSuccess"; 2257 "Net.AutoReload.ErrorAtSuccess";
2291 const char NetErrorHelperCoreHistogramTest::kErrorAtFirstSuccess[] = 2258 const char NetErrorHelperCoreHistogramTest::kErrorAtFirstSuccess[] =
2292 "Net.AutoReload.ErrorAtFirstSuccess"; 2259 "Net.AutoReload.ErrorAtFirstSuccess";
2293 const char *NetErrorHelperCoreHistogramTest::kHistogramNames[] = {
2294 kCountAtStop,
2295 kErrorAtStop,
2296 kCountAtSuccess,
2297 kErrorAtSuccess,
2298 kErrorAtFirstSuccess,
2299 NULL
2300 };
2301 2260
2302 // Test that the success histograms are updated when auto-reload succeeds at the 2261 // Test that the success histograms are updated when auto-reload succeeds at the
2303 // first attempt, and that the failure histograms are not updated. 2262 // first attempt, and that the failure histograms are not updated.
2304 TEST_F(NetErrorHelperCoreHistogramTest, SuccessAtFirstAttempt) { 2263 TEST_F(NetErrorHelperCoreHistogramTest, SuccessAtFirstAttempt) {
2305 DoErrorLoad(net::ERR_CONNECTION_RESET); 2264 DoErrorLoad(net::ERR_CONNECTION_RESET);
2306 timer()->Fire(); 2265 timer()->Fire();
2307 DoSuccessLoad(); 2266 DoSuccessLoad();
2308 2267
2309 // All of CountAtSuccess, ErrorAtSuccess, and ErrorAtFirstSuccess should 2268 // All of CountAtSuccess, ErrorAtSuccess, and ErrorAtFirstSuccess should
2310 // reflect this successful load. The failure histograms should be unchanged. 2269 // reflect this successful load. The failure histograms should be unchanged.
2311 ExpectDelta(kCountAtSuccess, 1); 2270 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 1);
2312 ExpectDelta(kErrorAtSuccess, 1); 2271 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 1);
2313 ExpectDelta(kErrorAtFirstSuccess, 1); 2272 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 1);
2314 ExpectDelta(kCountAtStop, 0); 2273 histogram_tester_.ExpectTotalCount(kCountAtStop, 0);
2315 ExpectDelta(kErrorAtStop, 0); 2274 histogram_tester_.ExpectTotalCount(kErrorAtStop, 0);
2316 } 2275 }
2317 2276
2318 // Test that the success histograms are updated when auto-reload succeeds but 2277 // Test that the success histograms are updated when auto-reload succeeds but
2319 // not on the first attempt, and that the first-success histogram is not 2278 // not on the first attempt, and that the first-success histogram is not
2320 // updated. 2279 // updated.
2321 TEST_F(NetErrorHelperCoreHistogramTest, SuccessAtSecondAttempt) { 2280 TEST_F(NetErrorHelperCoreHistogramTest, SuccessAtSecondAttempt) {
2322 DoErrorLoad(net::ERR_CONNECTION_RESET); 2281 DoErrorLoad(net::ERR_CONNECTION_RESET);
2323 timer()->Fire(); 2282 timer()->Fire();
2324 EXPECT_TRUE(core()->ShouldSuppressErrorPage(NetErrorHelperCore::MAIN_FRAME, 2283 EXPECT_TRUE(core()->ShouldSuppressErrorPage(NetErrorHelperCore::MAIN_FRAME,
2325 default_url())); 2284 default_url()));
2326 // DoErrorLoad(net::ERR_CONNECTION_RESET); 2285 // DoErrorLoad(net::ERR_CONNECTION_RESET);
2327 timer()->Fire(); 2286 timer()->Fire();
2328 DoSuccessLoad(); 2287 DoSuccessLoad();
2329 2288
2330 // CountAtSuccess and ErrorAtSuccess should reflect this successful load, but 2289 // CountAtSuccess and ErrorAtSuccess should reflect this successful load, but
2331 // not ErrorAtFirstSuccess since it wasn't a first success. 2290 // not ErrorAtFirstSuccess since it wasn't a first success.
2332 ExpectDelta(kCountAtSuccess, 1); 2291 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 1);
2333 ExpectDelta(kErrorAtSuccess, 1); 2292 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 1);
2334 ExpectDelta(kErrorAtFirstSuccess, 0); 2293 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2335 ExpectDelta(kCountAtStop, 0); 2294 histogram_tester_.ExpectTotalCount(kCountAtStop, 0);
2336 ExpectDelta(kErrorAtStop, 0); 2295 histogram_tester_.ExpectTotalCount(kErrorAtStop, 0);
2337 } 2296 }
2338 2297
2339 // Test that a user stop (caused by the user pressing the 'Stop' button) 2298 // Test that a user stop (caused by the user pressing the 'Stop' button)
2340 // registers as an auto-reload failure if an auto-reload attempt is in flight. 2299 // registers as an auto-reload failure if an auto-reload attempt is in flight.
2341 // Note that "user stop" is also caused by a cross-process navigation, for which 2300 // Note that "user stop" is also caused by a cross-process navigation, for which
2342 // the browser process will send an OnStop to the old process. 2301 // the browser process will send an OnStop to the old process.
2343 TEST_F(NetErrorHelperCoreHistogramTest, UserStop) { 2302 TEST_F(NetErrorHelperCoreHistogramTest, UserStop) {
2344 DoErrorLoad(net::ERR_CONNECTION_RESET); 2303 DoErrorLoad(net::ERR_CONNECTION_RESET);
2345 timer()->Fire(); 2304 timer()->Fire();
2346 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2305 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2347 NetErrorHelperCore::NON_ERROR_PAGE); 2306 NetErrorHelperCore::NON_ERROR_PAGE);
2348 core()->OnStop(); 2307 core()->OnStop();
2349 2308
2350 // CountAtStop and ErrorAtStop should reflect the failure. 2309 // CountAtStop and ErrorAtStop should reflect the failure.
2351 ExpectDelta(kCountAtSuccess, 0); 2310 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 0);
2352 ExpectDelta(kErrorAtSuccess, 0); 2311 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 0);
2353 ExpectDelta(kErrorAtFirstSuccess, 0); 2312 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2354 ExpectDelta(kCountAtStop, 1); 2313 histogram_tester_.ExpectTotalCount(kCountAtStop, 1);
2355 ExpectDelta(kErrorAtStop, 1); 2314 histogram_tester_.ExpectTotalCount(kErrorAtStop, 1);
2356 } 2315 }
2357 2316
2358 // Test that a user stop (caused by the user pressing the 'Stop' button) 2317 // Test that a user stop (caused by the user pressing the 'Stop' button)
2359 // registers as an auto-reload failure even if an auto-reload attempt has not 2318 // registers as an auto-reload failure even if an auto-reload attempt has not
2360 // been launched yet (i.e., if the timer is running, but no reload is in 2319 // been launched yet (i.e., if the timer is running, but no reload is in
2361 // flight), because this means auto-reload didn't successfully replace the error 2320 // flight), because this means auto-reload didn't successfully replace the error
2362 // page. 2321 // page.
2363 TEST_F(NetErrorHelperCoreHistogramTest, OtherPageLoaded) { 2322 TEST_F(NetErrorHelperCoreHistogramTest, OtherPageLoaded) {
2364 DoErrorLoad(net::ERR_CONNECTION_RESET); 2323 DoErrorLoad(net::ERR_CONNECTION_RESET);
2365 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2324 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2366 NetErrorHelperCore::NON_ERROR_PAGE); 2325 NetErrorHelperCore::NON_ERROR_PAGE);
2367 core()->OnStop(); 2326 core()->OnStop();
2368 2327
2369 ExpectDelta(kCountAtSuccess, 0); 2328 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 0);
2370 ExpectDelta(kErrorAtSuccess, 0); 2329 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 0);
2371 ExpectDelta(kErrorAtFirstSuccess, 0); 2330 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2372 ExpectDelta(kCountAtStop, 1); 2331 histogram_tester_.ExpectTotalCount(kCountAtStop, 1);
2373 ExpectDelta(kErrorAtStop, 1); 2332 histogram_tester_.ExpectTotalCount(kErrorAtStop, 1);
2374 } 2333 }
2375 2334
2376 // Test that a commit of a different URL (caused by the user navigating to a 2335 // Test that a commit of a different URL (caused by the user navigating to a
2377 // different page) with an auto-reload attempt in flight registers as an 2336 // different page) with an auto-reload attempt in flight registers as an
2378 // auto-reload failure. 2337 // auto-reload failure.
2379 TEST_F(NetErrorHelperCoreHistogramTest, OtherPageLoadedAfterTimerFires) { 2338 TEST_F(NetErrorHelperCoreHistogramTest, OtherPageLoadedAfterTimerFires) {
2380 const GURL kTestUrl("https://anotherurl"); 2339 const GURL kTestUrl("https://anotherurl");
2381 DoErrorLoad(net::ERR_CONNECTION_RESET); 2340 DoErrorLoad(net::ERR_CONNECTION_RESET);
2382 timer()->Fire(); 2341 timer()->Fire();
2383 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2342 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2384 NetErrorHelperCore::NON_ERROR_PAGE); 2343 NetErrorHelperCore::NON_ERROR_PAGE);
2385 core()->OnCommitLoad(NetErrorHelperCore::MAIN_FRAME, 2344 core()->OnCommitLoad(NetErrorHelperCore::MAIN_FRAME,
2386 kTestUrl); 2345 kTestUrl);
2387 core()->OnFinishLoad(NetErrorHelperCore::MAIN_FRAME); 2346 core()->OnFinishLoad(NetErrorHelperCore::MAIN_FRAME);
2388 2347
2389 ExpectDelta(kCountAtSuccess, 0); 2348 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 0);
2390 ExpectDelta(kErrorAtSuccess, 0); 2349 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 0);
2391 ExpectDelta(kErrorAtFirstSuccess, 0); 2350 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2392 ExpectDelta(kCountAtStop, 1); 2351 histogram_tester_.ExpectTotalCount(kCountAtStop, 1);
2393 ExpectDelta(kErrorAtStop, 1); 2352 histogram_tester_.ExpectTotalCount(kErrorAtStop, 1);
2394 } 2353 }
2395 2354
2396 // Test that a commit of the same URL with an auto-reload attempt in flight 2355 // Test that a commit of the same URL with an auto-reload attempt in flight
2397 // registers as an auto-reload success. 2356 // registers as an auto-reload success.
2398 TEST_F(NetErrorHelperCoreHistogramTest, SamePageLoadedAfterTimerFires) { 2357 TEST_F(NetErrorHelperCoreHistogramTest, SamePageLoadedAfterTimerFires) {
2399 DoErrorLoad(net::ERR_CONNECTION_RESET); 2358 DoErrorLoad(net::ERR_CONNECTION_RESET);
2400 timer()->Fire(); 2359 timer()->Fire();
2401 DoSuccessLoad(); 2360 DoSuccessLoad();
2402 2361
2403 ExpectDelta(kCountAtSuccess, 1); 2362 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 1);
2404 ExpectDelta(kErrorAtSuccess, 1); 2363 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 1);
2405 ExpectDelta(kErrorAtFirstSuccess, 1); 2364 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 1);
2406 ExpectDelta(kCountAtStop, 0); 2365 histogram_tester_.ExpectTotalCount(kCountAtStop, 0);
2407 ExpectDelta(kErrorAtStop, 0); 2366 histogram_tester_.ExpectTotalCount(kErrorAtStop, 0);
2408 } 2367 }
2409 2368
2410 TEST_F(NetErrorHelperCoreHistogramTest, SamePageLoadedAfterLoadStarts) { 2369 TEST_F(NetErrorHelperCoreHistogramTest, SamePageLoadedAfterLoadStarts) {
2411 DoErrorLoad(net::ERR_CONNECTION_RESET); 2370 DoErrorLoad(net::ERR_CONNECTION_RESET);
2412 timer()->Fire(); 2371 timer()->Fire();
2413 // Autoreload attempt starts 2372 // Autoreload attempt starts
2414 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2373 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2415 NetErrorHelperCore::NON_ERROR_PAGE); 2374 NetErrorHelperCore::NON_ERROR_PAGE);
2416 // User does a manual reload 2375 // User does a manual reload
2417 DoSuccessLoad(); 2376 DoSuccessLoad();
2418 2377
2419 ExpectDelta(kCountAtSuccess, 1); 2378 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 1);
2420 ExpectDelta(kErrorAtSuccess, 1); 2379 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 1);
2421 ExpectDelta(kErrorAtFirstSuccess, 1); 2380 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 1);
2422 ExpectDelta(kCountAtStop, 0); 2381 histogram_tester_.ExpectTotalCount(kCountAtStop, 0);
2423 ExpectDelta(kErrorAtStop, 0); 2382 histogram_tester_.ExpectTotalCount(kErrorAtStop, 0);
2424 } 2383 }
2425 2384
2426 // In this test case, the user presses the reload button manually after an 2385 // In this test case, the user presses the reload button manually after an
2427 // auto-reload fails and the error page is suppressed. 2386 // auto-reload fails and the error page is suppressed.
2428 TEST_F(NetErrorHelperCoreHistogramTest, ErrorPageLoadedAfterTimerFires) { 2387 TEST_F(NetErrorHelperCoreHistogramTest, ErrorPageLoadedAfterTimerFires) {
2429 DoErrorLoad(net::ERR_CONNECTION_RESET); 2388 DoErrorLoad(net::ERR_CONNECTION_RESET);
2430 timer()->Fire(); 2389 timer()->Fire();
2431 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2390 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2432 NetErrorHelperCore::NON_ERROR_PAGE); 2391 NetErrorHelperCore::NON_ERROR_PAGE);
2433 EXPECT_TRUE(core()->ShouldSuppressErrorPage(NetErrorHelperCore::MAIN_FRAME, 2392 EXPECT_TRUE(core()->ShouldSuppressErrorPage(NetErrorHelperCore::MAIN_FRAME,
2434 default_url())); 2393 default_url()));
2435 DoErrorLoad(net::ERR_CONNECTION_RESET); 2394 DoErrorLoad(net::ERR_CONNECTION_RESET);
2436 2395
2437 ExpectDelta(kCountAtSuccess, 0); 2396 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 0);
2438 ExpectDelta(kErrorAtSuccess, 0); 2397 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 0);
2439 ExpectDelta(kErrorAtFirstSuccess, 0); 2398 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2440 ExpectDelta(kCountAtStop, 0); 2399 histogram_tester_.ExpectTotalCount(kCountAtStop, 0);
2441 ExpectDelta(kErrorAtStop, 0); 2400 histogram_tester_.ExpectTotalCount(kErrorAtStop, 0);
2442 } 2401 }
2443 2402
2444 TEST_F(NetErrorHelperCoreHistogramTest, SuccessPageLoadedBeforeTimerFires) { 2403 TEST_F(NetErrorHelperCoreHistogramTest, SuccessPageLoadedBeforeTimerFires) {
2445 DoErrorLoad(net::ERR_CONNECTION_RESET); 2404 DoErrorLoad(net::ERR_CONNECTION_RESET);
2446 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME, 2405 core()->OnStartLoad(NetErrorHelperCore::MAIN_FRAME,
2447 NetErrorHelperCore::NON_ERROR_PAGE); 2406 NetErrorHelperCore::NON_ERROR_PAGE);
2448 core()->OnCommitLoad(NetErrorHelperCore::MAIN_FRAME, 2407 core()->OnCommitLoad(NetErrorHelperCore::MAIN_FRAME,
2449 GURL(kFailedHttpsUrl)); 2408 GURL(kFailedHttpsUrl));
2450 2409
2451 ExpectDelta(kCountAtSuccess, 0); 2410 histogram_tester_.ExpectTotalCount(kCountAtSuccess, 0);
2452 ExpectDelta(kErrorAtSuccess, 0); 2411 histogram_tester_.ExpectTotalCount(kErrorAtSuccess, 0);
2453 ExpectDelta(kErrorAtFirstSuccess, 0); 2412 histogram_tester_.ExpectTotalCount(kErrorAtFirstSuccess, 0);
2454 ExpectDelta(kCountAtStop, 1); 2413 histogram_tester_.ExpectTotalCount(kCountAtStop, 1);
2455 ExpectDelta(kErrorAtStop, 1); 2414 histogram_tester_.ExpectTotalCount(kErrorAtStop, 1);
2456 } 2415 }
2457 2416
2458 2417
2459 TEST_F(NetErrorHelperCoreTest, ExplicitReloadSucceeds) { 2418 TEST_F(NetErrorHelperCoreTest, ExplicitReloadSucceeds) {
2460 DoErrorLoad(net::ERR_CONNECTION_RESET); 2419 DoErrorLoad(net::ERR_CONNECTION_RESET);
2461 EXPECT_EQ(0, reload_count()); 2420 EXPECT_EQ(0, reload_count());
2462 core()->ExecuteButtonPress(NetErrorHelperCore::RELOAD_BUTTON); 2421 core()->ExecuteButtonPress(NetErrorHelperCore::RELOAD_BUTTON);
2463 EXPECT_EQ(1, reload_count()); 2422 EXPECT_EQ(1, reload_count());
2464 } 2423 }
2465 2424
2466 TEST_F(NetErrorHelperCoreTest, ExplicitLoadStaleSucceeds) { 2425 TEST_F(NetErrorHelperCoreTest, ExplicitLoadStaleSucceeds) {
2467 DoErrorLoad(net::ERR_CONNECTION_RESET); 2426 DoErrorLoad(net::ERR_CONNECTION_RESET);
2468 EXPECT_EQ(0, load_stale_count()); 2427 EXPECT_EQ(0, load_stale_count());
2469 core()->ExecuteButtonPress(NetErrorHelperCore::LOAD_STALE_BUTTON); 2428 core()->ExecuteButtonPress(NetErrorHelperCore::LOAD_STALE_BUTTON);
2470 EXPECT_EQ(1, load_stale_count()); 2429 EXPECT_EQ(1, load_stale_count());
2471 EXPECT_EQ(GURL(kFailedUrl), load_stale_url()); 2430 EXPECT_EQ(GURL(kFailedUrl), load_stale_url());
2472 } 2431 }
2473 2432
2474 } // namespace 2433 } // namespace
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/base/uma_histogram_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698