OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "components/copresence/rpc/http_post.h" | 5 #include "components/copresence/rpc/http_post.h" |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "components/copresence/proto/data.pb.h" | 8 #include "components/copresence/proto/data.pb.h" |
9 #include "net/base/url_util.h" | 9 #include "net/base/url_util.h" |
10 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class HttpPostTest : public testing::Test { | 29 class HttpPostTest : public testing::Test { |
30 public: | 30 public: |
31 HttpPostTest() | 31 HttpPostTest() |
32 : received_response_code_(0) { | 32 : received_response_code_(0) { |
33 context_getter_ = new net::TestURLRequestContextGetter( | 33 context_getter_ = new net::TestURLRequestContextGetter( |
34 make_scoped_refptr(new base::TestSimpleTaskRunner)); | 34 make_scoped_refptr(new base::TestSimpleTaskRunner)); |
35 proto_.set_client("test_client"); | 35 proto_.set_client("test_client"); |
36 proto_.set_version_code(123); | 36 proto_.set_version_code(123); |
37 } | 37 } |
38 virtual ~HttpPostTest() {} | 38 ~HttpPostTest() override {} |
39 | 39 |
40 // Record the response sent back to the client for verification. | 40 // Record the response sent back to the client for verification. |
41 void TestResponseCallback(int response_code, | 41 void TestResponseCallback(int response_code, |
42 const std::string& response) { | 42 const std::string& response) { |
43 received_response_code_ = response_code; | 43 received_response_code_ = response_code; |
44 received_response_ = response; | 44 received_response_ = response; |
45 } | 45 } |
46 | 46 |
47 protected: | 47 protected: |
48 bool ResponsePassedThrough(int response_code, const std::string& response) { | 48 bool ResponsePassedThrough(int response_code, const std::string& response) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 TEST_F(HttpPostTest, ErrorResponse) { | 133 TEST_F(HttpPostTest, ErrorResponse) { |
134 EXPECT_TRUE(ResponsePassedThrough( | 134 EXPECT_TRUE(ResponsePassedThrough( |
135 net::HTTP_BAD_REQUEST, "Bad client. Shame on you.")); | 135 net::HTTP_BAD_REQUEST, "Bad client. Shame on you.")); |
136 EXPECT_TRUE(ResponsePassedThrough( | 136 EXPECT_TRUE(ResponsePassedThrough( |
137 net::HTTP_INTERNAL_SERVER_ERROR, "I'm dying. Forgive me.")); | 137 net::HTTP_INTERNAL_SERVER_ERROR, "I'm dying. Forgive me.")); |
138 EXPECT_TRUE(ResponsePassedThrough(-1, "")); | 138 EXPECT_TRUE(ResponsePassedThrough(-1, "")); |
139 } | 139 } |
140 | 140 |
141 } // namespace copresence | 141 } // namespace copresence |
OLD | NEW |