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

Side by Side Diff: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py

Issue 820093002: Integration tests for desktop platforms and safebrowsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 import datetime 5 import datetime
6 import logging 6 import logging
7 import os 7 import os
8 8
9 from integration_tests import network_metrics 9 from integration_tests import network_metrics
10 from telemetry.core import util 10 from telemetry.core import util
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 'Exactly one response should be bypassed. ' 413 'Exactly one response should be bypassed. '
414 '(eligible_response_count=%d, bypass_count=%d)\n' % ( 414 '(eligible_response_count=%d, bypass_count=%d)\n' % (
415 eligible_response_count, bypass_count)) 415 eligible_response_count, bypass_count))
416 else: 416 else:
417 results.AddValue(scalar.ScalarValue( 417 results.AddValue(scalar.ScalarValue(
418 results.current_page, 'eligible_responses', 'count', 418 results.current_page, 'eligible_responses', 'count',
419 eligible_response_count)) 419 eligible_response_count))
420 results.AddValue(scalar.ScalarValue( 420 results.AddValue(scalar.ScalarValue(
421 results.current_page, 'bypass', 'count', bypass_count)) 421 results.current_page, 'bypass', 'count', bypass_count))
422 422
423 def AddResultsForSafebrowsing(self, tab, results): 423 def AddResultsForSafebrowsingMobile(self, tab, results):
424 count = 0 424 count = 0
425 safebrowsing_count = 0 425 safebrowsing_count = 0
426 for resp in self.IterResponses(tab): 426 for resp in self.IterResponses(tab):
427 count += 1 427 count += 1
428 if resp.IsSafebrowsingResponse(): 428 if resp.IsSafebrowsingResponse():
429 safebrowsing_count += 1 429 safebrowsing_count += 1
430 else: 430 else:
431 r = resp.response 431 r = resp.response
432 raise ChromeProxyMetricException, ( 432 raise ChromeProxyMetricException, (
433 '%s: Not a valid safe browsing response.\n' 433 '%s: Not a valid safe browsing response.\n'
434 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( 434 'Reponse: status=(%d, %s)\nHeaders:\n %s' % (
435 r.url, r.status, r.status_text, r.headers)) 435 r.url, r.status, r.status_text, r.headers))
436 if count == safebrowsing_count: 436 if count == safebrowsing_count:
437 results.AddValue(scalar.ScalarValue( 437 results.AddValue(scalar.ScalarValue(
438 results.current_page, 'safebrowsing', 'boolean', True)) 438 results.current_page, 'safebrowsing', 'boolean', True))
439 else: 439 else:
440 raise ChromeProxyMetricException, ( 440 raise ChromeProxyMetricException, (
441 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( 441 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % (
442 count, safebrowsing_count)) 442 count, safebrowsing_count))
443 443
444 def AddResultsForSafebrowsingDesktop(self, tab, results):
445 count = 0
446 safebrowsing_count = 0
447 for resp in self.IterResponses(tab):
448 count += 1
449 if resp.HasChromeProxyViaHeader():
450 safebrowsing_count += 1
451 else:
452 r = resp.response
453 raise ChromeProxyMetricException, (
454 '%s: Safebrowsing feature should be off for desktop.\n'
455 'Reponse: status=(%d, %s)\nHeaders:\n %s' % (
456 r.url, r.status, r.status_text, r.headers))
457 if count == safebrowsing_count:
458 results.AddValue(scalar.ScalarValue(
459 results.current_page, 'safebrowsing', 'boolean', True))
460 else:
461 raise ChromeProxyMetricException, (
462 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % (
463 count, safebrowsing_count))
464
444 def VerifyProxyInfo(self, tab, expected_proxies, expected_bad_proxies): 465 def VerifyProxyInfo(self, tab, expected_proxies, expected_bad_proxies):
445 info = GetProxyInfoFromNetworkInternals(tab) 466 info = GetProxyInfoFromNetworkInternals(tab)
446 if not 'enabled' in info or not info['enabled']: 467 if not 'enabled' in info or not info['enabled']:
447 raise ChromeProxyMetricException, ( 468 raise ChromeProxyMetricException, (
448 'Chrome proxy should be enabled. proxy info: %s' % info) 469 'Chrome proxy should be enabled. proxy info: %s' % info)
449 proxies = info['proxies'] 470 proxies = info['proxies']
450 if (set(proxies) != set(expected_proxies) and 471 if (set(proxies) != set(expected_proxies) and
451 set(proxies) != set(self.ProxyListForDev(expected_proxies))): 472 set(proxies) != set(self.ProxyListForDev(expected_proxies))):
452 raise ChromeProxyMetricException, ( 473 raise ChromeProxyMetricException, (
453 'Wrong effective proxies (%s). Expect: "%s"' % ( 474 'Wrong effective proxies (%s). Expect: "%s"' % (
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if not 'enabled' in info or not info['enabled']: 528 if not 'enabled' in info or not info['enabled']:
508 raise ChromeProxyMetricException, ( 529 raise ChromeProxyMetricException, (
509 'Chrome proxy should be enabled. proxy info: %s' % info) 530 'Chrome proxy should be enabled. proxy info: %s' % info)
510 # TODO(sclittle): Remove this dependency on net-internals#proxy once an 531 # TODO(sclittle): Remove this dependency on net-internals#proxy once an
511 # alternative method of verifying that Chrome is on the fallback proxy 532 # alternative method of verifying that Chrome is on the fallback proxy
512 # exists. 533 # exists.
513 self.VerifyBadProxies(info['badProxies'], 534 self.VerifyBadProxies(info['badProxies'],
514 expected_bad_proxies) 535 expected_bad_proxies)
515 results.AddValue(scalar.ScalarValue( 536 results.AddValue(scalar.ScalarValue(
516 results.current_page, 'explicit_bypass', 'boolean', True)) 537 results.current_page, 'explicit_bypass', 'boolean', True))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698