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 "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // | 187 // |
188 // This fixture provides an embedded HTTP server and a mock OAuth2 token service | 188 // This fixture provides an embedded HTTP server and a mock OAuth2 token service |
189 // for interacting with AttachmentUploaderImpl | 189 // for interacting with AttachmentUploaderImpl |
190 class AttachmentUploaderImplTest : public testing::Test, | 190 class AttachmentUploaderImplTest : public testing::Test, |
191 public base::NonThreadSafe { | 191 public base::NonThreadSafe { |
192 public: | 192 public: |
193 void OnRequestReceived(const HttpRequest& request); | 193 void OnRequestReceived(const HttpRequest& request); |
194 | 194 |
195 protected: | 195 protected: |
196 AttachmentUploaderImplTest(); | 196 AttachmentUploaderImplTest(); |
197 virtual void SetUp(); | 197 void SetUp() override; |
198 virtual void TearDown(); | 198 void TearDown() override; |
199 | 199 |
200 // Run the message loop until UploadDone has been invoked |num_uploads| times. | 200 // Run the message loop until UploadDone has been invoked |num_uploads| times. |
201 void RunAndWaitFor(int num_uploads); | 201 void RunAndWaitFor(int num_uploads); |
202 | 202 |
203 // Upload an attachment and have the server respond with |status_code|. | 203 // Upload an attachment and have the server respond with |status_code|. |
204 // | 204 // |
205 // Returns the attachment that was uploaded. | 205 // Returns the attachment that was uploaded. |
206 Attachment UploadAndRespondWith(const net::HttpStatusCode& status_code); | 206 Attachment UploadAndRespondWith(const net::HttpStatusCode& status_code); |
207 | 207 |
208 scoped_ptr<AttachmentUploader>& uploader(); | 208 scoped_ptr<AttachmentUploader>& uploader(); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); | 671 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); |
672 hello_world->data() = "hello world"; | 672 hello_world->data() = "hello world"; |
673 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( | 673 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( |
674 ComputeCrc32c(hello_world))); | 674 ComputeCrc32c(hello_world))); |
675 } | 675 } |
676 | 676 |
677 // TODO(maniscalco): Add test case for when we are uploading an attachment that | 677 // TODO(maniscalco): Add test case for when we are uploading an attachment that |
678 // already exists. 409 Conflict? (bug 379825) | 678 // already exists. 409 Conflict? (bug 379825) |
679 | 679 |
680 } // namespace syncer | 680 } // namespace syncer |
OLD | NEW |