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

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

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