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

Unified Diff: chrome/browser/extensions/api/identity/identity_apitest.cc

Issue 327403003: Identity API: add chrome.identity.getProfileUserInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add identity.email permission to stubs_app Created 6 years, 6 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/extensions/api/identity/identity_apitest.cc
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index ae7eaa2b8d2f16dc343a218a849743c5252c3c45..42dffa09e62aa130f9315d7502ffbeccfc241f35 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/command_line.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
@@ -33,6 +34,7 @@
#include "chrome/test/base/test_switches.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
+#include "components/signin/core/common/signin_pref_names.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/test/test_utils.h"
@@ -581,6 +583,35 @@ IN_PROC_BROWSER_TEST_F(IdentityOldProfilesGetAccountsFunctionTest,
EXPECT_TRUE(ExpectGetAccounts(only_primary));
}
+class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest {
+ protected:
+ scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() {
+ scoped_refptr<IdentityGetProfileUserInfoFunction> func(
+ new IdentityGetProfileUserInfoFunction);
+ func->set_extension(utils::CreateEmptyExtension(kExtensionId).get());
+ scoped_ptr<base::Value> value(
+ utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser()));
+ return api::identity::ProfileUserInfo::FromValue(*value.get());
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, NotSignedIn) {
+ scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ EXPECT_TRUE(info->email.empty());
+ EXPECT_TRUE(info->id.empty());
+}
+
+IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, SignedIn) {
+ profile()->GetPrefs()
+ ->SetString(prefs::kGoogleServicesUsername, "president@example.com");
+ profile()->GetPrefs()
+ ->SetString(prefs::kGoogleServicesUserAccountId, "12345");
+
+ scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ EXPECT_EQ("president@example.com", info->email);
+ EXPECT_EQ("12345", info->id);
+}
+
class GetAuthTokenFunctionTest : public AsyncExtensionBrowserTest {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.cc ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698