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

Side by Side Diff: content/renderer/media/buffered_resource_loader_unittest.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « content/renderer/media/buffered_resource_loader.cc ('k') | content/renderer/media/cache_util.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 12 matching lines...) Expand all
23 #include "third_party/WebKit/public/platform/WebURLResponse.h" 23 #include "third_party/WebKit/public/platform/WebURLResponse.h"
24 #include "third_party/WebKit/public/web/WebFrame.h" 24 #include "third_party/WebKit/public/web/WebFrame.h"
25 #include "third_party/WebKit/public/web/WebView.h" 25 #include "third_party/WebKit/public/web/WebView.h"
26 26
27 using ::testing::_; 27 using ::testing::_;
28 using ::testing::InSequence; 28 using ::testing::InSequence;
29 using ::testing::Return; 29 using ::testing::Return;
30 using ::testing::Truly; 30 using ::testing::Truly;
31 using ::testing::NiceMock; 31 using ::testing::NiceMock;
32 32
33 using WebKit::WebString; 33 using blink::WebString;
34 using WebKit::WebURLError; 34 using blink::WebURLError;
35 using WebKit::WebURLResponse; 35 using blink::WebURLResponse;
36 using WebKit::WebView; 36 using blink::WebView;
37 37
38 namespace content { 38 namespace content {
39 39
40 static const char* kHttpUrl = "http://test"; 40 static const char* kHttpUrl = "http://test";
41 static const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing"; 41 static const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing";
42 static const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2"; 42 static const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2";
43 static const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2"; 43 static const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2";
44 44
45 static const int kDataSize = 1024; 45 static const int kDataSize = 1024;
46 static const int kHttpOK = 200; 46 static const int kHttpOK = 200;
47 static const int kHttpPartialContent = 206; 47 static const int kHttpPartialContent = 206;
48 48
49 enum NetworkState { 49 enum NetworkState {
50 NONE, 50 NONE,
51 LOADED, 51 LOADED,
52 LOADING 52 LOADING
53 }; 53 };
54 54
55 // Predicate that tests that request disallows compressed data. 55 // Predicate that tests that request disallows compressed data.
56 static bool CorrectAcceptEncoding(const WebKit::WebURLRequest &request) { 56 static bool CorrectAcceptEncoding(const blink::WebURLRequest &request) {
57 std::string value = request.httpHeaderField( 57 std::string value = request.httpHeaderField(
58 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding)).utf8(); 58 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding)).utf8();
59 return (value.find("identity;q=1") != std::string::npos) && 59 return (value.find("identity;q=1") != std::string::npos) &&
60 (value.find("*;q=0") != std::string::npos); 60 (value.find("*;q=0") != std::string::npos);
61 } 61 }
62 62
63 class BufferedResourceLoaderTest : public testing::Test { 63 class BufferedResourceLoaderTest : public testing::Test {
64 public: 64 public:
65 BufferedResourceLoaderTest() 65 BufferedResourceLoaderTest()
66 : view_(WebView::create(NULL)) { 66 : view_(WebView::create(NULL)) {
(...skipping 14 matching lines...) Expand all
81 last_position_ = last_position; 81 last_position_ = last_position;
82 82
83 loader_.reset(new BufferedResourceLoader( 83 loader_.reset(new BufferedResourceLoader(
84 gurl_, BufferedResourceLoader::kUnspecified, 84 gurl_, BufferedResourceLoader::kUnspecified,
85 first_position_, last_position_, 85 first_position_, last_position_,
86 BufferedResourceLoader::kCapacityDefer, 0, 0, 86 BufferedResourceLoader::kCapacityDefer, 0, 0,
87 new media::MediaLog())); 87 new media::MediaLog()));
88 88
89 // |test_loader_| will be used when Start() is called. 89 // |test_loader_| will be used when Start() is called.
90 url_loader_ = new NiceMock<MockWebURLLoader>(); 90 url_loader_ = new NiceMock<MockWebURLLoader>();
91 loader_->test_loader_ = scoped_ptr<WebKit::WebURLLoader>(url_loader_); 91 loader_->test_loader_ = scoped_ptr<blink::WebURLLoader>(url_loader_);
92 } 92 }
93 93
94 void SetLoaderBuffer(int forward_capacity, int backward_capacity) { 94 void SetLoaderBuffer(int forward_capacity, int backward_capacity) {
95 loader_->buffer_.set_forward_capacity(forward_capacity); 95 loader_->buffer_.set_forward_capacity(forward_capacity);
96 loader_->buffer_.set_backward_capacity(backward_capacity); 96 loader_->buffer_.set_backward_capacity(backward_capacity);
97 loader_->buffer_.Clear(); 97 loader_->buffer_.Clear();
98 } 98 }
99 99
100 void Start() { 100 void Start() {
101 InSequence s; 101 InSequence s;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Can we eliminate one? 180 // Can we eliminate one?
181 EXPECT_EQ(content_length, loader_->content_length()); 181 EXPECT_EQ(content_length, loader_->content_length());
182 EXPECT_EQ(instance_size, loader_->instance_size()); 182 EXPECT_EQ(instance_size, loader_->instance_size());
183 183
184 // A valid partial response should always result in this being true. 184 // A valid partial response should always result in this being true.
185 EXPECT_TRUE(loader_->range_supported()); 185 EXPECT_TRUE(loader_->range_supported());
186 } 186 }
187 187
188 void Redirect(const char* url) { 188 void Redirect(const char* url) {
189 GURL redirectUrl(url); 189 GURL redirectUrl(url);
190 WebKit::WebURLRequest newRequest(redirectUrl); 190 blink::WebURLRequest newRequest(redirectUrl);
191 WebKit::WebURLResponse redirectResponse(gurl_); 191 blink::WebURLResponse redirectResponse(gurl_);
192 192
193 loader_->willSendRequest(url_loader_, newRequest, redirectResponse); 193 loader_->willSendRequest(url_loader_, newRequest, redirectResponse);
194 194
195 base::MessageLoop::current()->RunUntilIdle(); 195 base::MessageLoop::current()->RunUntilIdle();
196 } 196 }
197 197
198 void StopWhenLoad() { 198 void StopWhenLoad() {
199 InSequence s; 199 InSequence s;
200 EXPECT_CALL(*url_loader_, cancel()); 200 EXPECT_CALL(*url_loader_, cancel());
201 loader_->Stop(); 201 loader_->Stop();
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 ExpectContentRangeFailure("bytes 20-10/400"); 1119 ExpectContentRangeFailure("bytes 20-10/400");
1120 1120
1121 ExpectContentRangeSuccess("bytes 0-499/500", 0, 499, 500); 1121 ExpectContentRangeSuccess("bytes 0-499/500", 0, 499, 500);
1122 ExpectContentRangeSuccess("bytes 0-0/500", 0, 0, 500); 1122 ExpectContentRangeSuccess("bytes 0-0/500", 0, 0, 500);
1123 ExpectContentRangeSuccess("bytes 10-11/50", 10, 11, 50); 1123 ExpectContentRangeSuccess("bytes 10-11/50", 10, 11, 50);
1124 ExpectContentRangeSuccess("bytes 10-11/*", 10, 11, 1124 ExpectContentRangeSuccess("bytes 10-11/*", 10, 11,
1125 kPositionNotSpecified); 1125 kPositionNotSpecified);
1126 } 1126 }
1127 1127
1128 } // namespace content 1128 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/buffered_resource_loader.cc ('k') | content/renderer/media/cache_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698