diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 08:50:24 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 08:50:24 +0000 |
commit | ade55c50982e3416ee9329658b62e42650fec58c (patch) | |
tree | 5d8bcad1106a7ecb02ec4f638c29ed4942d0adf2 /chrome/browser/extensions/app_notify_channel_setup_unittest.cc | |
parent | 139a66fd8b8c4b0a416786bb18ba433afed932b3 (diff) | |
download | chromium_src-ade55c50982e3416ee9329658b62e42650fec58c.zip chromium_src-ade55c50982e3416ee9329658b62e42650fec58c.tar.gz chromium_src-ade55c50982e3416ee9329658b62e42650fec58c.tar.bz2 |
Fix the app notify channel setup for the case where the user may have explicitly revoked permission and hence the OAuth2
access token generation may fail. In that case, prompt the user.
add unit tests and modify existing tests.
TBR=asargent
Review URL: http://codereview.chromium.org/8822006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/app_notify_channel_setup_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/app_notify_channel_setup_unittest.cc | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc index 0e88fbf..063da55 100644 --- a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc +++ b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc @@ -182,13 +182,13 @@ class AppNotifyChannelSetupTest : public testing::Test { delegate_.AsWeakPtr()); } - virtual void SetupLogin(bool should_succeed) { + virtual void SetupLogin(bool should_prompt, bool should_succeed) { if (should_succeed) { SetLoggedInUser("user@gmail.com"); profile_.SetTokenServiceHasTokenResult(true); - } else { - ui_->SetSyncSetupResult(false); } + if (should_prompt) + ui_->SetSyncSetupResult(should_succeed); } virtual void SetupFetchAccessToken(bool should_succeed) { @@ -230,14 +230,16 @@ class AppNotifyChannelSetupTest : public testing::Test { }; TEST_F(AppNotifyChannelSetupTest, LoginFailure) { - SetupLogin(false); + SetupLogin(true, false); scoped_refptr<AppNotifyChannelSetup> setup = CreateInstance(); RunServerTest(setup, "", "canceled_by_user"); } -TEST_F(AppNotifyChannelSetupTest, FetchAccessTokenFailure) { - SetupLogin(true); +TEST_F(AppNotifyChannelSetupTest, DoubleFetchAccessTokenFailure) { + SetupLogin(false, true); + SetupFetchAccessToken(false); + SetupLogin(true, true); SetupFetchAccessToken(false); scoped_refptr<AppNotifyChannelSetup> setup = CreateInstance(); @@ -245,7 +247,7 @@ TEST_F(AppNotifyChannelSetupTest, FetchAccessTokenFailure) { } TEST_F(AppNotifyChannelSetupTest, RecordGrantFailure) { - SetupLogin(true); + SetupLogin(false, true); SetupFetchAccessToken(true); SetupRecordGrant(false); @@ -254,7 +256,7 @@ TEST_F(AppNotifyChannelSetupTest, RecordGrantFailure) { } TEST_F(AppNotifyChannelSetupTest, GetChannelIdFailure) { - SetupLogin(true); + SetupLogin(false, true); SetupFetchAccessToken(true); SetupRecordGrant(true); SetupGetChannelId(false); @@ -263,8 +265,20 @@ TEST_F(AppNotifyChannelSetupTest, GetChannelIdFailure) { RunServerTest(setup, "", "internal_error"); } -TEST_F(AppNotifyChannelSetupTest, ServerSuccess) { - SetupLogin(true); +TEST_F(AppNotifyChannelSetupTest, FirstFetchAccessTokenSuccess) { + SetupLogin(false, true); + SetupFetchAccessToken(true); + SetupRecordGrant(true); + SetupGetChannelId(true); + + scoped_refptr<AppNotifyChannelSetup> setup = CreateInstance(); + RunServerTest(setup, "dummy_do_not_use", ""); +} + +TEST_F(AppNotifyChannelSetupTest, SecondFetchAccessTokenSuccess) { + SetupLogin(false, true); + SetupFetchAccessToken(false); + SetupLogin(true, true); SetupFetchAccessToken(true); SetupRecordGrant(true); SetupGetChannelId(true); |