| Index: chrome/browser/chrome_to_mobile_service_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/chrome_to_mobile_service_unittest.cc (revision 152612)
|
| +++ chrome/browser/chrome_to_mobile_service_unittest.cc (working copy)
|
| @@ -17,6 +17,7 @@
|
|
|
| class DummyNotificationSource {};
|
|
|
| +// A mock ChromeToMobileService with a mocked out RequestAccessToken method.
|
| class MockChromeToMobileService : public ChromeToMobileService {
|
| public:
|
| MockChromeToMobileService();
|
| @@ -49,37 +50,29 @@
|
|
|
| ChromeToMobileServiceTest::~ChromeToMobileServiceTest() {}
|
|
|
| -// Ensure that irrelevant notifications do not invalidate the access token.
|
| +// Ensure that RequestAccessToken is not called for irrelevant notifications.
|
| TEST_F(ChromeToMobileServiceTest, IgnoreIrrelevantNotifications) {
|
| EXPECT_CALL(service_, RequestAccessToken()).Times(0);
|
|
|
| - service_.SetAccessTokenForTest(kDummyString);
|
| - ASSERT_FALSE(service_.GetAccessTokenForTest().empty());
|
| -
|
| - // Send dummy service/token details (should not request token).
|
| + // Send dummy service/token details (should not refresh token).
|
| DummyNotificationSource dummy_source;
|
| TokenService::TokenAvailableDetails dummy_details(kDummyString, kDummyString);
|
| service_.Observe(chrome::NOTIFICATION_TOKEN_AVAILABLE,
|
| content::Source<DummyNotificationSource>(&dummy_source),
|
| content::Details<TokenService::TokenAvailableDetails>(&dummy_details));
|
| - EXPECT_FALSE(service_.GetAccessTokenForTest().empty());
|
| }
|
|
|
| -// Ensure that proper notifications invalidate the access token.
|
| +// Ensure that RequestAccessToken is called on the proper notification.
|
| TEST_F(ChromeToMobileServiceTest, AuthenticateOnTokenAvailable) {
|
| - EXPECT_CALL(service_, RequestAccessToken()).Times(0);
|
| + EXPECT_CALL(service_, RequestAccessToken()).Times(1);
|
|
|
| - service_.SetAccessTokenForTest(kDummyString);
|
| - ASSERT_FALSE(service_.GetAccessTokenForTest().empty());
|
| -
|
| - // Send a Gaia OAuth2 Login service dummy token (should request token).
|
| + // Send a Gaia OAuth2 Login service dummy token (should refresh token).
|
| DummyNotificationSource dummy_source;
|
| TokenService::TokenAvailableDetails login_details(
|
| GaiaConstants::kGaiaOAuth2LoginRefreshToken, kDummyString);
|
| service_.Observe(chrome::NOTIFICATION_TOKEN_AVAILABLE,
|
| content::Source<DummyNotificationSource>(&dummy_source),
|
| content::Details<TokenService::TokenAvailableDetails>(&login_details));
|
| - EXPECT_TRUE(service_.GetAccessTokenForTest().empty());
|
| }
|
|
|
| } // namespace
|
|
|