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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "components/component_updater/request_sender.h" | 10 #include "components/component_updater/request_sender.h" |
11 #include "components/component_updater/test/test_configurator.h" | 11 #include "components/component_updater/test/test_configurator.h" |
12 #include "components/component_updater/test/url_request_post_interceptor.h" | 12 #include "components/component_updater/test/url_request_post_interceptor.h" |
13 #include "net/url_request/url_fetcher.h" | 13 #include "net/url_request/url_fetcher.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace component_updater { | 16 namespace component_updater { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kUrl1[] = "https://localhost2/path1"; | 20 const char kUrl1[] = "https://localhost2/path1"; |
21 const char kUrl2[] = "https://localhost2/path2"; | 21 const char kUrl2[] = "https://localhost2/path2"; |
22 const char kUrlPath1[] = "path1"; | 22 const char kUrlPath1[] = "path1"; |
23 const char kUrlPath2[] = "path2"; | 23 const char kUrlPath2[] = "path2"; |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 class RequestSenderTest : public testing::Test { | 27 class RequestSenderTest : public testing::Test { |
28 public: | 28 public: |
29 RequestSenderTest(); | 29 RequestSenderTest(); |
30 virtual ~RequestSenderTest(); | 30 ~RequestSenderTest() override; |
31 | 31 |
32 // Overrides from testing::Test. | 32 // Overrides from testing::Test. |
33 virtual void SetUp() override; | 33 void SetUp() override; |
34 virtual void TearDown() override; | 34 void TearDown() override; |
35 | 35 |
36 void RequestSenderComplete(const net::URLFetcher* source); | 36 void RequestSenderComplete(const net::URLFetcher* source); |
37 | 37 |
38 protected: | 38 protected: |
39 void Quit(); | 39 void Quit(); |
40 void RunThreads(); | 40 void RunThreads(); |
41 void RunThreadsUntilIdle(); | 41 void RunThreadsUntilIdle(); |
42 | 42 |
43 scoped_ptr<TestConfigurator> config_; | 43 scoped_ptr<TestConfigurator> config_; |
44 scoped_ptr<RequestSender> request_sender_; | 44 scoped_ptr<RequestSender> request_sender_; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 EXPECT_EQ(1, post_interceptor_2->GetCount()) | 201 EXPECT_EQ(1, post_interceptor_2->GetCount()) |
202 << post_interceptor_2->GetRequestsAsString(); | 202 << post_interceptor_2->GetRequestsAsString(); |
203 | 203 |
204 EXPECT_STREQ("test", post_interceptor_1->GetRequests()[0].c_str()); | 204 EXPECT_STREQ("test", post_interceptor_1->GetRequests()[0].c_str()); |
205 EXPECT_STREQ("test", post_interceptor_2->GetRequests()[0].c_str()); | 205 EXPECT_STREQ("test", post_interceptor_2->GetRequests()[0].c_str()); |
206 EXPECT_EQ(GURL(kUrl2), url_fetcher_source_->GetOriginalURL()); | 206 EXPECT_EQ(GURL(kUrl2), url_fetcher_source_->GetOriginalURL()); |
207 EXPECT_EQ(403, url_fetcher_source_->GetResponseCode()); | 207 EXPECT_EQ(403, url_fetcher_source_->GetResponseCode()); |
208 } | 208 } |
209 | 209 |
210 } // namespace component_updater | 210 } // namespace component_updater |
OLD | NEW |