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

Unified Diff: chrome/browser/services/gcm/gcm_account_tracker_unittest.cc

Issue 710903002: Revert of [GCM] Fetching OAuth2 tokens periodically in account tracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mapper-in-driver
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/services/gcm/gcm_account_tracker.cc ('k') | components/gcm_driver/gcm_client_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/services/gcm/gcm_account_tracker_unittest.cc
diff --git a/chrome/browser/services/gcm/gcm_account_tracker_unittest.cc b/chrome/browser/services/gcm/gcm_account_tracker_unittest.cc
index eb8030a165ff1e8cad90d967fedd69fab90fdb61..2211d76ad2e1724a6e3c966e00765cf2341a49bf 100644
--- a/chrome/browser/services/gcm/gcm_account_tracker_unittest.cc
+++ b/chrome/browser/services/gcm/gcm_account_tracker_unittest.cc
@@ -8,6 +8,8 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "components/gcm_driver/fake_gcm_driver.h"
#include "google_apis/gaia/fake_identity_provider.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
@@ -74,8 +76,6 @@
void AddConnectionObserver(GCMConnectionObserver* observer) override;
void RemoveConnectionObserver(GCMConnectionObserver* observer) override;
bool IsConnected() const override { return connected_; }
- base::Time GetLastTokenFetchTime() override;
- void SetLastTokenFetchTime(const base::Time& time) override;
// Test results and helpers.
void SetConnected(bool connected);
@@ -98,7 +98,6 @@
GCMConnectionObserver* last_connection_observer_;
GCMConnectionObserver* removed_connection_observer_;
net::IPEndPoint ip_endpoint_;
- base::Time last_token_fetch_time_;
DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver);
};
@@ -140,15 +139,6 @@
update_accounts_called_ = false;
last_connection_observer_ = NULL;
removed_connection_observer_ = NULL;
-}
-
-
-base::Time CustomFakeGCMDriver::GetLastTokenFetchTime() {
- return last_token_fetch_time_;
-}
-
-void CustomFakeGCMDriver::SetLastTokenFetchTime(const base::Time& time) {
- last_token_fetch_time_ = time;
}
} // namespace
@@ -175,11 +165,6 @@
GCMAccountTracker* tracker() { return tracker_.get(); }
CustomFakeGCMDriver* driver() { return &driver_; }
- // Accessors to private methods of account tracker.
- bool IsFetchingRequired() const;
- bool IsTokenReportingRequired() const;
- base::TimeDelta GetTimeToNextTokenReporting() const;
-
private:
CustomFakeGCMDriver driver_;
@@ -252,18 +237,6 @@
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
}
-bool GCMAccountTrackerTest::IsFetchingRequired() const {
- return tracker_->IsTokenFetchingRequired();
-}
-
-bool GCMAccountTrackerTest::IsTokenReportingRequired() const {
- return tracker_->IsTokenReportingRequired();
-}
-
-base::TimeDelta GCMAccountTrackerTest::GetTimeToNextTokenReporting() const {
- return tracker_->GetTimeToNextTokenReporting();
-}
-
TEST_F(GCMAccountTrackerTest, NoAccounts) {
EXPECT_FALSE(driver()->update_accounts_called());
tracker()->Start();
@@ -430,7 +403,7 @@
EXPECT_EQ(1UL, tracker()->get_pending_token_request_count());
}
-TEST_F(GCMAccountTrackerTest, InvalidateExpiredTokens) {
+TEST_F(GCMAccountTrackerTest, IvalidateExpiredTokens) {
StartAccountSignIn(kAccountId1);
StartAccountSignIn(kAccountId2);
tracker()->Start();
@@ -448,63 +421,6 @@
EXPECT_EQ(1UL, tracker()->get_pending_token_request_count());
}
-// Testing for whether there are still more tokens to be fetched. Typically the
-// need for token fetching triggers immediate request, unless there is no
-// connection, that is why connection is set on and off in this test.
-TEST_F(GCMAccountTrackerTest, IsTokenFetchingRequired) {
- tracker()->Start();
- driver()->SetConnected(false);
- EXPECT_FALSE(IsFetchingRequired());
- StartAccountSignIn(kAccountId1);
- FinishAccountSignIn(kAccountId1);
- EXPECT_TRUE(IsFetchingRequired());
-
- driver()->SetConnected(true);
- EXPECT_FALSE(IsFetchingRequired()); // Indicates that fetching has started.
- IssueAccessToken(kAccountId1);
- EXPECT_FALSE(IsFetchingRequired());
-
- driver()->SetConnected(false);
- StartAccountSignIn(kAccountId2);
- FinishAccountSignIn(kAccountId2);
- EXPECT_TRUE(IsFetchingRequired());
-
- IssueExpiredAccessToken(kAccountId2);
- // Make sure that if the token was expired it is still needed.
- EXPECT_TRUE(IsFetchingRequired());
-}
-
-// Tests what is the expected time to the next token fetching.
-TEST_F(GCMAccountTrackerTest, GetTimeToNextTokenReporting) {
- tracker()->Start();
- // At this point the last token fetch time is never.
- EXPECT_EQ(base::TimeDelta(), GetTimeToNextTokenReporting());
-
- driver()->SetLastTokenFetchTime(base::Time::Now());
- EXPECT_TRUE(GetTimeToNextTokenReporting() <=
- base::TimeDelta::FromSeconds(12 * 60 * 60));
-}
-
-// Tests conditions when token reporting is required.
-TEST_F(GCMAccountTrackerTest, IsTokenReportingRequired) {
- tracker()->Start();
- // Required because it is overdue.
- EXPECT_TRUE(IsTokenReportingRequired());
-
- // Not required because it just happened.
- driver()->SetLastTokenFetchTime(base::Time::Now());
- EXPECT_FALSE(IsTokenReportingRequired());
-
- SignInAccount(kAccountId1);
- IssueAccessToken(kAccountId1);
- driver()->ResetResults();
- // Reporting was triggered, which means testing for required will give false,
- // but we have the update call.
- SignOutAccount(kAccountId1);
- EXPECT_TRUE(driver()->update_accounts_called());
- EXPECT_FALSE(IsTokenReportingRequired());
-}
-
// TODO(fgorski): Add test for adding account after removal >> make sure it does
// not mark removal.
« no previous file with comments | « chrome/browser/services/gcm/gcm_account_tracker.cc ('k') | components/gcm_driver/gcm_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698