OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/google_apis/drive_api_url_generator.h" |
| 6 |
| 7 #include "googleurl/src/gurl.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace google_apis { |
| 11 |
| 12 class DriveApiUrlGeneratorTest : public testing::Test { |
| 13 public: |
| 14 DriveApiUrlGeneratorTest() { |
| 15 } |
| 16 |
| 17 protected: |
| 18 DriveApiUrlGenerator url_generator_; |
| 19 }; |
| 20 |
| 21 // Make sure the hard-coded urls are returned. |
| 22 // TODO(hidehiko): More detailed tests when we support server path injecting. |
| 23 TEST_F(DriveApiUrlGeneratorTest, GetAboutUrl) { |
| 24 EXPECT_EQ("https://www.googleapis.com/drive/v2/about", |
| 25 url_generator_.GetAboutUrl().spec()); |
| 26 } |
| 27 |
| 28 TEST_F(DriveApiUrlGeneratorTest, GetApplistUrl) { |
| 29 EXPECT_EQ("https://www.googleapis.com/drive/v2/apps", |
| 30 url_generator_.GetApplistUrl().spec()); |
| 31 } |
| 32 |
| 33 TEST_F(DriveApiUrlGeneratorTest, GetChangelistUrl) { |
| 34 // Use default URL, if |override_url| is empty. |
| 35 // Do not add startChangeId parameter if |start_changestamp| is 0. |
| 36 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes", |
| 37 url_generator_.GetChangelistUrl(GURL(), 0).spec()); |
| 38 |
| 39 // Set startChangeId parameter if |start_changestamp| is given. |
| 40 EXPECT_EQ("https://www.googleapis.com/drive/v2/changes?startChangeId=100", |
| 41 url_generator_.GetChangelistUrl(GURL(), 100).spec()); |
| 42 |
| 43 // Use the |override_url| for the base URL if given. |
| 44 // The behavior for the |start_changestamp| should be as same as above cases. |
| 45 EXPECT_EQ("https://localhost/drive/v2/changes", |
| 46 url_generator_.GetChangelistUrl( |
| 47 GURL("https://localhost/drive/v2/changes"), 0).spec()); |
| 48 EXPECT_EQ("https://localhost/drive/v2/changes?startChangeId=200", |
| 49 url_generator_.GetChangelistUrl( |
| 50 GURL("https://localhost/drive/v2/changes"), 200).spec()); |
| 51 } |
| 52 |
| 53 TEST_F(DriveApiUrlGeneratorTest, GetFilelistUrl) { |
| 54 // Use default URL, if |override_url| is empty. |
| 55 // Do not add q parameter if |search_string| is empty. |
| 56 EXPECT_EQ("https://www.googleapis.com/drive/v2/files", |
| 57 url_generator_.GetFilelistUrl(GURL(), "").spec()); |
| 58 |
| 59 // Set q parameter if non-empty |search_string| is given. |
| 60 EXPECT_EQ("https://www.googleapis.com/drive/v2/files?q=query", |
| 61 url_generator_.GetFilelistUrl(GURL(), "query").spec()); |
| 62 |
| 63 // Use the |override_url| for the base URL if given. |
| 64 // The behavior for the |search_string| should be as same as above cases. |
| 65 EXPECT_EQ("https://localhost/drive/v2/files", |
| 66 url_generator_.GetFilelistUrl( |
| 67 GURL("https://localhost/drive/v2/files"), "").spec()); |
| 68 EXPECT_EQ("https://localhost/drive/v2/files?q=query", |
| 69 url_generator_.GetFilelistUrl( |
| 70 GURL("https://localhost/drive/v2/files"), "query").spec()); |
| 71 } |
| 72 |
| 73 TEST_F(DriveApiUrlGeneratorTest, GetFileUrl) { |
| 74 // |file_id| should be embedded into the url. |
| 75 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg", |
| 76 url_generator_.GetFileUrl("0ADK06pfg").spec()); |
| 77 EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0Bz0bd074", |
| 78 url_generator_.GetFileUrl("0Bz0bd074").spec()); |
| 79 } |
| 80 |
| 81 } // namespace google_apis |
OLD | NEW |