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

Side by Side Diff: webkit/glue/media/buffered_resource_loader_unittest.cc

Issue 7044092: Not allow compression when requesting multimedia (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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 | « webkit/glue/media/buffered_resource_loader.cc ('k') | webkit/glue/media/simple_data_source.cc » ('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 (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 <algorithm> 5 #include <algorithm>
6 #include <string>
6 7
7 #include "base/format_macros.h" 8 #include "base/format_macros.h"
8 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/http/http_request_headers.h"
10 #include "net/http/http_util.h" 12 #include "net/http/http_util.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
16 #include "webkit/glue/media/buffered_resource_loader.h" 19 #include "webkit/glue/media/buffered_resource_loader.h"
17 #include "webkit/mocks/mock_webframeclient.h" 20 #include "webkit/mocks/mock_webframeclient.h"
18 #include "webkit/mocks/mock_weburlloader.h" 21 #include "webkit/mocks/mock_weburlloader.h"
19 22
20 using ::testing::_; 23 using ::testing::_;
21 using ::testing::Assign; 24 using ::testing::Assign;
22 using ::testing::AtLeast; 25 using ::testing::AtLeast;
23 using ::testing::DeleteArg; 26 using ::testing::DeleteArg;
24 using ::testing::DoAll; 27 using ::testing::DoAll;
25 using ::testing::InSequence; 28 using ::testing::InSequence;
26 using ::testing::Invoke; 29 using ::testing::Invoke;
27 using ::testing::InvokeWithoutArgs; 30 using ::testing::InvokeWithoutArgs;
28 using ::testing::NotNull; 31 using ::testing::NotNull;
29 using ::testing::Return; 32 using ::testing::Return;
30 using ::testing::ReturnRef; 33 using ::testing::ReturnRef;
31 using ::testing::SetArgumentPointee; 34 using ::testing::SetArgumentPointee;
32 using ::testing::StrictMock; 35 using ::testing::StrictMock;
36 using ::testing::Truly;
33 using ::testing::NiceMock; 37 using ::testing::NiceMock;
34 using ::testing::WithArgs; 38 using ::testing::WithArgs;
35 39
36 using WebKit::WebString; 40 using WebKit::WebString;
37 using WebKit::WebURLError; 41 using WebKit::WebURLError;
38 using WebKit::WebURLResponse; 42 using WebKit::WebURLResponse;
39 using WebKit::WebView; 43 using WebKit::WebView;
40 44
41 namespace webkit_glue { 45 namespace webkit_glue {
42 46
(...skipping 15 matching lines...) Expand all
58 62
59 // Submit a request completed event to the resource loader due to request 63 // Submit a request completed event to the resource loader due to request
60 // being canceled. Pretending the event is from external. 64 // being canceled. Pretending the event is from external.
61 ACTION_P(RequestCanceled, loader) { 65 ACTION_P(RequestCanceled, loader) {
62 WebURLError error; 66 WebURLError error;
63 error.reason = net::ERR_ABORTED; 67 error.reason = net::ERR_ABORTED;
64 error.domain = WebString::fromUTF8(net::kErrorDomain); 68 error.domain = WebString::fromUTF8(net::kErrorDomain);
65 loader->didFail(NULL, error); 69 loader->didFail(NULL, error);
66 } 70 }
67 71
72 // Predicate that tests that request disallows compressed data.
73 static bool CorrectAcceptEncoding(const WebKit::WebURLRequest &request) {
74 std::string value = request.httpHeaderField(
75 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding)).utf8();
76 return (value.find("identity;q=1") != std::string::npos) &&
77 (value.find("*;q=0") != std::string::npos);
78 }
79
68 class BufferedResourceLoaderTest : public testing::Test { 80 class BufferedResourceLoaderTest : public testing::Test {
69 public: 81 public:
70 BufferedResourceLoaderTest() 82 BufferedResourceLoaderTest()
71 : view_(WebView::create(NULL)) { 83 : view_(WebView::create(NULL)) {
72 view_->initializeMainFrame(&client_); 84 view_->initializeMainFrame(&client_);
73 85
74 for (int i = 0; i < kDataSize; ++i) { 86 for (int i = 0; i < kDataSize; ++i) {
75 data_[i] = i; 87 data_[i] = i;
76 } 88 }
77 } 89 }
(...skipping 13 matching lines...) Expand all
91 loader_->SetURLLoaderForTest(url_loader_); 103 loader_->SetURLLoaderForTest(url_loader_);
92 } 104 }
93 105
94 void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) { 106 void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) {
95 loader_->buffer_.reset( 107 loader_->buffer_.reset(
96 new media::SeekableBuffer(backward_capacity, forward_capacity)); 108 new media::SeekableBuffer(backward_capacity, forward_capacity));
97 } 109 }
98 110
99 void Start() { 111 void Start() {
100 InSequence s; 112 InSequence s;
101 EXPECT_CALL(*url_loader_, loadAsynchronously(_, loader_.get())); 113 EXPECT_CALL(*url_loader_, loadAsynchronously(Truly(CorrectAcceptEncoding),
114 loader_.get()));
102 loader_->Start( 115 loader_->Start(
103 NewCallback(this, &BufferedResourceLoaderTest::StartCallback), 116 NewCallback(this, &BufferedResourceLoaderTest::StartCallback),
104 NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback), 117 NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback),
105 view_->mainFrame()); 118 view_->mainFrame());
106 } 119 }
107 120
108 void FullResponse(int64 instance_size) { 121 void FullResponse(int64 instance_size) {
109 FullResponse(instance_size, net::OK); 122 FullResponse(instance_size, net::OK);
110 } 123 }
111 124
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 Start(); 591 Start();
579 Redirect(kHttpRedirectToSameDomainUrl1); 592 Redirect(kHttpRedirectToSameDomainUrl1);
580 Redirect(kHttpRedirectToDifferentDomainUrl1); 593 Redirect(kHttpRedirectToDifferentDomainUrl1);
581 EXPECT_FALSE(loader_->HasSingleOrigin()); 594 EXPECT_FALSE(loader_->HasSingleOrigin());
582 StopWhenLoad(); 595 StopWhenLoad();
583 } 596 }
584 597
585 // TODO(hclam): add unit test for defer loading. 598 // TODO(hclam): add unit test for defer loading.
586 599
587 } // namespace webkit_glue 600 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/media/buffered_resource_loader.cc ('k') | webkit/glue/media/simple_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698