| Index: sync/internal_api/attachments/attachment_server_url_builder_unittest.cc
|
| diff --git a/sync/internal_api/attachments/attachment_server_url_builder_unittest.cc b/sync/internal_api/attachments/attachment_server_url_builder_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e7210c988105adce47c33a7496de707959b097ef
|
| --- /dev/null
|
| +++ b/sync/internal_api/attachments/attachment_server_url_builder_unittest.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "sync/internal_api/public/attachments/attachment_server_url_builder.h"
|
| +
|
| +#include "sync/api/attachments/attachment_id.h"
|
| +#include "sync/protocol/sync.pb.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace syncer {
|
| +
|
| +// The test cases below hard-code parts of the path and may need to be updated
|
| +// when the path used by AttachmentServerURLBuilder changes.
|
| +class AttachmentServerURLBuilderTest : public testing::Test {};
|
| +
|
| +// Verify we can build an HTTPS URL.
|
| +TEST_F(AttachmentServerURLBuilderTest, BuildUploadURLFor_SCHEME_HTTPS) {
|
| + std::string host("www.example.com");
|
| + int port = 8080;
|
| + AttachmentServerURLBuilder builder(
|
| + AttachmentServerURLBuilder::SCHEME_HTTPS, host, port);
|
| + sync_pb::AttachmentIdProto proto;
|
| + *proto.mutable_unique_id() = "someattachmentid";
|
| + AttachmentId id = AttachmentId::CreateFromProto(proto);
|
| + GURL url = builder.BuildUploadURLFor(id);
|
| + EXPECT_EQ("https://www.example.com:8080/uploads/someattachmentid",
|
| + url.spec());
|
| +}
|
| +
|
| +// Verify we can build an HTTP URL.
|
| +TEST_F(AttachmentServerURLBuilderTest, BuildUploadURLFor_SCHEME_HTTP) {
|
| + std::string host("localhost");
|
| + int port = 12345;
|
| + AttachmentServerURLBuilder builder(
|
| + AttachmentServerURLBuilder::SCHEME_HTTP, host, port);
|
| + sync_pb::AttachmentIdProto proto;
|
| + *proto.mutable_unique_id() = "someotherattachmentid";
|
| + AttachmentId id = AttachmentId::CreateFromProto(proto);
|
| + GURL url = builder.BuildUploadURLFor(id);
|
| + EXPECT_EQ("http://localhost:12345/uploads/someotherattachmentid", url.spec());
|
| +}
|
| +
|
| +} // namespace syncer
|
|
|