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 "chrome/browser/google_apis/drive_api_url_generator.h" | 5 #include "chrome/browser/google_apis/drive_api_url_generator.h" |
6 | 6 |
7 #include "chrome/browser/google_apis/test_util.h" | 7 #include "chrome/browser/google_apis/test_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 EXPECT_EQ( | 180 EXPECT_EQ( |
181 "http://127.0.0.1:12345/drive/v2/files" + | 181 "http://127.0.0.1:12345/drive/v2/files" + |
182 kTestPatterns[i].expected_query, | 182 kTestPatterns[i].expected_query, |
183 test_url_generator_.GetFilesListUrl( | 183 test_url_generator_.GetFilesListUrl( |
184 kTestPatterns[i].max_results, kTestPatterns[i].page_token, | 184 kTestPatterns[i].max_results, kTestPatterns[i].page_token, |
185 kTestPatterns[i].q).spec()); | 185 kTestPatterns[i].q).spec()); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
| 189 TEST_F(DriveApiUrlGeneratorTest, GetFilesTrashUrl) { |
| 190 // |file_id| should be embedded into the url. |
| 191 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/trash", |
| 192 url_generator_.GetFilesTrashUrl("0ADK06pfg").spec()); |
| 193 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074/trash", |
| 194 url_generator_.GetFilesTrashUrl("0Bz0bd074").spec()); |
| 195 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id/trash", |
| 196 url_generator_.GetFilesTrashUrl("file:file_id").spec()); |
| 197 |
| 198 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/trash", |
| 199 test_url_generator_.GetFilesTrashUrl("0ADK06pfg").spec()); |
| 200 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/trash", |
| 201 test_url_generator_.GetFilesTrashUrl("0Bz0bd074").spec()); |
| 202 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afile_id/trash", |
| 203 test_url_generator_.GetFilesTrashUrl("file:file_id").spec()); |
| 204 } |
| 205 |
189 TEST_F(DriveApiUrlGeneratorTest, GetFileTouchUrl) { | 206 TEST_F(DriveApiUrlGeneratorTest, GetFileTouchUrl) { |
190 // |file_id| should be embedded into the url. | 207 // |file_id| should be embedded into the url. |
191 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg" | 208 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg" |
192 "?setModifiedDate=true&updateViewedDate=false", | 209 "?setModifiedDate=true&updateViewedDate=false", |
193 url_generator_.GetFileTouchUrl("0ADK06pfg").spec()); | 210 url_generator_.GetFileTouchUrl("0ADK06pfg").spec()); |
194 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074" | 211 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074" |
195 "?setModifiedDate=true&updateViewedDate=false", | 212 "?setModifiedDate=true&updateViewedDate=false", |
196 url_generator_.GetFileTouchUrl("0Bz0bd074").spec()); | 213 url_generator_.GetFileTouchUrl("0Bz0bd074").spec()); |
197 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id" | 214 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id" |
198 "?setModifiedDate=true&updateViewedDate=false", | 215 "?setModifiedDate=true&updateViewedDate=false", |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 "http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/children/0ADK06pfg", | 338 "http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/children/0ADK06pfg", |
322 test_url_generator_.GetChildrenUrlForRemoval( | 339 test_url_generator_.GetChildrenUrlForRemoval( |
323 "0Bz0bd074", "0ADK06pfg").spec()); | 340 "0Bz0bd074", "0ADK06pfg").spec()); |
324 EXPECT_EQ( | 341 EXPECT_EQ( |
325 "http://127.0.0.1:12345/drive/v2/files/file%3Afolder_id/children/" | 342 "http://127.0.0.1:12345/drive/v2/files/file%3Afolder_id/children/" |
326 "file%3Achild_id", | 343 "file%3Achild_id", |
327 test_url_generator_.GetChildrenUrlForRemoval( | 344 test_url_generator_.GetChildrenUrlForRemoval( |
328 "file:folder_id", "file:child_id").spec()); | 345 "file:folder_id", "file:child_id").spec()); |
329 } | 346 } |
330 | 347 |
331 TEST_F(DriveApiUrlGeneratorTest, GetFileTrashUrl) { | |
332 // |file_id| should be embedded into the url. | |
333 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg/trash", | |
334 url_generator_.GetFileTrashUrl("0ADK06pfg").spec()); | |
335 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074/trash", | |
336 url_generator_.GetFileTrashUrl("0Bz0bd074").spec()); | |
337 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/file%3Afile_id/trash", | |
338 url_generator_.GetFileTrashUrl("file:file_id").spec()); | |
339 | |
340 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0ADK06pfg/trash", | |
341 test_url_generator_.GetFileTrashUrl("0ADK06pfg").spec()); | |
342 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/0Bz0bd074/trash", | |
343 test_url_generator_.GetFileTrashUrl("0Bz0bd074").spec()); | |
344 EXPECT_EQ("http://127.0.0.1:12345/drive/v2/files/file%3Afile_id/trash", | |
345 test_url_generator_.GetFileTrashUrl("file:file_id").spec()); | |
346 } | |
347 | |
348 TEST_F(DriveApiUrlGeneratorTest, GetInitiateUploadNewFileUrl) { | 348 TEST_F(DriveApiUrlGeneratorTest, GetInitiateUploadNewFileUrl) { |
349 EXPECT_EQ( | 349 EXPECT_EQ( |
350 "https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable", | 350 "https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable", |
351 url_generator_.GetInitiateUploadNewFileUrl().spec()); | 351 url_generator_.GetInitiateUploadNewFileUrl().spec()); |
352 | 352 |
353 EXPECT_EQ( | 353 EXPECT_EQ( |
354 "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=resumable", | 354 "http://127.0.0.1:12345/upload/drive/v2/files?uploadType=resumable", |
355 test_url_generator_.GetInitiateUploadNewFileUrl().spec()); | 355 test_url_generator_.GetInitiateUploadNewFileUrl().spec()); |
356 } | 356 } |
357 | 357 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 url_generator_.GenerateDownloadFileUrl("resourceId").spec()); | 393 url_generator_.GenerateDownloadFileUrl("resourceId").spec()); |
394 EXPECT_EQ( | 394 EXPECT_EQ( |
395 "https://www.googledrive.com/host/file%3AresourceId", | 395 "https://www.googledrive.com/host/file%3AresourceId", |
396 url_generator_.GenerateDownloadFileUrl("file:resourceId").spec()); | 396 url_generator_.GenerateDownloadFileUrl("file:resourceId").spec()); |
397 EXPECT_EQ( | 397 EXPECT_EQ( |
398 "http://127.0.0.1:12345/download/resourceId", | 398 "http://127.0.0.1:12345/download/resourceId", |
399 test_url_generator_.GenerateDownloadFileUrl("resourceId").spec()); | 399 test_url_generator_.GenerateDownloadFileUrl("resourceId").spec()); |
400 } | 400 } |
401 | 401 |
402 } // namespace google_apis | 402 } // namespace google_apis |
OLD | NEW |