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

Unified Diff: sync/internal_api/attachments/attachment_uploader_impl_unittest.cc

Issue 356953009: Revert of Consolidate attachment URL construction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_uploader_impl_unittest.cc
diff --git a/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc b/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc
index 90cb07db99d8f1dbeeee72a6eec68e3ced1036ed..3e3c67e1ecee4f91634fed2f5b0af6d47cab0937 100644
--- a/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc
+++ b/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc
@@ -33,7 +33,6 @@
const char kAccountId[] = "some-account-id";
const char kAccessToken[] = "some-access-token";
const char kAuthorization[] = "Authorization";
-const char kAttachments[] = "/attachments/";
} // namespace
@@ -265,7 +264,8 @@
base::Bind(&RequestHandler::HandleRequest,
base::Unretained(request_handler_.get())));
- GURL url(base::StringPrintf("http://localhost:%d/", server_.port()));
+ std::string url_prefix(
+ base::StringPrintf("http://localhost:%d/uploads/", server_.port()));
token_service_.reset(new MockOAuth2TokenService);
scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider>
@@ -273,7 +273,7 @@
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
- uploader().reset(new AttachmentUploaderImpl(url,
+ uploader().reset(new AttachmentUploaderImpl(url_prefix,
url_request_context_getter_,
kAccountId,
scopes,
@@ -377,42 +377,6 @@
return status_code_;
}
-TEST_F(AttachmentUploaderImplTest, GetURLForAttachmentId_NoPath) {
- AttachmentId id = AttachmentId::Create();
- std::string unique_id = id.GetProto().unique_id();
- GURL sync_service_url("https://example.com");
- EXPECT_EQ("https://example.com/attachments/" + unique_id,
- AttachmentUploaderImpl::GetURLForAttachmentId(sync_service_url, id)
- .spec());
-}
-
-TEST_F(AttachmentUploaderImplTest, GetURLForAttachmentId_JustSlash) {
- AttachmentId id = AttachmentId::Create();
- std::string unique_id = id.GetProto().unique_id();
- GURL sync_service_url("https://example.com/");
- EXPECT_EQ("https://example.com/attachments/" + unique_id,
- AttachmentUploaderImpl::GetURLForAttachmentId(sync_service_url, id)
- .spec());
-}
-
-TEST_F(AttachmentUploaderImplTest, GetURLForAttachmentId_Path) {
- AttachmentId id = AttachmentId::Create();
- std::string unique_id = id.GetProto().unique_id();
- GURL sync_service_url("https://example.com/service");
- EXPECT_EQ("https://example.com/service/attachments/" + unique_id,
- AttachmentUploaderImpl::GetURLForAttachmentId(sync_service_url, id)
- .spec());
-}
-
-TEST_F(AttachmentUploaderImplTest, GetURLForAttachmentId_PathAndSlash) {
- AttachmentId id = AttachmentId::Create();
- std::string unique_id = id.GetProto().unique_id();
- GURL sync_service_url("https://example.com/service/");
- EXPECT_EQ("https://example.com/service/attachments/" + unique_id,
- AttachmentUploaderImpl::GetURLForAttachmentId(sync_service_url, id)
- .spec());
-}
-
// Verify the "happy case" of uploading an attachment.
//
// Token is requested, token is returned, HTTP request is made, attachment is
@@ -439,7 +403,7 @@
ASSERT_EQ(1U, http_requests_received().size());
const HttpRequest& http_request = http_requests_received().front();
EXPECT_EQ(net::test_server::METHOD_POST, http_request.method);
- std::string expected_relative_url(kAttachments +
+ std::string expected_relative_url("/uploads/" +
attachment.GetId().GetProto().unique_id());
EXPECT_EQ(expected_relative_url, http_request.relative_url);
EXPECT_TRUE(http_request.has_content);
@@ -542,7 +506,7 @@
ASSERT_EQ(1U, http_requests_received().size());
const HttpRequest& http_request = http_requests_received().front();
EXPECT_EQ(net::test_server::METHOD_POST, http_request.method);
- std::string expected_relative_url(kAttachments +
+ std::string expected_relative_url("/uploads/" +
attachment.GetId().GetProto().unique_id());
EXPECT_EQ(expected_relative_url, http_request.relative_url);
EXPECT_TRUE(http_request.has_content);
@@ -580,7 +544,7 @@
ASSERT_EQ(1U, http_requests_received().size());
const HttpRequest& http_request = http_requests_received().front();
EXPECT_EQ(net::test_server::METHOD_POST, http_request.method);
- std::string expected_relative_url(kAttachments +
+ std::string expected_relative_url("/uploads/" +
attachment.GetId().GetProto().unique_id());
EXPECT_EQ(expected_relative_url, http_request.relative_url);
EXPECT_TRUE(http_request.has_content);

Powered by Google App Engine
This is Rietveld 408576698