| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class RequestSenderTest : public testing::Test { | 39 class RequestSenderTest : public testing::Test { |
| 40 public: | 40 public: |
| 41 RequestSenderTest(); | 41 RequestSenderTest(); |
| 42 ~RequestSenderTest() override; | 42 ~RequestSenderTest() override; |
| 43 | 43 |
| 44 // Overrides from testing::Test. | 44 // Overrides from testing::Test. |
| 45 void SetUp() override; | 45 void SetUp() override; |
| 46 void TearDown() override; | 46 void TearDown() override; |
| 47 | 47 |
| 48 void RequestSenderComplete(int error, const std::string& response); | 48 void RequestSenderComplete(int error, |
| 49 const std::string& response, |
| 50 int retry_after_sec); |
| 49 | 51 |
| 50 protected: | 52 protected: |
| 51 void Quit(); | 53 void Quit(); |
| 52 void RunThreads(); | 54 void RunThreads(); |
| 53 void RunThreadsUntilIdle(); | 55 void RunThreadsUntilIdle(); |
| 54 | 56 |
| 55 scoped_refptr<TestConfigurator> config_; | 57 scoped_refptr<TestConfigurator> config_; |
| 56 scoped_ptr<RequestSender> request_sender_; | 58 scoped_ptr<RequestSender> request_sender_; |
| 57 scoped_ptr<InterceptorFactory> interceptor_factory_; | 59 scoped_ptr<InterceptorFactory> interceptor_factory_; |
| 58 | 60 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void RequestSenderTest::RunThreadsUntilIdle() { | 119 void RequestSenderTest::RunThreadsUntilIdle() { |
| 118 base::RunLoop().RunUntilIdle(); | 120 base::RunLoop().RunUntilIdle(); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void RequestSenderTest::Quit() { | 123 void RequestSenderTest::Quit() { |
| 122 if (!quit_closure_.is_null()) | 124 if (!quit_closure_.is_null()) |
| 123 quit_closure_.Run(); | 125 quit_closure_.Run(); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void RequestSenderTest::RequestSenderComplete(int error, | 128 void RequestSenderTest::RequestSenderComplete(int error, |
| 127 const std::string& response) { | 129 const std::string& response, |
| 130 int retry_after_sec) { |
| 128 error_ = error; | 131 error_ = error; |
| 129 response_ = response; | 132 response_ = response; |
| 130 | 133 |
| 131 Quit(); | 134 Quit(); |
| 132 } | 135 } |
| 133 | 136 |
| 134 // Tests that when a request to the first url succeeds, the subsequent urls are | 137 // Tests that when a request to the first url succeeds, the subsequent urls are |
| 135 // not tried. | 138 // not tried. |
| 136 TEST_F(RequestSenderTest, RequestSendSuccess) { | 139 TEST_F(RequestSenderTest, RequestSendSuccess) { |
| 137 EXPECT_TRUE(post_interceptor_1_->ExpectRequest( | 140 EXPECT_TRUE(post_interceptor_1_->ExpectRequest( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 << post_interceptor_1_->GetRequestsAsString(); | 254 << post_interceptor_1_->GetRequestsAsString(); |
| 252 EXPECT_EQ(1, post_interceptor_1_->GetCount()) | 255 EXPECT_EQ(1, post_interceptor_1_->GetCount()) |
| 253 << post_interceptor_1_->GetRequestsAsString(); | 256 << post_interceptor_1_->GetRequestsAsString(); |
| 254 | 257 |
| 255 EXPECT_STREQ("test", post_interceptor_1_->GetRequests()[0].c_str()); | 258 EXPECT_STREQ("test", post_interceptor_1_->GetRequests()[0].c_str()); |
| 256 EXPECT_EQ(RequestSender::kErrorResponseNotTrusted, error_); | 259 EXPECT_EQ(RequestSender::kErrorResponseNotTrusted, error_); |
| 257 EXPECT_TRUE(response_.empty()); | 260 EXPECT_TRUE(response_.empty()); |
| 258 } | 261 } |
| 259 | 262 |
| 260 } // namespace update_client | 263 } // namespace update_client |
| OLD | NEW |