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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698