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

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

Issue 1145513004: Record UMA when googlezip proxies are removed from the proxy config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment about bitwise ORs Created 5 years, 7 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/pref_proxy_config_tracker_impl.h" 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_registry_simple.h" 12 #include "base/prefs/pref_registry_simple.h"
13 #include "base/prefs/testing_pref_service.h" 13 #include "base/prefs/testing_pref_service.h"
14 #include "base/test/histogram_tester.h"
14 #include "chrome/browser/prefs/pref_service_mock_factory.h" 15 #include "chrome/browser/prefs/pref_service_mock_factory.h"
15 #include "chrome/browser/prefs/proxy_config_dictionary.h" 16 #include "chrome/browser/prefs/proxy_config_dictionary.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
19 #include "net/proxy/proxy_config_service_common_unittest.h" 20 #include "net/proxy/proxy_config_service_common_unittest.h"
20 #include "net/proxy/proxy_info.h" 21 #include "net/proxy/proxy_info.h"
21 #include "net/proxy/proxy_list.h" 22 #include "net/proxy/proxy_list.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 const std::string kDataReductionProxies = 310 const std::string kDataReductionProxies =
310 "https://proxy.googlezip.net:443,compress.googlezip.net," 311 "https://proxy.googlezip.net:443,compress.googlezip.net,"
311 "https://proxy-dev.googlezip.net:443,proxy-dev.googlezip.net," 312 "https://proxy-dev.googlezip.net:443,proxy-dev.googlezip.net,"
312 "quic://proxy.googlezip.net"; 313 "quic://proxy.googlezip.net";
313 314
314 struct { 315 struct {
315 std::string initial_proxy_rules; 316 std::string initial_proxy_rules;
316 const char* http_proxy_info; 317 const char* http_proxy_info;
317 const char* https_proxy_info; 318 const char* https_proxy_info;
318 const char* ftp_proxy_info; 319 const char* ftp_proxy_info;
320 PrefProxyConfigTrackerImpl::GooglezipProxyRemovalResult expected_result;
319 } test_cases[] = { 321 } test_cases[] = {
320 {"http=foopyhttp," + kDataReductionProxies + 322 {"http=foopyhttp," + kDataReductionProxies +
321 ",direct://;https=foopyhttps," + kDataReductionProxies + 323 ",direct://;https=foopyhttps," + kDataReductionProxies +
322 ",direct://;ftp=foopyftp," + kDataReductionProxies + ",direct://", 324 ",direct://;ftp=foopyftp," + kDataReductionProxies + ",direct://",
323 "foopyhttp;direct://", 325 "foopyhttp;direct://",
324 "foopyhttps;direct://", 326 "foopyhttps;direct://",
325 "foopyftp;direct://"}, 327 "foopyftp;direct://",
328 PrefProxyConfigTrackerImpl::
329 GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED},
326 330
327 {"foopy," + kDataReductionProxies + ",direct://", 331 {"foopy," + kDataReductionProxies + ",direct://",
328 "foopy;direct://", 332 "foopy;direct://",
329 "foopy;direct://", 333 "foopy;direct://",
330 "foopy;direct://"}, 334 "foopy;direct://",
335 PrefProxyConfigTrackerImpl::
336 GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED},
331 337
332 {"http=" + kDataReductionProxies + ";https=" + kDataReductionProxies + 338 {"http=" + kDataReductionProxies + ";https=" + kDataReductionProxies +
333 ";ftp=" + kDataReductionProxies, 339 ";ftp=" + kDataReductionProxies,
334 "direct://", 340 "direct://",
335 "direct://", 341 "direct://",
336 "direct://"}, 342 "direct://",
343 PrefProxyConfigTrackerImpl::
344 GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED},
337 345
338 {"http=" + kDataReductionProxies + ",foopy,direct://", 346 {"http=" + kDataReductionProxies + ",foopy,direct://",
339 "foopy;direct://", 347 "foopy;direct://",
340 "direct://", 348 "direct://",
341 "direct://"}, 349 "direct://",
350 PrefProxyConfigTrackerImpl::
351 GOOGLEZIP_PROXY_REMOVAL_RESULT_FOUND_AND_REMOVED},
352
353 {"foopy,direct://",
354 "foopy;direct://",
355 "foopy;direct://",
356 "foopy;direct://",
357 PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_NOT_FOUND},
358
359 {"direct://",
360 "direct://",
361 "direct://",
362 "direct://",
363 PrefProxyConfigTrackerImpl::GOOGLEZIP_PROXY_REMOVAL_RESULT_NOT_FOUND},
342 }; 364 };
343 365
344 // Test setting the proxy from a user pref. 366 // Test setting the proxy from a user pref.
345 for (const auto& test : test_cases) { 367 for (const auto& test : test_cases) {
368 base::HistogramTester histogram_tester;
346 pref_service_->SetUserPref(prefs::kProxy, 369 pref_service_->SetUserPref(prefs::kProxy,
347 ProxyConfigDictionary::CreateFixedServers( 370 ProxyConfigDictionary::CreateFixedServers(
348 test.initial_proxy_rules, std::string())); 371 test.initial_proxy_rules, std::string()));
349 loop_.RunUntilIdle(); 372 loop_.RunUntilIdle();
350 373
351 net::ProxyConfig config; 374 net::ProxyConfig config;
352 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, 375 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
353 proxy_config_service_->GetLatestProxyConfig(&config)); 376 proxy_config_service_->GetLatestProxyConfig(&config));
377 histogram_tester.ExpectUniqueSample(
eroman 2015/05/14 22:20:15 neat, thanks for adding the test!
sclittle 2015/05/15 02:29:42 Acknowledged.
378 "Net.PrefProxyConfig.GooglezipProxyRemovalResult", test.expected_result,
379 1);
354 380
355 CheckResolvedProxyMatches(&config, GURL("http://google.com"), 381 CheckResolvedProxyMatches(&config, GURL("http://google.com"),
356 test.http_proxy_info); 382 test.http_proxy_info);
357 CheckResolvedProxyMatches(&config, GURL("https://google.com"), 383 CheckResolvedProxyMatches(&config, GURL("https://google.com"),
358 test.https_proxy_info); 384 test.https_proxy_info);
359 CheckResolvedProxyMatches(&config, GURL("ftp://google.com"), 385 CheckResolvedProxyMatches(&config, GURL("ftp://google.com"),
360 test.ftp_proxy_info); 386 test.ftp_proxy_info);
361 } 387 }
362 } 388 }
363 389
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 net::ProxyRulesExpectation::Empty(), 573 net::ProxyRulesExpectation::Empty(),
548 }, 574 },
549 }; 575 };
550 576
551 INSTANTIATE_TEST_CASE_P( 577 INSTANTIATE_TEST_CASE_P(
552 PrefProxyConfigTrackerImplCommandLineTestInstance, 578 PrefProxyConfigTrackerImplCommandLineTestInstance,
553 PrefProxyConfigTrackerImplCommandLineTest, 579 PrefProxyConfigTrackerImplCommandLineTest,
554 testing::ValuesIn(kCommandLineTestParams)); 580 testing::ValuesIn(kCommandLineTestParams));
555 581
556 } // namespace 582 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698