| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/drive/drive_api_url_generator.h" | 5 #include "google_apis/drive/drive_api_url_generator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "google_apis/drive/test_util.h" | 11 #include "google_apis/drive/test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 #include "url/url_util.h" | 14 #include "url/url_util.h" |
| 15 | 15 |
| 16 namespace google_apis { | 16 namespace google_apis { |
| 17 namespace { | 17 namespace { |
| 18 // The URLs used for production may be different for Chromium OS and Chrome | 18 // The URLs used for production may be different for Chromium OS and Chrome |
| 19 // OS, so use testing base urls. | 19 // OS, so use testing base urls. |
| 20 const char kBaseUrlForTesting[] = "https://www.example.com"; | 20 const char kBaseUrlForTesting[] = "https://www.example.com"; |
| 21 const char kBaseDownloadUrlForTesting[] = "https://download.example.com/p/"; | |
| 22 const char kBaseThumbnailUrlForTesting[] = "https://thumbnail.example.com"; | 21 const char kBaseThumbnailUrlForTesting[] = "https://thumbnail.example.com"; |
| 23 } // namespace | 22 } // namespace |
| 24 | 23 |
| 25 class DriveApiUrlGeneratorTest : public testing::Test { | 24 class DriveApiUrlGeneratorTest : public testing::Test { |
| 26 public: | 25 public: |
| 27 DriveApiUrlGeneratorTest() | 26 DriveApiUrlGeneratorTest() |
| 28 : url_generator_(GURL(kBaseUrlForTesting), | 27 : url_generator_(GURL(kBaseUrlForTesting), |
| 29 GURL(kBaseDownloadUrlForTesting), | |
| 30 GURL(kBaseThumbnailUrlForTesting)) {} | 28 GURL(kBaseThumbnailUrlForTesting)) {} |
| 31 | 29 |
| 32 protected: | 30 protected: |
| 33 DriveApiUrlGenerator url_generator_; | 31 DriveApiUrlGenerator url_generator_; |
| 34 }; | 32 }; |
| 35 | 33 |
| 36 // Make sure the hard-coded urls are returned. | 34 // Make sure the hard-coded urls are returned. |
| 37 TEST_F(DriveApiUrlGeneratorTest, GetAboutGetUrl) { | 35 TEST_F(DriveApiUrlGeneratorTest, GetAboutGetUrl) { |
| 38 EXPECT_EQ("https://www.example.com/drive/v2/about", | 36 EXPECT_EQ("https://www.example.com/drive/v2/about", |
| 39 url_generator_.GetAboutGetUrl().spec()); | 37 url_generator_.GetAboutGetUrl().spec()); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 url_generator_.GetMultipartUploadExistingFileUrl( | 353 url_generator_.GetMultipartUploadExistingFileUrl( |
| 356 "file:file_id", !kSetModifiedDate).spec()); | 354 "file:file_id", !kSetModifiedDate).spec()); |
| 357 EXPECT_EQ( | 355 EXPECT_EQ( |
| 358 "https://www.example.com/upload/drive/v2/files/file%3Afile_id" | 356 "https://www.example.com/upload/drive/v2/files/file%3Afile_id" |
| 359 "?uploadType=multipart&setModifiedDate=true", | 357 "?uploadType=multipart&setModifiedDate=true", |
| 360 url_generator_.GetMultipartUploadExistingFileUrl( | 358 url_generator_.GetMultipartUploadExistingFileUrl( |
| 361 "file:file_id", kSetModifiedDate).spec()); | 359 "file:file_id", kSetModifiedDate).spec()); |
| 362 } | 360 } |
| 363 | 361 |
| 364 TEST_F(DriveApiUrlGeneratorTest, GenerateDownloadFileUrl) { | 362 TEST_F(DriveApiUrlGeneratorTest, GenerateDownloadFileUrl) { |
| 365 EXPECT_EQ("https://download.example.com/p/host/resourceId", | 363 EXPECT_EQ( |
| 366 url_generator_.GenerateDownloadFileUrl("resourceId").spec()); | 364 "https://www.example.com/drive/v2/files/resourceId?alt=media", |
| 367 EXPECT_EQ("https://download.example.com/p/host/file%3AresourceId", | 365 url_generator_.GenerateDownloadFileUrl("resourceId").spec()); |
| 368 url_generator_.GenerateDownloadFileUrl("file:resourceId").spec()); | 366 EXPECT_EQ( |
| 367 "https://www.example.com/drive/v2/files/file%3AresourceId?alt=media", |
| 368 url_generator_.GenerateDownloadFileUrl("file:resourceId").spec()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 TEST_F(DriveApiUrlGeneratorTest, GeneratePermissionsInsertUrl) { | 371 TEST_F(DriveApiUrlGeneratorTest, GeneratePermissionsInsertUrl) { |
| 372 EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/permissions", | 372 EXPECT_EQ("https://www.example.com/drive/v2/files/0ADK06pfg/permissions", |
| 373 url_generator_.GetPermissionsInsertUrl("0ADK06pfg").spec()); | 373 url_generator_.GetPermissionsInsertUrl("0ADK06pfg").spec()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(DriveApiUrlGeneratorTest, GenerateThumbnailUrl) { | 376 TEST_F(DriveApiUrlGeneratorTest, GenerateThumbnailUrl) { |
| 377 EXPECT_EQ( | 377 EXPECT_EQ( |
| 378 "https://thumbnail.example.com/d/0ADK06pfg=w500-h480", | 378 "https://thumbnail.example.com/d/0ADK06pfg=w500-h480", |
| 379 url_generator_.GetThumbnailUrl("0ADK06pfg", 500, 480, false).spec()); | 379 url_generator_.GetThumbnailUrl("0ADK06pfg", 500, 480, false).spec()); |
| 380 | 380 |
| 381 EXPECT_EQ( | 381 EXPECT_EQ( |
| 382 "https://thumbnail.example.com/d/0ADK06pfg=w360-h380-c", | 382 "https://thumbnail.example.com/d/0ADK06pfg=w360-h380-c", |
| 383 url_generator_.GetThumbnailUrl("0ADK06pfg", 360, 380, true).spec()); | 383 url_generator_.GetThumbnailUrl("0ADK06pfg", 360, 380, true).spec()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 TEST_F(DriveApiUrlGeneratorTest, BatchUploadUrl) { | 386 TEST_F(DriveApiUrlGeneratorTest, BatchUploadUrl) { |
| 387 EXPECT_EQ("https://www.example.com/upload/drive", | 387 EXPECT_EQ("https://www.example.com/upload/drive", |
| 388 url_generator_.GetBatchUploadUrl().spec()); | 388 url_generator_.GetBatchUploadUrl().spec()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace google_apis | 391 } // namespace google_apis |
| OLD | NEW |