| Index: chrome/browser/profiles/profile_downloader_unittest.cc
|
| diff --git a/chrome/browser/profiles/profile_downloader_unittest.cc b/chrome/browser/profiles/profile_downloader_unittest.cc
|
| index 3761c77ef2a8cbf0057de3d9198cc4930f975c9a..0b5d9f12ec8f3002d0c3a85df1c3b97f1631e492 100644
|
| --- a/chrome/browser/profiles/profile_downloader_unittest.cc
|
| +++ b/chrome/browser/profiles/profile_downloader_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/profiles/profile_downloader.h"
|
|
|
| +#include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -12,7 +13,9 @@ namespace {
|
| std::string GetJSonData(const std::string& full_name,
|
| const std::string& given_name,
|
| const std::string& url,
|
| - const std::string& locale) {
|
| + const std::string& locale,
|
| + const std::string& hosted_domain,
|
| + bool include_empty_hosted_domain) {
|
| std::stringstream stream;
|
| bool started = false;
|
|
|
| @@ -34,6 +37,9 @@ std::string GetJSonData(const std::string& full_name,
|
| if (!locale.empty())
|
| stream << (started ? ", " : "") << "\"locale\": \"" << locale << "\"";
|
|
|
| + if (!hosted_domain.empty() || include_empty_hosted_domain)
|
| + stream << (started ? ", " : "") << "\"hd\": \"" << hosted_domain << "\"";
|
| +
|
| stream << " }";
|
| return stream.str();
|
| }
|
| @@ -53,26 +59,38 @@ class ProfileDownloaderTest : public testing::Test {
|
| const std::string& url,
|
| const std::string& expected_url,
|
| const std::string& locale,
|
| + const std::string& hosted_domain,
|
| + bool include_empty_hosted_domain,
|
| bool is_valid) {
|
| base::string16 parsed_full_name;
|
| base::string16 parsed_given_name;
|
| std::string parsed_url;
|
| std::string parsed_locale;
|
| + base::string16 parsed_hosted_domain;
|
| bool result = ProfileDownloader::ParseProfileJSON(
|
| - GetJSonData(full_name, given_name, url, locale),
|
| + GetJSonData(full_name,
|
| + given_name,
|
| + url,
|
| + locale,
|
| + hosted_domain,
|
| + include_empty_hosted_domain),
|
| &parsed_full_name,
|
| &parsed_given_name,
|
| &parsed_url,
|
| 32,
|
| - &parsed_locale);
|
| + &parsed_locale,
|
| + &parsed_hosted_domain);
|
| EXPECT_EQ(is_valid, result);
|
| std::string parsed_full_name_utf8 = base::UTF16ToUTF8(parsed_full_name);
|
| std::string parsed_given_name_utf8 = base::UTF16ToUTF8(parsed_given_name);
|
| + std::string parsed_hosted_domain_utf8 =
|
| + base::UTF16ToUTF8(parsed_hosted_domain);
|
|
|
| EXPECT_EQ(full_name, parsed_full_name_utf8);
|
| EXPECT_EQ(given_name, parsed_given_name_utf8);
|
| EXPECT_EQ(expected_url, parsed_url);
|
| EXPECT_EQ(locale, parsed_locale);
|
| + EXPECT_EQ(hosted_domain, parsed_hosted_domain_utf8);
|
| }
|
| };
|
|
|
| @@ -84,6 +102,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/photo.jpg",
|
| "https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/s32-c/photo.jpg",
|
| "en-US",
|
| + "google.com",
|
| + false,
|
| true);
|
|
|
| // URL with size specified.
|
| @@ -93,6 +113,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/abc12/s64-c/1234567890.jpg",
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/abc12/s32-c/1234567890.jpg",
|
| "en-US",
|
| + "google.com",
|
| + false,
|
| true);
|
|
|
| // URL with unknown format.
|
| @@ -101,6 +123,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/",
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/",
|
| "en-US",
|
| + "google.com",
|
| + false,
|
| true);
|
|
|
| // Try different locales. URL with size specified.
|
| @@ -110,6 +134,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/abc12/s64-c/1234567890.jpg",
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/abc12/s32-c/1234567890.jpg",
|
| "jp",
|
| + "google.com",
|
| + false,
|
| true);
|
|
|
| // URL with unknown format.
|
| @@ -118,11 +144,29 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/",
|
| "http://lh0.ggpht.com/-abcd1aBCDEf/AAAA/AAA_A/",
|
| "fr",
|
| + "",
|
| + false,
|
| true);
|
|
|
| // Data with only name.
|
| - VerifyWithAccountData(
|
| - "Pat Smith", "Pat", std::string(), std::string(), std::string(), true);
|
| + VerifyWithAccountData("Pat Smith",
|
| + "Pat",
|
| + std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + false,
|
| + true);
|
| +
|
| + // Data with only name and a blank but present hosted domain.
|
| + VerifyWithAccountData("Pat Smith",
|
| + "Pat",
|
| + std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + true,
|
| + true);
|
|
|
| // Data with only URL.
|
| VerifyWithAccountData(
|
| @@ -131,11 +175,19 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/photo.jpg",
|
| "https://example.com/--Abc/AAAAAAAAAAI/AAAAAAAAACQ/Efg/s32-c/photo.jpg",
|
| std::string(),
|
| + std::string(),
|
| + false,
|
| true);
|
|
|
| // Data with only locale.
|
| - VerifyWithAccountData(
|
| - std::string(), std::string(), std::string(), std::string(), "fr", false);
|
| + VerifyWithAccountData(std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + std::string(),
|
| + "fr",
|
| + std::string(),
|
| + false,
|
| + false);
|
|
|
| // Data without name or URL or locale.
|
| VerifyWithAccountData(std::string(),
|
| @@ -143,6 +195,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| std::string(),
|
| std::string(),
|
| std::string(),
|
| + std::string(),
|
| + false,
|
| false);
|
|
|
| // Data with an invalid URL.
|
| @@ -151,6 +205,8 @@ TEST_F(ProfileDownloaderTest, ParseData) {
|
| "invalid url",
|
| std::string(),
|
| std::string(),
|
| + std::string(),
|
| + false,
|
| false);
|
| }
|
|
|
|
|