| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/gaia/account_tracker.h" | 5 #include "google_apis/gaia/account_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 testing::AssertionResult CheckEvents(const TrackingEvent& e1, | 129 testing::AssertionResult CheckEvents(const TrackingEvent& e1, |
| 130 const TrackingEvent& e2, | 130 const TrackingEvent& e2, |
| 131 const TrackingEvent& e3, | 131 const TrackingEvent& e3, |
| 132 const TrackingEvent& e4, | 132 const TrackingEvent& e4, |
| 133 const TrackingEvent& e5, | 133 const TrackingEvent& e5, |
| 134 const TrackingEvent& e6); | 134 const TrackingEvent& e6); |
| 135 void Clear(); | 135 void Clear(); |
| 136 void SortEventsByUser(); | 136 void SortEventsByUser(); |
| 137 | 137 |
| 138 // AccountTracker::Observer implementation | 138 // AccountTracker::Observer implementation |
| 139 virtual void OnAccountAdded(const AccountIds& ids) OVERRIDE; | 139 virtual void OnAccountAdded(const AccountIds& ids) override; |
| 140 virtual void OnAccountRemoved(const AccountIds& ids) OVERRIDE; | 140 virtual void OnAccountRemoved(const AccountIds& ids) override; |
| 141 virtual void OnAccountSignInChanged(const AccountIds& ids, bool is_signed_in) | 141 virtual void OnAccountSignInChanged(const AccountIds& ids, bool is_signed_in) |
| 142 OVERRIDE; | 142 override; |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 testing::AssertionResult CheckEvents( | 145 testing::AssertionResult CheckEvents( |
| 146 const std::vector<TrackingEvent>& events); | 146 const std::vector<TrackingEvent>& events); |
| 147 | 147 |
| 148 std::vector<TrackingEvent> events_; | 148 std::vector<TrackingEvent> events_; |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 void AccountTrackerObserver::OnAccountAdded(const AccountIds& ids) { | 151 void AccountTrackerObserver::OnAccountAdded(const AccountIds& ids) { |
| 152 events_.push_back(TrackingEvent(ADDED, ids.email, ids.gaia)); | 152 events_.push_back(TrackingEvent(ADDED, ids.email, ids.gaia)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 events_.clear(); | 259 events_.clear(); |
| 260 return result; | 260 return result; |
| 261 } | 261 } |
| 262 | 262 |
| 263 class IdentityAccountTrackerTest : public testing::Test { | 263 class IdentityAccountTrackerTest : public testing::Test { |
| 264 public: | 264 public: |
| 265 IdentityAccountTrackerTest() {} | 265 IdentityAccountTrackerTest() {} |
| 266 | 266 |
| 267 virtual ~IdentityAccountTrackerTest() {} | 267 virtual ~IdentityAccountTrackerTest() {} |
| 268 | 268 |
| 269 virtual void SetUp() OVERRIDE { | 269 virtual void SetUp() override { |
| 270 | 270 |
| 271 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); | 271 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); |
| 272 | 272 |
| 273 fake_identity_provider_.reset( | 273 fake_identity_provider_.reset( |
| 274 new FakeIdentityProvider(fake_oauth2_token_service_.get())); | 274 new FakeIdentityProvider(fake_oauth2_token_service_.get())); |
| 275 | 275 |
| 276 account_tracker_.reset( | 276 account_tracker_.reset( |
| 277 new AccountTracker(fake_identity_provider_.get(), | 277 new AccountTracker(fake_identity_provider_.get(), |
| 278 new net::TestURLRequestContextGetter( | 278 new net::TestURLRequestContextGetter( |
| 279 message_loop_.message_loop_proxy()))); | 279 message_loop_.message_loop_proxy()))); |
| 280 account_tracker_->AddObserver(&observer_); | 280 account_tracker_->AddObserver(&observer_); |
| 281 } | 281 } |
| 282 | 282 |
| 283 virtual void TearDown() OVERRIDE { | 283 virtual void TearDown() override { |
| 284 account_tracker_->RemoveObserver(&observer_); | 284 account_tracker_->RemoveObserver(&observer_); |
| 285 account_tracker_->Shutdown(); | 285 account_tracker_->Shutdown(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 AccountTrackerObserver* observer() { | 288 AccountTrackerObserver* observer() { |
| 289 return &observer_; | 289 return &observer_; |
| 290 } | 290 } |
| 291 | 291 |
| 292 AccountTracker* account_tracker() { | 292 AccountTracker* account_tracker() { |
| 293 return account_tracker_.get(); | 293 return account_tracker_.get(); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 EXPECT_TRUE(ids.email.empty()); | 807 EXPECT_TRUE(ids.email.empty()); |
| 808 EXPECT_TRUE(ids.gaia.empty()); | 808 EXPECT_TRUE(ids.gaia.empty()); |
| 809 | 809 |
| 810 ids = account_tracker()->FindAccountIdsByGaiaId("alpha@example.com"); | 810 ids = account_tracker()->FindAccountIdsByGaiaId("alpha@example.com"); |
| 811 EXPECT_TRUE(ids.account_key.empty()); | 811 EXPECT_TRUE(ids.account_key.empty()); |
| 812 EXPECT_TRUE(ids.email.empty()); | 812 EXPECT_TRUE(ids.email.empty()); |
| 813 EXPECT_TRUE(ids.gaia.empty()); | 813 EXPECT_TRUE(ids.gaia.empty()); |
| 814 } | 814 } |
| 815 | 815 |
| 816 } // namespace gaia | 816 } // namespace gaia |
| OLD | NEW |