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

Side by Side Diff: tools/android/loading/request_track_unittest.py

Issue 1707173003: tools/android/loading Add 'redirect' and 'ping' content types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: indent Created 4 years, 10 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
« no previous file with comments | « tools/android/loading/request_track.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 copy 5 import copy
6 import json 6 import json
7 import unittest 7 import unittest
8 8
9 from request_track import (TimeBetween, Request, RequestTrack, TimingFromDict) 9 from request_track import (TimeBetween, Request, RequestTrack, TimingFromDict)
10 10
(...skipping 29 matching lines...) Expand all
40 r.response_headers = {} 40 r.response_headers = {}
41 self.assertEquals(None, r.GetContentType()) 41 self.assertEquals(None, r.GetContentType())
42 r.response_headers = {'Content-Type': 'application/javascript'} 42 r.response_headers = {'Content-Type': 'application/javascript'}
43 self.assertEquals('application/javascript', r.GetContentType()) 43 self.assertEquals('application/javascript', r.GetContentType())
44 # Case-insensitive match. 44 # Case-insensitive match.
45 r.response_headers = {'content-type': 'application/javascript'} 45 r.response_headers = {'content-type': 'application/javascript'}
46 self.assertEquals('application/javascript', r.GetContentType()) 46 self.assertEquals('application/javascript', r.GetContentType())
47 # Parameters are filtered out. 47 # Parameters are filtered out.
48 r.response_headers = {'Content-Type': 'application/javascript;bla'} 48 r.response_headers = {'Content-Type': 'application/javascript;bla'}
49 self.assertEquals('application/javascript', r.GetContentType()) 49 self.assertEquals('application/javascript', r.GetContentType())
50 # MIME type takes precedence over headers. 50 # MIME type takes precedence over 'Content-Type' header.
51 r.mime_type = 'image/webp' 51 r.mime_type = 'image/webp'
52 self.assertEquals('image/webp', r.GetContentType()) 52 self.assertEquals('image/webp', r.GetContentType())
53 r.mime_type = None 53 r.mime_type = None
54 # Test for 'ping' type.
55 r.status = 204
56 self.assertEquals('ping', r.GetContentType())
57 r.status = None
58 r.response_headers = {'Content-Type': 'application/javascript',
59 'content-length': '0'}
60 self.assertEquals('ping', r.GetContentType())
61 # Test for 'redirect' type.
62 r.response_headers = {'Content-Type': 'application/javascript',
63 'location': 'http://foo',
64 'content-length': '0'}
65 self.assertEquals('redirect', r.GetContentType())
66
67 def testGetHTTPResponseHeader(self):
68 r = Request()
69 r.response_headers = {}
70 self.assertEquals(None, r.GetHTTPResponseHeader('Foo'))
71 r.response_headers = {'Foo': 'Bar', 'Baz': 'Foo'}
72 self.assertEquals('Bar', r.GetHTTPResponseHeader('Foo'))
73 r.response_headers = {'foo': 'Bar', 'Baz': 'Foo'}
74 self.assertEquals('Bar', r.GetHTTPResponseHeader('Foo'))
54 75
55 76
56 class RequestTrackTestCase(unittest.TestCase): 77 class RequestTrackTestCase(unittest.TestCase):
57 _REQUEST_WILL_BE_SENT = { 78 _REQUEST_WILL_BE_SENT = {
58 'method': 'Network.requestWillBeSent', 79 'method': 'Network.requestWillBeSent',
59 'params': { 80 'params': {
60 'documentURL': 'http://example.com/', 81 'documentURL': 'http://example.com/',
61 'frameId': '32493.1', 82 'frameId': '32493.1',
62 'initiator': { 83 'initiator': {
63 'type': 'other' 84 'type': 'other'
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 def _ValidSequence(cls, request_track): 403 def _ValidSequence(cls, request_track):
383 request_track.Handle( 404 request_track.Handle(
384 'Network.requestWillBeSent', cls._REQUEST_WILL_BE_SENT) 405 'Network.requestWillBeSent', cls._REQUEST_WILL_BE_SENT)
385 request_track.Handle('Network.responseReceived', cls._RESPONSE_RECEIVED) 406 request_track.Handle('Network.responseReceived', cls._RESPONSE_RECEIVED)
386 request_track.Handle('Network.dataReceived', cls._DATA_RECEIVED_1) 407 request_track.Handle('Network.dataReceived', cls._DATA_RECEIVED_1)
387 request_track.Handle('Network.dataReceived', cls._DATA_RECEIVED_2) 408 request_track.Handle('Network.dataReceived', cls._DATA_RECEIVED_2)
388 request_track.Handle('Network.loadingFinished', cls._LOADING_FINISHED) 409 request_track.Handle('Network.loadingFinished', cls._LOADING_FINISHED)
389 410
390 if __name__ == '__main__': 411 if __name__ == '__main__':
391 unittest.main() 412 unittest.main()
OLDNEW
« no previous file with comments | « tools/android/loading/request_track.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698