OLD | NEW |
(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 |
OLD | NEW |