Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2704)

Unified Diff: chrome/browser/profiles/profile_downloader_unittest.cc

Issue 257773002: Use new people.get api instead of oauth2/v1/userinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PD tests Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f700848d73e9a18507f6bf03f00ddd8533557fe9 100644
--- a/chrome/browser/profiles/profile_downloader_unittest.cc
+++ b/chrome/browser/profiles/profile_downloader_unittest.cc
@@ -4,38 +4,47 @@
#include "chrome/browser/profiles/profile_downloader.h"
+#include "base/json/json_reader.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-std::string GetJSonData(const std::string& full_name,
- const std::string& given_name,
- const std::string& url,
- const std::string& locale) {
+scoped_ptr<base::DictionaryValue> GetJSonData(const std::string& full_name,
noms (inactive) 2014/04/25 17:07:40 Can you do something here like in the ProfileDownl
Roger Tawa OOO till Jul 10th 2014/04/28 20:44:12 Done.
+ const std::string& given_name,
+ const std::string& url,
+ const std::string& locale) {
std::stringstream stream;
bool started = false;
stream << "{ ";
if (!full_name.empty()) {
- stream << "\"name\": \"" << full_name << "\"";
+ stream << "\"displayName\": \"" << full_name << "\"";
started = true;
}
if (!given_name.empty()) {
- stream << (started ? ", " : "") << "\"given_name\": \"" << given_name
- << "\"";
+ stream << (started ? ", " : "") << "\"name\": {";
+ stream << "\"givenName\": \"" << given_name
+ << "\"}";
started = true;
}
if (!url.empty()) {
- stream << (started ? ", " : "") << "\"picture\": \"" << url << "\"";
+ stream << (started ? ", " : "") << "\"image\": {";
+ stream << "\"url\": \"" << url << "\"}";
started = true;
}
if (!locale.empty())
- stream << (started ? ", " : "") << "\"locale\": \"" << locale << "\"";
+ stream << (started ? ", " : "") << "\"language\": \"" << locale << "\"";
stream << " }";
- return stream.str();
+ base::Value* value = base::JSONReader::Read(stream.str());
+ base::DictionaryValue* dict = NULL;
+ value->GetAsDictionary(&dict);
+ return make_scoped_ptr(dict);
}
} // namespace
@@ -58,8 +67,10 @@ class ProfileDownloaderTest : public testing::Test {
base::string16 parsed_given_name;
std::string parsed_url;
std::string parsed_locale;
+ scoped_ptr<base::DictionaryValue> dict(
+ GetJSonData(full_name, given_name, url, locale));
bool result = ProfileDownloader::ParseProfileJSON(
- GetJSonData(full_name, given_name, url, locale),
+ dict.get(),
&parsed_full_name,
&parsed_given_name,
&parsed_url,

Powered by Google App Engine
This is Rietveld 408576698