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

Side by Side Diff: components/webp_transcode/webp_network_client_unittest.mm

Issue 1860003003: Remove the WebPNetworkClient* from iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix No. 2 Created 4 years, 8 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 | « components/webp_transcode/webp_network_client_factory.mm ('k') | ios/crnet/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/webp_transcode/webp_network_client.h"
6
7 #include <stddef.h>
8
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "net/http/http_request_headers.h"
15 #include "net/url_request/url_request_test_util.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #import "third_party/ocmock/OCMock/OCMock.h"
18
19 namespace {
20 class WebPNetworkClientTest : public testing::Test {
21 public:
22 WebPNetworkClientTest() {
23 // Set up mock original network client proxy.
24 OCMockObject* mockProxy_ = [[OCMockObject
25 niceMockForProtocol:@protocol(CRNNetworkClientProtocol)] retain];
26 mockWebProxy_.reset(mockProxy_);
27
28 // Link all the mock objects into the WebPNetworkClient.
29 webp_client_.reset([[WebPNetworkClient alloc]
30 initWithTaskRunner:base::ThreadTaskRunnerHandle::Get()]);
31 [webp_client_
32 setUnderlyingClient:(id<CRNNetworkClientProtocol>)mockWebProxy_];
33 }
34
35 protected:
36 base::MessageLoop loop_;
37 base::scoped_nsobject<WebPNetworkClient> webp_client_;
38 // Holds a mock CRNNetworkClientProtocol object.
39 base::scoped_nsobject<OCMockObject> mockWebProxy_;
40 };
41 } // namespace
42
43 TEST_F(WebPNetworkClientTest, TestAcceptHeaders) {
44 const struct {
45 const std::string header_in;
46 const std::string header_out;
47 } tests[] = {
48 {"", "image/webp"},
49 {"*/*", "*/*,image/webp"},
50 {"image/webp", "image/webp"},
51 {"text/html,*/*", "text/html,*/*,image/webp"},
52 // Desktop Chrome default without image/webp.
53 {"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
54 "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,"
55 "image/webp"},
56 // Desktop Chrome default.
57 {"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,"
58 "*/*;q=0.8",
59 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,"
60 "*/*;q=0.8"}};
61 GURL url("http://www.google.com");
62 scoped_ptr<net::URLRequestContext> request_context(
63 new net::TestURLRequestContext(false));
64 for (size_t i = 0; i < arraysize(tests); ++i) {
65 scoped_ptr<net::URLRequest> request =
66 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, nullptr);
67 if (!tests[i].header_in.empty())
68 request->SetExtraRequestHeaderByName("Accept", tests[i].header_in, true);
69 [webp_client_ didCreateNativeRequest:request.get()];
70 const net::HttpRequestHeaders& headers = request->extra_request_headers();
71 std::string acceptHeader;
72 EXPECT_TRUE(headers.GetHeader("Accept", &acceptHeader));
73 EXPECT_EQ(tests[i].header_out, acceptHeader);
74 }
75 }
OLDNEW
« no previous file with comments | « components/webp_transcode/webp_network_client_factory.mm ('k') | ios/crnet/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698