summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_to_mobile_service_unittest.cc
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-22 04:16:09 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-22 04:16:09 +0000
commit8211fbf15dbace88e34ba440ba05420fcf01f742 (patch)
treee84c9906ab8775c08cd3f4ceea9db2cf1d209275 /chrome/browser/chrome_to_mobile_service_unittest.cc
parentcfa147a850870e229cabae2cfda76df3dfee4a72 (diff)
downloadchromium_src-8211fbf15dbace88e34ba440ba05420fcf01f742.zip
chromium_src-8211fbf15dbace88e34ba440ba05420fcf01f742.tar.gz
chromium_src-8211fbf15dbace88e34ba440ba05420fcf01f742.tar.bz2
Reland Integrate invalidation API into ChromeToMobileService.
A continuation of http://codereview.chromium.org/10834203 r152609 reverted original r152609 for debug test crashes: http://build.chromium.org/p/chromium/builders/Mac%2010.7%20Tests%20%28dbg%29%284%29/builds/100/steps/browser_tests/logs/stdio Move dtor logic to a ProfileKeyedService::Shutdown OVERRIDE. This fixes the problem locally (we have no debug trybots?). Remaining description matches that of the original CL: ====================================================== Update chrome/browser/DEPS with new dependencies: (google/cacheinvalidation and sync/notifier) Observe Sync Notifier invalidation notifications: (depend on this service for mobile list updates) (refresh the device list on cloud print invalidation) Remove RequestMobileListUpdate, timestamp, & account info: (no longer needed with invalidation integration) (just set command state and icon visibility w/HasMobiles) Lazily init the access token, queue search/send operations: (only get an access token as needed, add |task_queue_|) Allow concurrent cloud print device search requests: (handle user-triggered updates while fetching the list) Misc cleanup (CloudPrintUrl handling, tests, etc.) TODO(followup): Additional logging, tests, invalidation ack. BUG=102709, 137086 TEST=Chrome To Mobile devices update with cloud print! Review URL: https://chromiumcodereview.appspot.com/10869002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152735 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_to_mobile_service_unittest.cc')
-rw-r--r--chrome/browser/chrome_to_mobile_service_unittest.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/chrome/browser/chrome_to_mobile_service_unittest.cc b/chrome/browser/chrome_to_mobile_service_unittest.cc
index d1e6d41..8cff191 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