Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sync/internal_api/attachments/attachment_server_url_builder_unittest.cc

Issue 278263003: Add a minimal AttachmentUploaderImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up after self-review. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/internal_api/public/attachments/attachment_server_url_builder.h"
6
7 #include "sync/api/attachments/attachment_id.h"
8 #include "sync/protocol/sync.pb.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h"
11
12 namespace syncer {
13
14 // The test cases below hard-code parts of the path and may need to be updated
15 // when the path used by AttachmentServerURLBuilder changes.
16 class AttachmentServerURLBuilderTest : public testing::Test {};
17
18 // Verify we can build an HTTPS URL.
19 TEST_F(AttachmentServerURLBuilderTest, BuildUploadURLFor_SCHEME_HTTPS) {
20 std::string host("www.example.com");
21 int port = 8080;
22 AttachmentServerURLBuilder builder(
23 AttachmentServerURLBuilder::SCHEME_HTTPS, host, port);
24 sync_pb::AttachmentIdProto proto;
25 *proto.mutable_unique_id() = "someattachmentid";
26 AttachmentId id = AttachmentId::CreateFromProto(proto);
27 GURL url = builder.BuildUploadURLFor(id);
28 EXPECT_EQ("https://www.example.com:8080/uploads/someattachmentid",
29 url.spec());
30 }
31
32 // Verify we can build an HTTP URL.
33 TEST_F(AttachmentServerURLBuilderTest, BuildUploadURLFor_SCHEME_HTTP) {
34 std::string host("localhost");
35 int port = 12345;
36 AttachmentServerURLBuilder builder(
37 AttachmentServerURLBuilder::SCHEME_HTTP, host, port);
38 sync_pb::AttachmentIdProto proto;
39 *proto.mutable_unique_id() = "someotherattachmentid";
40 AttachmentId id = AttachmentId::CreateFromProto(proto);
41 GURL url = builder.BuildUploadURLFor(id);
42 EXPECT_EQ("http://localhost:12345/uploads/someotherattachmentid", url.spec());
43 }
44
45 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698