summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/identity/identity_apitest.cc
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-02 21:15:09 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-02 21:15:09 +0000
commitdc24976fc87171d50b49f37bbaaa23ae53e51f4b (patch)
tree8d7c684afa0d65e22efc3384197ef5b50d867160 /chrome/browser/extensions/api/identity/identity_apitest.cc
parentfc72bb18b111ff63e57135d97de6d59291f3b7b8 (diff)
downloadchromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.zip
chromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.tar.gz
chromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.tar.bz2
Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*"
Linux fixes, Part 2 of N BUG=110610 TBR=darin Review URL: https://chromiumcodereview.appspot.com/16295003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/identity/identity_apitest.cc')
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc98
1 files changed, 48 insertions, 50 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index f2707bc..736b806 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -384,9 +384,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NonInteractiveMintAdviceSuccess) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
- EXPECT_CALL(*func.get(), HasLoginToken())
- .WillOnce(Return(true));
+ func->set_extension(extension.get());
+ EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
@@ -396,10 +395,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->scope_ui_shown());
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
- EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_ADVICE,
- id_api()->GetCachedToken(extension->id(),
- oauth2_info.scopes).status());
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
+ EXPECT_EQ(
+ IdentityTokenCacheValue::CACHE_STATUS_ADVICE,
+ id_api()->GetCachedToken(extension->id(), oauth2_info.scopes).status());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -422,10 +421,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NonInteractiveSuccess) {
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
- func->set_extension(extension);
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
- EXPECT_CALL(*func.get(), HasLoginToken())
- .WillOnce(Return(true));
+ func->set_extension(extension.get());
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
+ EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
@@ -542,9 +540,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
InteractiveLoginSuccessApprovalSuccess) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
- EXPECT_CALL(*func.get(), HasLoginToken())
- .WillOnce(Return(false));
+ func->set_extension(extension.get());
+ EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(false));
func->set_login_ui_result(true);
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
@@ -644,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
++it) {
scoped_refptr<MockGetAuthTokenFunction> func(
new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
@@ -661,11 +658,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
InteractiveApprovalSuccess) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
- EXPECT_CALL(*func.get(), HasLoginToken())
- .WillOnce(Return(true));
+ func->set_extension(extension.get());
+ EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_))
@@ -687,10 +683,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// Create a fake request to block the queue.
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
IdentityAPI* id_api =
@@ -707,9 +703,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
// The real request will start processing, but wait in the queue behind
// the blocker.
EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
- RunFunctionAsync(func, "[{}]");
+ RunFunctionAsync(func.get(), "[{}]");
// Verify that we have fetched the login token at this point.
- testing::Mock::VerifyAndClearExpectations(func);
+ testing::Mock::VerifyAndClearExpectations(func.get());
// The flow will be created after the first queued request clears.
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
@@ -718,7 +714,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
queue->RequestComplete(type, extension->id(), scopes, &queued_request);
- scoped_ptr<base::Value> value(WaitForSingleResult(func));
+ scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
EXPECT_TRUE(value->GetAsString(&access_token));
EXPECT_EQ(std::string(kAccessToken), access_token);
@@ -729,10 +725,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) {
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// Create a fake request to block the queue.
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
IdentityAPI* id_api =
@@ -752,16 +748,16 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) {
TestOAuth2MintTokenFlow* flow1 = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow1));
- RunFunctionAsync(func, "[{\"interactive\": true}]");
+ RunFunctionAsync(func.get(), "[{\"interactive\": true}]");
// Verify that we have fetched the login token and run the first flow.
- testing::Mock::VerifyAndClearExpectations(func);
+ testing::Mock::VerifyAndClearExpectations(func.get());
EXPECT_FALSE(func->scope_ui_shown());
// The UI will be displayed and a token retrieved after the first
// queued request clears.
queue->RequestComplete(type, extension->id(), scopes, &queued_request);
- scoped_ptr<base::Value> value(WaitForSingleResult(func));
+ scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
EXPECT_TRUE(value->GetAsString(&access_token));
EXPECT_EQ(std::string(kAccessToken), access_token);
@@ -773,10 +769,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
InteractiveQueuedNoninteractiveFails) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// Create a fake request to block the interactive queue.
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
IdentityAPI* id_api =
@@ -806,10 +802,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NonInteractiveCacheHit) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// pre-populate the cache with a token
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
IdentityTokenCacheValue token(kAccessToken,
base::TimeDelta::FromSeconds(3600));
id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
@@ -830,10 +826,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NonInteractiveIssueAdviceCacheHit) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// pre-populate the cache with advice
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
IssueAdviceInfo info;
IdentityTokenCacheValue token(info);
id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
@@ -852,10 +848,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
InteractiveCacheHit) {
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
- func->set_extension(extension);
+ func->set_extension(extension.get());
// Create a fake request to block the queue.
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
IdentityMintRequestQueue* queue = id_api()->mint_queue();
@@ -872,7 +868,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
- RunFunctionAsync(func, "[{\"interactive\": true}]");
+ RunFunctionAsync(func.get(), "[{\"interactive\": true}]");
// Populate the cache with a token while the request is blocked.
IdentityTokenCacheValue token(kAccessToken,
@@ -884,7 +880,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
queue->RequestComplete(type, extension->id(), scopes, &queued_request);
- scoped_ptr<base::Value> value(WaitForSingleResult(func));
+ scoped_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
EXPECT_TRUE(value->GetAsString(&access_token));
EXPECT_EQ(std::string(kAccessToken), access_token);
@@ -896,10 +892,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
LoginInvalidatesTokenCache) {
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
- func->set_extension(extension);
+ func->set_extension(extension.get());
// pre-populate the cache with a token
- const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension);
+ const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get());
IdentityTokenCacheValue token(kAccessToken,
base::TimeDelta::FromSeconds(3600));
id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token);
@@ -933,7 +929,9 @@ class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest {
new IdentityRemoveCachedAuthTokenFunction);
func->set_extension(utils::CreateEmptyExtension(kExtensionId));
return utils::RunFunction(
- func, std::string("[{\"token\": \"") + kAccessToken + "\"}]", browser(),
+ func.get(),
+ std::string("[{\"token\": \"") + kAccessToken + "\"}]",
+ browser(),
extension_function_test_utils::NONE);
}
@@ -1016,11 +1014,11 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest,
std::string args = "[{\"interactive\": true, \"url\": \"" +
auth_url.spec() + "\"}]";
- RunFunctionAsync(function, args);
+ RunFunctionAsync(function.get(), args);
popup_observer.Wait();
- EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function));
+ EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get()));
}
IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) {
@@ -1040,8 +1038,8 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) {
std::string args = "[{\"interactive\": false, \"url\": \"" +
auth_url.spec() + "\"}]";
- std::string error = utils::RunFunctionAndReturnError(function, args,
- browser());
+ std::string error =
+ utils::RunFunctionAndReturnError(function.get(), args, browser());
EXPECT_EQ(std::string(errors::kInteractionRequired), error);
}
@@ -1078,7 +1076,7 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) {
function->InitFinalRedirectURLPrefixForTest("abcdefghij");
scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
- function,
+ function.get(),
"[{\"interactive\": false,"
"\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]",
browser()));
@@ -1099,7 +1097,7 @@ IN_PROC_BROWSER_TEST_F(
function->InitFinalRedirectURLPrefixForTest("abcdefghij");
scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
- function,
+ function.get(),
"[{\"interactive\": true,"
"\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]",
browser()));
@@ -1129,8 +1127,8 @@ IN_PROC_BROWSER_TEST_F(
function->InitFinalRedirectURLPrefixForTest("abcdefghij");
std::string args = "[{\"interactive\": true, \"url\": \"" +
auth_url.spec() + "\"}]";
- scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
- function, args, browser()));
+ scoped_ptr<base::Value> value(
+ utils::RunFunctionAndReturnSingleResult(function.get(), args, browser()));
std::string url;
EXPECT_TRUE(value->GetAsString(&url));