summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authormtomasz <mtomasz@chromium.org>2015-02-27 03:05:28 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-27 11:06:26 +0000
commit3315eb5fe7bcb9300995dae3326de2d2c5f3c44a (patch)
treeaee3ef0271ad1fddc7436f7df2c30e829d04a8a3 /google_apis
parenta0920dfe9bf0cbe0f1506a5294ee0900a7d0b5e9 (diff)
downloadchromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.zip
chromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.tar.gz
chromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.tar.bz2
Update Styx URLs for thumbnails and downloads in Files app.
This patch updates the URLs for Drive files to match the recent requirements. TBR=kinaba@chromium.org TEST=unit_tests: *DriveApiUrlGeneratorTest* BUG=None Review URL: https://codereview.chromium.org/831663009 Cr-Commit-Position: refs/heads/master@{#318432}
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/drive/drive_api_requests_unittest.cc6
-rw-r--r--google_apis/drive/drive_api_url_generator.cc55
-rw-r--r--google_apis/drive/drive_api_url_generator.h5
-rw-r--r--google_apis/drive/drive_api_url_generator_unittest.cc376
4 files changed, 144 insertions, 298 deletions
diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc
index 3f56e4e..1acbf2f 100644
--- a/google_apis/drive/drive_api_requests_unittest.cc
+++ b/google_apis/drive/drive_api_requests_unittest.cc
@@ -47,7 +47,7 @@ const char kTestPermissionResponse[] =
const char kTestUploadExistingFilePath[] = "/upload/existingfile/path";
const char kTestUploadNewFilePath[] = "/upload/newfile/path";
-const char kTestDownloadPathPrefix[] = "/download/";
+const char kTestDownloadPathPrefix[] = "/host/";
// Used as a GetContentCallback.
void AppendContent(std::string* out,
@@ -102,8 +102,8 @@ class DriveApiRequestsTest : public testing::Test {
base::Unretained(this)));
GURL test_base_url = test_util::GetBaseUrlForTesting(test_server_.port());
- url_generator_.reset(new DriveApiUrlGenerator(
- test_base_url, test_base_url.Resolve(kTestDownloadPathPrefix)));
+ url_generator_.reset(
+ new DriveApiUrlGenerator(test_base_url, test_base_url));
// Reset the server's expected behavior just in case.
ResetExpectedResponse();
diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc
index e35a3e7..285e754 100644
--- a/google_apis/drive/drive_api_url_generator.cc
+++ b/google_apis/drive/drive_api_url_generator.cc
@@ -16,29 +16,30 @@ namespace google_apis {
namespace {
// Hard coded URLs for communication with a google drive server.
-const char kDriveV2AboutUrl[] = "/drive/v2/about";
-const char kDriveV2AppsUrl[] = "/drive/v2/apps";
-const char kDriveV2ChangelistUrl[] = "/drive/v2/changes";
-const char kDriveV2FilesUrl[] = "/drive/v2/files";
-const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/";
-const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children";
+const char kDriveV2AboutUrl[] = "drive/v2/about";
+const char kDriveV2AppsUrl[] = "drive/v2/apps";
+const char kDriveV2ChangelistUrl[] = "drive/v2/changes";
+const char kDriveV2FilesUrl[] = "drive/v2/files";
+const char kDriveV2FileUrlPrefix[] = "drive/v2/files/";
+const char kDriveV2ChildrenUrlFormat[] = "drive/v2/files/%s/children";
const char kDriveV2ChildrenUrlForRemovalFormat[] =
- "/drive/v2/files/%s/children/%s";
-const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy";
-const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s";
-const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash";
-const char kDriveV2UploadNewFileUrl[] = "/upload/drive/v2/files";
-const char kDriveV2UploadExistingFileUrlPrefix[] =
- "/upload/drive/v2/files/";
-const char kDriveV2PermissionsUrlFormat[] = "/drive/v2/files/%s/permissions";
+ "drive/v2/files/%s/children/%s";
+const char kDriveV2FileCopyUrlFormat[] = "drive/v2/files/%s/copy";
+const char kDriveV2FileDeleteUrlFormat[] = "drive/v2/files/%s";
+const char kDriveV2FileTrashUrlFormat[] = "drive/v2/files/%s/trash";
+const char kDriveV2UploadNewFileUrl[] = "upload/drive/v2/files";
+const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/";
+const char kDriveV2PermissionsUrlFormat[] = "drive/v2/files/%s/permissions";
+const char kDriveV2DownloadUrlFormat[] = "host/%s";
+const char kDriveV2ThumbnailUrlFormat[] = "thumb/%s?width=%d&height=%d";
// apps.delete and file.authorize API is exposed through a special endpoint
// v2internal that is accessible only by the official API key for Chrome.
-const char kDriveV2InternalAppsUrl[] = "/drive/v2internal/apps";
-const char kDriveV2AppsDeleteUrlFormat[] = "/drive/v2internal/apps/%s";
+const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps";
+const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s";
const char kDriveV2FilesAuthorizeUrlFormat[] =
- "/drive/v2internal/files/%s/authorize?appId=%s";
-const char kDriveV2InternalFileUrlPrefix[] = "/drive/v2internal/files/";
+ "drive/v2internal/files/%s/authorize?appId=%s";
+const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/";
GURL AddResumableUploadParam(const GURL& url) {
return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable");
@@ -63,8 +64,13 @@ DriveApiUrlGenerator::~DriveApiUrlGenerator() {
const char DriveApiUrlGenerator::kBaseUrlForProduction[] =
"https://www.googleapis.com";
+
const char DriveApiUrlGenerator::kBaseDownloadUrlForProduction[] =
- "https://www.googledrive.com/host/";
+#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+ "https://www.googledrive.com/p/";
+#else
+ "https://www.googledrive.com";
+#endif
GURL DriveApiUrlGenerator::GetAboutGetUrl() const {
return base_url_.Resolve(kDriveV2AboutUrl);
@@ -263,7 +269,8 @@ GURL DriveApiUrlGenerator::GetMultipartUploadExistingFileUrl(
GURL DriveApiUrlGenerator::GenerateDownloadFileUrl(
const std::string& resource_id) const {
- return base_download_url_.Resolve(net::EscapePath(resource_id));
+ return base_download_url_.Resolve(base::StringPrintf(
+ kDriveV2DownloadUrlFormat, net::EscapePath(resource_id).c_str()));
}
GURL DriveApiUrlGenerator::GetPermissionsInsertUrl(
@@ -273,4 +280,12 @@ GURL DriveApiUrlGenerator::GetPermissionsInsertUrl(
net::EscapePath(resource_id).c_str()));
}
+GURL DriveApiUrlGenerator::GetThumbnailUrl(const std::string& resource_id,
+ int width,
+ int height) const {
+ return base_download_url_.Resolve(
+ base::StringPrintf(kDriveV2ThumbnailUrlFormat,
+ net::EscapePath(resource_id).c_str(), width, height));
+}
+
} // namespace google_apis
diff --git a/google_apis/drive/drive_api_url_generator.h b/google_apis/drive/drive_api_url_generator.h
index cbac795..ab623e3 100644
--- a/google_apis/drive/drive_api_url_generator.h
+++ b/google_apis/drive/drive_api_url_generator.h
@@ -107,6 +107,11 @@ class DriveApiUrlGenerator {
// Generates a URL for adding permissions.
GURL GetPermissionsInsertUrl(const std::string& resource_id) const;
+ // Generates a URL for a thumbnail with specified dimensions.
+ GURL GetThumbnailUrl(const std::string& resource_id,
+ int width,
+ int height) const;
+
private:
const GURL base_url_;
const GURL base_download_url_;
diff --git a/google_apis/drive/drive_api_url_generator_unittest.cc b/google_apis/drive/drive_api_url_generator_unittest.cc
index b00a524..03e4c02 100644
--- a/google_apis/drive/drive_api_url_generator_unittest.cc
+++ b/google_apis/drive/drive_api_url_generator_unittest.cc
@@ -10,108 +10,80 @@
#include "url/url_util.h"
namespace google_apis {
+namespace {
+// The URLs used for production may be different for Chromium OS and Chrome
+// OS, so use testing base urls.
+const char kBaseUrlForTesting[] = "https://www.example.com";
+const char kBaseDownloadUrlForTesting[] = "https://download.example.com/p/";
+} // namespace
class DriveApiUrlGeneratorTest : public testing::Test {
public:
DriveApiUrlGeneratorTest()
- : url_generator_(
- GURL(DriveApiUrlGenerator::kBaseUrlForProduction),
- GURL(DriveApiUrlGenerator::kBaseDownloadUrlForProduction)),
- test_url_generator_(
- test_util::GetBaseUrlForTesting(12345),
- test_util::GetBaseUrlForTesting(12345).Resolve("download/")) {
- }
+ : url_generator_(GURL(kBaseUrlForTesting),
+ GURL(kBaseDownloadUrlForTesting)) {}
protected:
DriveApiUrlGenerator url_generator_;
- DriveApiUrlGenerator test_url_generator_;
};
// Make sure the hard-coded urls are returned.
TEST_F(DriveApiUrlGeneratorTest, GetAboutGetUrl) {
- EXPECT_EQ("https://www.googleapis.com/drive/v2/about",
+ EXPECT_EQ("https://www.example.com/drive/v2/about",
url_generator_.GetAboutGetUrl().spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/about",
- test_url_generator_.GetAboutGetUrl().spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetAppsListUrl) {
const bool use_internal_url = true;
- EXPECT_EQ("https://www.googleapis.com/drive/v2internal/apps",
+ EXPECT_EQ("https://www.example.com/drive/v2internal/apps",
url_generator_.GetAppsListUrl(use_internal_url).spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/apps",
+ EXPECT_EQ("https://www.example.com/drive/v2/apps",
url_generator_.GetAppsListUrl(!use_internal_url).spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/apps",
- test_url_generator_.GetAppsListUrl(!use_internal_url).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetAppsDeleteUrl) {
- EXPECT_EQ("https://www.googleapis.com/drive/v2internal/apps/0ADK06pfg",
+ EXPECT_EQ("https://www.example.com/drive/v2internal/apps/0ADK06pfg",
url_generator_.GetAppsDeleteUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2internal/apps/0ADK06pfg",
- test_url_generator_.GetAppsDeleteUrl("0ADK06pfg").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesGetUrl) {
// |file_id| should be embedded into the url.
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg",
+ url_generator_.GetFilesGetUrl("0ADK06pfg", false, GURL()).spec());
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0Bz0bd074",
+ url_generator_.GetFilesGetUrl("0Bz0bd074", false, GURL()).spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0ADK06pfg",
- url_generator_.GetFilesGetUrl("0ADK06pfg", false, GURL()).spec());
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0Bz0bd074",
- url_generator_.GetFilesGetUrl("0Bz0bd074", false, GURL()).spec());
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/file%3Afile_id",
+ "https://www.example.com/drive/v2/files/file%3Afile_id",
url_generator_.GetFilesGetUrl("file:file_id", false, GURL()).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0ADK06pfg",
- test_url_generator_.GetFilesGetUrl("0ADK06pfg", false, GURL()).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0Bz0bd074",
- test_url_generator_.GetFilesGetUrl("0Bz0bd074", false, GURL()).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/file%3Afile_id",
- test_url_generator_.GetFilesGetUrl("file:file_id", false, GURL()).spec());
-
// If |use_internal_endpoint| is true, the generated url should point to the
// v2internal.
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2internal/files/0ADK06pfg",
- url_generator_.GetFilesGetUrl("0ADK06pfg", true, GURL()).spec());
+ EXPECT_EQ("https://www.example.com/drive/v2internal/files/0ADK06pfg",
+ url_generator_.GetFilesGetUrl("0ADK06pfg", true, GURL()).spec());
// If |embed_origin| is not empty, it should be added as a query parameter.
url::AddStandardScheme("chrome-extension");
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0ADK06pfg"
+ "https://www.example.com/drive/v2/files/0ADK06pfg"
"?embedOrigin=chrome-extension%3A%2F%2Ftest",
- url_generator_.GetFilesGetUrl(
- "0ADK06pfg",
- false,
- GURL("chrome-extension://test")).spec());
+ url_generator_.GetFilesGetUrl("0ADK06pfg", false,
+ GURL("chrome-extension://test")).spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2internal/files/0ADK06pfg"
+ "https://www.example.com/drive/v2internal/files/0ADK06pfg"
"?embedOrigin=chrome-extension%3A%2F%2Ftest",
- url_generator_.GetFilesGetUrl(
- "0ADK06pfg",
- true,
- GURL("chrome-extension://test")).spec());
+ url_generator_.GetFilesGetUrl("0ADK06pfg", true,
+ GURL("chrome-extension://test")).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesAuthorizeUrl) {
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2internal/files/aa/authorize?appId=bb",
- url_generator_.GetFilesAuthorizeUrl("aa", "bb").spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2internal/files/foo/authorize?appId=bar",
- test_url_generator_.GetFilesAuthorizeUrl("foo", "bar").spec());
+ "https://www.example.com/drive/v2internal/files/aa/authorize?appId=bb",
+ url_generator_.GetFilesAuthorizeUrl("aa", "bb").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesInsertUrl) {
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files",
+ EXPECT_EQ("https://www.example.com/drive/v2/files",
url_generator_.GetFilesInsertUrl().spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files",
- test_url_generator_.GetFilesInsertUrl().spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilePatchUrl) {
@@ -129,71 +101,36 @@ TEST_F(DriveApiUrlGeneratorTest, GetFilePatchUrl) {
for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0ADK06pfg" +
+ "https://www.example.com/drive/v2/files/0ADK06pfg" +
kTestPatterns[i].expected_query,
url_generator_.GetFilesPatchUrl(
- "0ADK06pfg",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
+ "0ADK06pfg", kTestPatterns[i].set_modified_date,
+ kTestPatterns[i].update_viewed_date).spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0Bz0bd074" +
+ "https://www.example.com/drive/v2/files/0Bz0bd074" +
kTestPatterns[i].expected_query,
url_generator_.GetFilesPatchUrl(
- "0Bz0bd074",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
+ "0Bz0bd074", kTestPatterns[i].set_modified_date,
+ kTestPatterns[i].update_viewed_date).spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/file%3Afile_id" +
+ "https://www.example.com/drive/v2/files/file%3Afile_id" +
kTestPatterns[i].expected_query,
url_generator_.GetFilesPatchUrl(
- "file:file_id",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
-
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0ADK06pfg" +
- kTestPatterns[i].expected_query,
- test_url_generator_.GetFilesPatchUrl(
- "0ADK06pfg",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0Bz0bd074" +
- kTestPatterns[i].expected_query,
- test_url_generator_.GetFilesPatchUrl(
- "0Bz0bd074",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/file%3Afile_id" +
- kTestPatterns[i].expected_query,
- test_url_generator_.GetFilesPatchUrl(
- "file:file_id",
- kTestPatterns[i].set_modified_date,
- kTestPatterns[i].update_viewed_date).spec());
+ "file:file_id", kTestPatterns[i].set_modified_date,
+ kTestPatterns[i].update_viewed_date).spec());
}
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesCopyUrl) {
// |file_id| should be embedded into the url.
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/copy",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/copy",
url_generator_.GetFilesCopyUrl("0ADK06pfg").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074/copy",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0Bz0bd074/copy",
url_generator_.GetFilesCopyUrl("0Bz0bd074").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id/copy",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/file%3Afile_id/copy",
url_generator_.GetFilesCopyUrl("file:file_id").spec());
-
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/copy",
- test_url_generator_.GetFilesCopyUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/copy",
- test_url_generator_.GetFilesCopyUrl("0Bz0bd074").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afile_id/copy",
- test_url_generator_.GetFilesCopyUrl("file:file_id").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesListUrl) {
@@ -219,54 +156,32 @@ TEST_F(DriveApiUrlGeneratorTest, GetFilesListUrl) {
};
for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files" +
- kTestPatterns[i].expected_query,
- url_generator_.GetFilesListUrl(
- kTestPatterns[i].max_results, kTestPatterns[i].page_token,
- kTestPatterns[i].q).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files" +
- kTestPatterns[i].expected_query,
- test_url_generator_.GetFilesListUrl(
- kTestPatterns[i].max_results, kTestPatterns[i].page_token,
- kTestPatterns[i].q).spec());
+ EXPECT_EQ("https://www.example.com/drive/v2/files" +
+ kTestPatterns[i].expected_query,
+ url_generator_.GetFilesListUrl(kTestPatterns[i].max_results,
+ kTestPatterns[i].page_token,
+ kTestPatterns[i].q).spec());
}
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesDeleteUrl) {
// |file_id| should be embedded into the url.
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg",
url_generator_.GetFilesDeleteUrl("0ADK06pfg").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0Bz0bd074",
url_generator_.GetFilesDeleteUrl("0Bz0bd074").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/file%3Afile_id",
url_generator_.GetFilesDeleteUrl("file:file_id").spec());
-
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg",
- test_url_generator_.GetFilesDeleteUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074",
- test_url_generator_.GetFilesDeleteUrl("0Bz0bd074").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afile_id",
- test_url_generator_.GetFilesDeleteUrl("file:file_id").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetFilesTrashUrl) {
// |file_id| should be embedded into the url.
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/trash",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/trash",
url_generator_.GetFilesTrashUrl("0ADK06pfg").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074/trash",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0Bz0bd074/trash",
url_generator_.GetFilesTrashUrl("0Bz0bd074").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id/trash",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/file%3Afile_id/trash",
url_generator_.GetFilesTrashUrl("file:file_id").spec());
-
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/trash",
- test_url_generator_.GetFilesTrashUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/trash",
- test_url_generator_.GetFilesTrashUrl("0Bz0bd074").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afile_id/trash",
- test_url_generator_.GetFilesTrashUrl("file:file_id").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetChangesListUrl) {
@@ -319,90 +234,51 @@ TEST_F(DriveApiUrlGeneratorTest, GetChangesListUrl) {
};
for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/changes" +
- kTestPatterns[i].expected_query,
- url_generator_.GetChangesListUrl(
- kTestPatterns[i].include_deleted,
- kTestPatterns[i].max_results,
- kTestPatterns[i].page_token,
- kTestPatterns[i].start_change_id).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/changes" +
- kTestPatterns[i].expected_query,
- test_url_generator_.GetChangesListUrl(
- kTestPatterns[i].include_deleted,
- kTestPatterns[i].max_results,
- kTestPatterns[i].page_token,
- kTestPatterns[i].start_change_id).spec());
+ EXPECT_EQ("https://www.example.com/drive/v2/changes" +
+ kTestPatterns[i].expected_query,
+ url_generator_.GetChangesListUrl(kTestPatterns[i].include_deleted,
+ kTestPatterns[i].max_results,
+ kTestPatterns[i].page_token,
+ kTestPatterns[i].start_change_id)
+ .spec());
}
}
TEST_F(DriveApiUrlGeneratorTest, GetChildrenInsertUrl) {
// |file_id| should be embedded into the url.
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/children",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/children",
url_generator_.GetChildrenInsertUrl("0ADK06pfg").spec());
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074/children",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0Bz0bd074/children",
url_generator_.GetChildrenInsertUrl("0Bz0bd074").spec());
- EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/file%3Afolder_id/children",
- url_generator_.GetChildrenInsertUrl("file:folder_id").spec());
-
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/children",
- test_url_generator_.GetChildrenInsertUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/children",
- test_url_generator_.GetChildrenInsertUrl("0Bz0bd074").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afolder_id/children",
- test_url_generator_.GetChildrenInsertUrl("file:folder_id").spec());
+ EXPECT_EQ("https://www.example.com/drive/v2/files/file%3Afolder_id/children",
+ url_generator_.GetChildrenInsertUrl("file:folder_id").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetChildrenDeleteUrl) {
// |file_id| should be embedded into the url.
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0ADK06pfg/children/0Bz0bd074",
+ "https://www.example.com/drive/v2/files/0ADK06pfg/children/0Bz0bd074",
url_generator_.GetChildrenDeleteUrl("0Bz0bd074", "0ADK06pfg").spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/0Bz0bd074/children/0ADK06pfg",
+ "https://www.example.com/drive/v2/files/0Bz0bd074/children/0ADK06pfg",
url_generator_.GetChildrenDeleteUrl("0ADK06pfg", "0Bz0bd074").spec());
EXPECT_EQ(
- "https://www.googleapis.com/drive/v2/files/file%3Afolder_id/children"
+ "https://www.example.com/drive/v2/files/file%3Afolder_id/children"
"/file%3Achild_id",
- url_generator_.GetChildrenDeleteUrl(
- "file:child_id", "file:folder_id").spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/children/0Bz0bd074",
- test_url_generator_.GetChildrenDeleteUrl(
- "0Bz0bd074", "0ADK06pfg").spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/children/0ADK06pfg",
- test_url_generator_.GetChildrenDeleteUrl(
- "0ADK06pfg", "0Bz0bd074").spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/drive/v2/files/file%3Afolder_id/children/"
- "file%3Achild_id",
- test_url_generator_.GetChildrenDeleteUrl(
- "file:child_id", "file:folder_id").spec());
+ url_generator_.GetChildrenDeleteUrl("file:child_id", "file:folder_id")
+ .spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetInitiateUploadNewFileUrl) {
const bool kSetModifiedDate = true;
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable",
+ "https://www.example.com/upload/drive/v2/files?uploadType=resumable",
url_generator_.GetInitiateUploadNewFileUrl(!kSetModifiedDate).spec());
-
EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=resumable",
- test_url_generator_.GetInitiateUploadNewFileUrl(
- !kSetModifiedDate).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=resumable&"
+ "https://www.example.com/upload/drive/v2/files?uploadType=resumable&"
"setModifiedDate=true",
- test_url_generator_.GetInitiateUploadNewFileUrl(
- kSetModifiedDate).spec());
+ url_generator_.GetInitiateUploadNewFileUrl(kSetModifiedDate).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetInitiateUploadExistingFileUrl) {
@@ -410,65 +286,37 @@ TEST_F(DriveApiUrlGeneratorTest, GetInitiateUploadExistingFileUrl) {
// |resource_id| should be embedded into the url.
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/0ADK06pfg"
+ "https://www.example.com/upload/drive/v2/files/0ADK06pfg"
"?uploadType=resumable",
url_generator_.GetInitiateUploadExistingFileUrl(
- "0ADK06pfg", !kSetModifiedDate).spec());
+ "0ADK06pfg", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/0Bz0bd074"
+ "https://www.example.com/upload/drive/v2/files/0Bz0bd074"
"?uploadType=resumable",
url_generator_.GetInitiateUploadExistingFileUrl(
- "0Bz0bd074", !kSetModifiedDate).spec());
+ "0Bz0bd074", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/file%3Afile_id"
+ "https://www.example.com/upload/drive/v2/files/file%3Afile_id"
"?uploadType=resumable",
url_generator_.GetInitiateUploadExistingFileUrl(
- "file:file_id", !kSetModifiedDate).spec());
+ "file:file_id", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/file%3Afile_id"
+ "https://www.example.com/upload/drive/v2/files/file%3Afile_id"
"?uploadType=resumable&setModifiedDate=true",
- url_generator_.GetInitiateUploadExistingFileUrl(
- "file:file_id", kSetModifiedDate).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/0ADK06pfg"
- "?uploadType=resumable",
- test_url_generator_.GetInitiateUploadExistingFileUrl(
- "0ADK06pfg", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/0Bz0bd074"
- "?uploadType=resumable",
- test_url_generator_.GetInitiateUploadExistingFileUrl(
- "0Bz0bd074", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/file%3Afile_id"
- "?uploadType=resumable",
- test_url_generator_.GetInitiateUploadExistingFileUrl(
- "file:file_id", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/file%3Afile_id"
- "?uploadType=resumable&setModifiedDate=true",
- test_url_generator_.GetInitiateUploadExistingFileUrl(
- "file:file_id", kSetModifiedDate).spec());
+ url_generator_.GetInitiateUploadExistingFileUrl("file:file_id",
+ kSetModifiedDate).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetMultipartUploadNewFileUrl) {
const bool kSetModifiedDate = true;
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart",
+ "https://www.example.com/upload/drive/v2/files?uploadType=multipart",
url_generator_.GetMultipartUploadNewFileUrl(!kSetModifiedDate).spec());
-
EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=multipart",
- test_url_generator_.GetMultipartUploadNewFileUrl(
- !kSetModifiedDate).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=multipart&"
+ "https://www.example.com/upload/drive/v2/files?uploadType=multipart&"
"setModifiedDate=true",
- test_url_generator_.GetMultipartUploadNewFileUrl(
- kSetModifiedDate).spec());
+ url_generator_.GetMultipartUploadNewFileUrl(kSetModifiedDate).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GetMultipartUploadExistingFileUrl) {
@@ -476,65 +324,43 @@ TEST_F(DriveApiUrlGeneratorTest, GetMultipartUploadExistingFileUrl) {
// |resource_id| should be embedded into the url.
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/0ADK06pfg"
+ "https://www.example.com/upload/drive/v2/files/0ADK06pfg"
"?uploadType=multipart",
url_generator_.GetMultipartUploadExistingFileUrl(
- "0ADK06pfg", !kSetModifiedDate).spec());
+ "0ADK06pfg", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/0Bz0bd074"
+ "https://www.example.com/upload/drive/v2/files/0Bz0bd074"
"?uploadType=multipart",
url_generator_.GetMultipartUploadExistingFileUrl(
- "0Bz0bd074", !kSetModifiedDate).spec());
+ "0Bz0bd074", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/file%3Afile_id"
+ "https://www.example.com/upload/drive/v2/files/file%3Afile_id"
"?uploadType=multipart",
url_generator_.GetMultipartUploadExistingFileUrl(
- "file:file_id", !kSetModifiedDate).spec());
+ "file:file_id", !kSetModifiedDate).spec());
EXPECT_EQ(
- "https://www.googleapis.com/upload/drive/v2/files/file%3Afile_id"
+ "https://www.example.com/upload/drive/v2/files/file%3Afile_id"
"?uploadType=multipart&setModifiedDate=true",
url_generator_.GetMultipartUploadExistingFileUrl(
- "file:file_id", kSetModifiedDate).spec());
-
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/0ADK06pfg"
- "?uploadType=multipart",
- test_url_generator_.GetMultipartUploadExistingFileUrl(
- "0ADK06pfg", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/0Bz0bd074"
- "?uploadType=multipart",
- test_url_generator_.GetMultipartUploadExistingFileUrl(
- "0Bz0bd074", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/file%3Afile_id"
- "?uploadType=multipart",
- test_url_generator_.GetMultipartUploadExistingFileUrl(
- "file:file_id", !kSetModifiedDate).spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/upload/drive/v2/files/file%3Afile_id"
- "?uploadType=multipart&setModifiedDate=true",
- test_url_generator_.GetMultipartUploadExistingFileUrl(
- "file:file_id", kSetModifiedDate).spec());
+ "file:file_id", kSetModifiedDate).spec());
}
TEST_F(DriveApiUrlGeneratorTest, GenerateDownloadFileUrl) {
- EXPECT_EQ(
- "https://www.googledrive.com/host/resourceId",
- url_generator_.GenerateDownloadFileUrl("resourceId").spec());
- EXPECT_EQ(
- "https://www.googledrive.com/host/file%3AresourceId",
- url_generator_.GenerateDownloadFileUrl("file:resourceId").spec());
- EXPECT_EQ(
- "http://127.0.0.1:12345/download/resourceId",
- test_url_generator_.GenerateDownloadFileUrl("resourceId").spec());
+ EXPECT_EQ("https://download.example.com/p/host/resourceId",
+ url_generator_.GenerateDownloadFileUrl("resourceId").spec());
+ EXPECT_EQ("https://download.example.com/p/host/file%3AresourceId",
+ url_generator_.GenerateDownloadFileUrl("file:resourceId").spec());
}
TEST_F(DriveApiUrlGeneratorTest, GeneratePermissionsInsertUrl) {
- EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/permissions",
+ EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/permissions",
url_generator_.GetPermissionsInsertUrl("0ADK06pfg").spec());
- EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Aabc/permissions",
- test_url_generator_.GetPermissionsInsertUrl("file:abc").spec());
+}
+
+TEST_F(DriveApiUrlGeneratorTest, GenerateThumbnailUrl) {
+ EXPECT_EQ(
+ "https://download.example.com/p/thumb/0ADK06pfg?width=500&height=500",
+ url_generator_.GetThumbnailUrl("0ADK06pfg", 500, 500).spec());
}
} // namespace google_apis