OLD | NEW |
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 "google_apis/drive/request_sender.h" | 5 #include "google_apis/drive/request_sender.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "google_apis/drive/base_requests.h" | 10 #include "google_apis/drive/base_requests.h" |
11 #include "google_apis/drive/dummy_auth_service.h" | 11 #include "google_apis/drive/dummy_auth_service.h" |
| 12 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace google_apis { | 15 namespace google_apis { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const char kTestRefreshToken[] = "valid-refresh-token"; | 19 const char kTestRefreshToken[] = "valid-refresh-token"; |
19 const char kTestAccessToken[] = "valid-access-token"; | 20 const char kTestAccessToken[] = "valid-access-token"; |
20 | 21 |
21 // Enum for indicating the reason why a request is finished. | 22 // Enum for indicating the reason why a request is finished. |
(...skipping 29 matching lines...) Expand all Loading... |
51 } | 52 } |
52 | 53 |
53 private: | 54 private: |
54 int auth_try_count_; | 55 int auth_try_count_; |
55 }; | 56 }; |
56 | 57 |
57 // The main test fixture class. | 58 // The main test fixture class. |
58 class RequestSenderTest : public testing::Test { | 59 class RequestSenderTest : public testing::Test { |
59 protected: | 60 protected: |
60 RequestSenderTest() | 61 RequestSenderTest() |
61 : auth_service_(new TestAuthService), | 62 : auth_service_(new TestAuthService), |
62 request_sender_(auth_service_, NULL, NULL, "dummy-user-agent") { | 63 request_sender_(auth_service_, |
| 64 NULL, |
| 65 NULL, |
| 66 "dummy-user-agent", |
| 67 TRAFFIC_ANNOTATION_FOR_TESTS) { |
63 auth_service_->set_refresh_token(kTestRefreshToken); | 68 auth_service_->set_refresh_token(kTestRefreshToken); |
64 auth_service_->set_access_token(kTestAccessToken); | 69 auth_service_->set_access_token(kTestAccessToken); |
65 } | 70 } |
66 | 71 |
67 TestAuthService* auth_service_; // Owned by |request_sender_|. | 72 TestAuthService* auth_service_; // Owned by |request_sender_|. |
68 RequestSender request_sender_; | 73 RequestSender request_sender_; |
69 }; | 74 }; |
70 | 75 |
71 // Minimal implementation for AuthenticatedRequestInterface that can interact | 76 // Minimal implementation for AuthenticatedRequestInterface that can interact |
72 // with RequestSender correctly. | 77 // with RequestSender correctly. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // by the RequestSender. So with this TestRequest, RequestSender retries | 253 // by the RequestSender. So with this TestRequest, RequestSender retries |
249 // infinitely. Let it succeed/ | 254 // infinitely. Let it succeed/ |
250 EXPECT_EQ(kTestAccessToken + std::string("3"), | 255 EXPECT_EQ(kTestAccessToken + std::string("3"), |
251 request_ptr->passed_access_token()); | 256 request_ptr->passed_access_token()); |
252 request_ptr->FinishRequestWithSuccess(); | 257 request_ptr->FinishRequestWithSuccess(); |
253 EXPECT_EQ(SUCCESS, finish_reason); | 258 EXPECT_EQ(SUCCESS, finish_reason); |
254 EXPECT_FALSE(weak_ptr); | 259 EXPECT_FALSE(weak_ptr); |
255 } | 260 } |
256 | 261 |
257 } // namespace google_apis | 262 } // namespace google_apis |
OLD | NEW |