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

Unified Diff: chrome/browser/chrome_to_mobile_service_unittest.cc

Issue 10834203: Integrate invalidation API into ChromeToMobileService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment; sync and rebase. Created 8 years, 4 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/chrome_to_mobile_service_unittest.cc
diff --git a/chrome/browser/chrome_to_mobile_service_unittest.cc b/chrome/browser/chrome_to_mobile_service_unittest.cc
index d1e6d4163b53947f4333cdef9149e36d459afba4..8cff191e9a67a7db4c0f18655235eec97506d7cd 100644
--- a/chrome/browser/chrome_to_mobile_service_unittest.cc
+++ b/chrome/browser/chrome_to_mobile_service_unittest.cc
@@ -17,7 +17,6 @@ const char kDummyString[] = "dummy";
class DummyNotificationSource {};
-// A mock ChromeToMobileService with a mocked out RequestAccessToken method.
class MockChromeToMobileService : public ChromeToMobileService {
public:
MockChromeToMobileService();
@@ -50,29 +49,37 @@ ChromeToMobileServiceTest::ChromeToMobileServiceTest() {}
ChromeToMobileServiceTest::~ChromeToMobileServiceTest() {}
-// Ensure that RequestAccessToken is not called for irrelevant notifications.
+// Ensure that irrelevant notifications do not invalidate the access token.
TEST_F(ChromeToMobileServiceTest, IgnoreIrrelevantNotifications) {
EXPECT_CALL(service_, RequestAccessToken()).Times(0);
- // Send dummy service/token details (should not refresh token).
+ service_.SetAccessTokenForTest(kDummyString);
+ ASSERT_FALSE(service_.GetAccessTokenForTest().empty());
+
+ // Send dummy service/token details (should not request 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 RequestAccessToken is called on the proper notification.
+// Ensure that proper notifications invalidate the access token.
TEST_F(ChromeToMobileServiceTest, AuthenticateOnTokenAvailable) {
- EXPECT_CALL(service_, RequestAccessToken()).Times(1);
+ EXPECT_CALL(service_, RequestAccessToken()).Times(0);
+
+ service_.SetAccessTokenForTest(kDummyString);
+ ASSERT_FALSE(service_.GetAccessTokenForTest().empty());
- // Send a Gaia OAuth2 Login service dummy token (should refresh token).
+ // Send a Gaia OAuth2 Login service dummy token (should request 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
« no previous file with comments | « chrome/browser/chrome_to_mobile_service_factory.cc ('k') | chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698