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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 needs_comma = true; | 91 needs_comma = true; |
92 str += it->ToString(); | 92 str += it->ToString(); |
93 } | 93 } |
94 str += "]"; | 94 str += "]"; |
95 return str; | 95 return str; |
96 } | 96 } |
97 | 97 |
98 class AccountTrackerObserver : public AccountTrackerService::Observer { | 98 class AccountTrackerObserver : public AccountTrackerService::Observer { |
99 public: | 99 public: |
100 AccountTrackerObserver() {} | 100 AccountTrackerObserver() {} |
101 virtual ~AccountTrackerObserver() {} | 101 ~AccountTrackerObserver() override {} |
102 | 102 |
103 void Clear(); | 103 void Clear(); |
104 void SortEventsByUser(); | 104 void SortEventsByUser(); |
105 | 105 |
106 testing::AssertionResult CheckEvents(); | 106 testing::AssertionResult CheckEvents(); |
107 testing::AssertionResult CheckEvents(const TrackingEvent& e1); | 107 testing::AssertionResult CheckEvents(const TrackingEvent& e1); |
108 testing::AssertionResult CheckEvents(const TrackingEvent& e1, | 108 testing::AssertionResult CheckEvents(const TrackingEvent& e1, |
109 const TrackingEvent& e2); | 109 const TrackingEvent& e2); |
110 testing::AssertionResult CheckEvents(const TrackingEvent& e1, | 110 testing::AssertionResult CheckEvents(const TrackingEvent& e1, |
111 const TrackingEvent& e2, | 111 const TrackingEvent& e2, |
112 const TrackingEvent& e3); | 112 const TrackingEvent& e3); |
113 | 113 |
114 private: | 114 private: |
115 // AccountTrackerService::Observer implementation | 115 // AccountTrackerService::Observer implementation |
116 virtual void OnAccountUpdated( | 116 void OnAccountUpdated(const AccountTrackerService::AccountInfo& ids) override; |
117 const AccountTrackerService::AccountInfo& ids) override; | 117 void OnAccountRemoved(const AccountTrackerService::AccountInfo& ids) override; |
118 virtual void OnAccountRemoved( | |
119 const AccountTrackerService::AccountInfo& ids) override; | |
120 | 118 |
121 testing::AssertionResult CheckEvents( | 119 testing::AssertionResult CheckEvents( |
122 const std::vector<TrackingEvent>& events); | 120 const std::vector<TrackingEvent>& events); |
123 | 121 |
124 std::vector<TrackingEvent> events_; | 122 std::vector<TrackingEvent> events_; |
125 }; | 123 }; |
126 | 124 |
127 void AccountTrackerObserver::OnAccountUpdated( | 125 void AccountTrackerObserver::OnAccountUpdated( |
128 const AccountTrackerService::AccountInfo& ids) { | 126 const AccountTrackerService::AccountInfo& ids) { |
129 events_.push_back(TrackingEvent(UPDATED, ids.account_id, ids.gaia)); | 127 events_.push_back(TrackingEvent(UPDATED, ids.account_id, ids.gaia)); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 498 |
501 std::vector<AccountTrackerService::AccountInfo> infos = | 499 std::vector<AccountTrackerService::AccountInfo> infos = |
502 tracker.GetAccounts(); | 500 tracker.GetAccounts(); |
503 ASSERT_EQ(1u, infos.size()); | 501 ASSERT_EQ(1u, infos.size()); |
504 EXPECT_EQ("beta", infos[0].account_id); | 502 EXPECT_EQ("beta", infos[0].account_id); |
505 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia); | 503 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia); |
506 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email); | 504 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email); |
507 tracker.Shutdown(); | 505 tracker.Shutdown(); |
508 } | 506 } |
509 } | 507 } |
OLD | NEW |