This source file includes following definitions.
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "google_apis/drive/gdata_wapi_url_generator.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/url_util.h"
namespace google_apis {
class GDataWapiUrlGeneratorTest : public testing::Test {
public:
GDataWapiUrlGeneratorTest()
: url_generator_(
GURL(GDataWapiUrlGenerator::kBaseUrlForProduction),
GURL(GDataWapiUrlGenerator::kBaseDownloadUrlForProduction)) {
}
protected:
GDataWapiUrlGenerator url_generator_;
};
TEST_F(GDataWapiUrlGeneratorTest, AddStandardUrlParams) {
EXPECT_EQ("http://www.example.com/?v=3&alt=json&showroot=true",
GDataWapiUrlGenerator::AddStandardUrlParams(
GURL("http://www.example.com")).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, AddInitiateUploadUrlParams) {
EXPECT_EQ("http://www.example.com/?convert=false&v=3&alt=json&showroot=true",
GDataWapiUrlGenerator::AddInitiateUploadUrlParams(
GURL("http://www.example.com")).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) {
EXPECT_EQ(
"http://www.example.com/?v=3&alt=json&showroot=true&"
"showfolders=true"
"&include-shared=true"
"&max-results=100",
GDataWapiUrlGenerator::AddFeedUrlParams(GURL("http://www.example.com"),
100
).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
EXPECT_EQ("https://docs.google.com/feeds/default/private/full"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500",
url_generator_.GenerateResourceListUrl(
GURL(),
0,
std::string(),
std::string()
).spec());
EXPECT_EQ("http://localhost/"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500",
url_generator_.GenerateResourceListUrl(
GURL("http://localhost/"),
0,
std::string(),
std::string()
).spec());
EXPECT_EQ("https://docs.google.com/feeds/default/private/changes"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&start-index=100",
url_generator_.GenerateResourceListUrl(
GURL(),
100,
std::string(),
std::string()
).spec());
EXPECT_EQ("https://docs.google.com/feeds/default/private/full"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=100&q=foo",
url_generator_.GenerateResourceListUrl(
GURL(),
0,
"foo",
std::string()
).spec());
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX/contents"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500",
url_generator_.GenerateResourceListUrl(GURL(),
0,
std::string(),
"XXX"
).spec());
EXPECT_EQ("http://example.com/"
"?start-index=123&v=3&alt=json&showroot=true&showfolders=true"
"&include-shared=true&max-results=500",
url_generator_.GenerateResourceListUrl(
GURL("http://example.com/?start-index=123"),
100,
std::string(),
"XXX"
).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateSearchByTitleUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&title=search-title&title-exact=true",
url_generator_.GenerateSearchByTitleUrl(
"search-title", std::string()).spec());
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX/contents"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&title=search-title&title-exact=true",
url_generator_.GenerateSearchByTitleUrl(
"search-title", "XXX").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
"&showroot=true",
url_generator_.GenerateEditUrl("XXX").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrlWithoutParams) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX",
url_generator_.GenerateEditUrlWithoutParams("XXX").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateEditUrlWithEmbedOrigin) {
url_util::AddStandardScheme("chrome-extension");
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
"&showroot=true&embedOrigin=chrome-extension%3A%2F%2Ftest",
url_generator_.GenerateEditUrlWithEmbedOrigin(
"XXX",
GURL("chrome-extension://test")).spec());
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json"
"&showroot=true",
url_generator_.GenerateEditUrlWithEmbedOrigin(
"XXX",
GURL()).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateContentUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/"
"folder%3Aroot/contents?v=3&alt=json&showroot=true",
url_generator_.GenerateContentUrl("folder:root").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceUrlForRemoval) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/"
"folder%3Aroot/contents/file%3AABCDE?v=3&alt=json&showroot=true",
url_generator_.GenerateResourceUrlForRemoval(
"folder:root", "file:ABCDE").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateInitiateUploadNewFileUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/upload/create-session/default/private/"
"full/folder%3Aabcde/contents?convert=false&v=3&alt=json&showroot=true",
url_generator_.GenerateInitiateUploadNewFileUrl("folder:abcde").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateInitiateUploadExistingFileUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/upload/create-session/default/private/"
"full/file%3Aresource_id?convert=false&v=3&alt=json&showroot=true",
url_generator_.GenerateInitiateUploadExistingFileUrl(
"file:resource_id").spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListRootUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full?v=3&alt=json"
"&showroot=true",
url_generator_.GenerateResourceListRootUrl().spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateAccountMetadataUrl) {
EXPECT_EQ(
"https://docs.google.com/feeds/metadata/default"
"?v=3&alt=json&showroot=true&include-installed-apps=true",
url_generator_.GenerateAccountMetadataUrl(true).spec());
EXPECT_EQ(
"https://docs.google.com/feeds/metadata/default?v=3&alt=json"
"&showroot=true",
url_generator_.GenerateAccountMetadataUrl(false).spec());
}
TEST_F(GDataWapiUrlGeneratorTest, GenerateDownloadFileUrl) {
EXPECT_EQ(
"https://www.googledrive.com/host/resourceId",
url_generator_.GenerateDownloadFileUrl("file:resourceId").spec());
}
}