Home | History | Annotate | Download | only in drive
      1 // Copyright (c) 2012 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 "google_apis/drive/gdata_wapi_url_generator.h"
      6 
      7 #include "testing/gtest/include/gtest/gtest.h"
      8 #include "url/gurl.h"
      9 #include "url/url_util.h"
     10 
     11 namespace google_apis {
     12 
     13 class GDataWapiUrlGeneratorTest : public testing::Test {
     14  public:
     15   GDataWapiUrlGeneratorTest()
     16       : url_generator_(
     17           GURL(GDataWapiUrlGenerator::kBaseUrlForProduction)) {
     18   }
     19 
     20  protected:
     21   GDataWapiUrlGenerator url_generator_;
     22 };
     23 
     24 TEST_F(GDataWapiUrlGeneratorTest, AddStandardUrlParams) {
     25   EXPECT_EQ("http://www.example.com/?v=3&alt=json&showroot=true",
     26             GDataWapiUrlGenerator::AddStandardUrlParams(
     27                 GURL("http://www.example.com")).spec());
     28 }
     29 
     30 TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrl) {
     31   EXPECT_EQ(
     32       "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
     33       "&showroot=true",
     34       url_generator_.GenerateEditUrl("XXX").spec());
     35 }
     36 
     37 TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrlWithoutParams) {
     38   EXPECT_EQ(
     39       "https://docs.google.com/feeds/default/private/full/XXX",
     40       url_generator_.GenerateEditUrlWithoutParams("XXX").spec());
     41 }
     42 
     43 TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrlWithEmbedOrigin) {
     44   url::AddStandardScheme("chrome-extension");
     45 
     46   EXPECT_EQ(
     47       "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
     48       "&showroot=true&embedOrigin=chrome-extension%3A%2F%2Ftest",
     49       url_generator_.GenerateEditUrlWithEmbedOrigin(
     50           "XXX",
     51           GURL("chrome-extension://test")).spec());
     52   EXPECT_EQ(
     53       "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
     54       "&showroot=true",
     55       url_generator_.GenerateEditUrlWithEmbedOrigin(
     56           "XXX",
     57           GURL()).spec());
     58 }
     59 
     60 }  // namespace google_apis
     61