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

Side by Side Diff: google_apis/gaia/account_tracker_unittest.cc

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 22
23 const char kPrimaryAccountKey[] = "primary_account@example.com"; 23 const char kPrimaryAccountKey[] = "primary_account@example.com";
24 24
25 enum TrackingEventType { 25 enum TrackingEventType {
26 ADDED, 26 ADDED,
27 REMOVED, 27 REMOVED,
28 SIGN_IN, 28 SIGN_IN,
29 SIGN_OUT 29 SIGN_OUT
30 }; 30 };
31 31
32 std::string AccountKeyToObfuscatedId(const std::string email) { 32 std::string AccountKeyToObfuscatedId(const std::string& email) {
33 return "obfid-" + email; 33 return "obfid-" + email;
34 } 34 }
35 35
36 class TrackingEvent { 36 class TrackingEvent {
37 public: 37 public:
38 TrackingEvent(TrackingEventType type, 38 TrackingEvent(TrackingEventType type,
39 const std::string& account_key, 39 const std::string& account_key,
40 const std::string& gaia_id) 40 const std::string& gaia_id)
41 : type_(type), 41 : type_(type),
42 account_key_(account_key), 42 account_key_(account_key),
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 AccountTrackerObserver* observer() { 287 AccountTrackerObserver* observer() {
288 return &observer_; 288 return &observer_;
289 } 289 }
290 290
291 AccountTracker* account_tracker() { 291 AccountTracker* account_tracker() {
292 return account_tracker_.get(); 292 return account_tracker_.get();
293 } 293 }
294 294
295 // Helpers to pass fake events to the tracker. 295 // Helpers to pass fake events to the tracker.
296 296
297 void NotifyLogin(const std::string account_key) { 297 void NotifyLogin(const std::string& account_key) {
298 identity_provider()->LogIn(account_key); 298 identity_provider()->LogIn(account_key);
299 } 299 }
300 300
301 void NotifyLogout() { identity_provider()->LogOut(); } 301 void NotifyLogout() { identity_provider()->LogOut(); }
302 302
303 void NotifyTokenAvailable(const std::string& username) { 303 void NotifyTokenAvailable(const std::string& username) {
304 fake_oauth2_token_service_->AddAccount(username); 304 fake_oauth2_token_service_->AddAccount(username);
305 } 305 }
306 306
307 void NotifyTokenRevoked(const std::string& username) { 307 void NotifyTokenRevoked(const std::string& username) {
308 fake_oauth2_token_service_->RemoveAccount(username); 308 fake_oauth2_token_service_->RemoveAccount(username);
309 } 309 }
310 310
311 // Helpers to fake access token and user info fetching 311 // Helpers to fake access token and user info fetching
312 void IssueAccessToken(const std::string& username) { 312 void IssueAccessToken(const std::string& username) {
313 fake_oauth2_token_service_->IssueAllTokensForAccount( 313 fake_oauth2_token_service_->IssueAllTokensForAccount(
314 username, "access_token-" + username, base::Time::Max()); 314 username, "access_token-" + username, base::Time::Max());
315 } 315 }
316 316
317 std::string GetValidTokenInfoResponse(const std::string account_key) { 317 std::string GetValidTokenInfoResponse(const std::string& account_key) {
318 return std::string("{ \"id\": \"") + AccountKeyToObfuscatedId(account_key) + 318 return std::string("{ \"id\": \"") + AccountKeyToObfuscatedId(account_key) +
319 "\" }"; 319 "\" }";
320 } 320 }
321 321
322 void ReturnOAuthUrlFetchResults(int fetcher_id, 322 void ReturnOAuthUrlFetchResults(int fetcher_id,
323 net::HttpStatusCode response_code, 323 net::HttpStatusCode response_code,
324 const std::string& response_string); 324 const std::string& response_string);
325 325
326 void ReturnOAuthUrlFetchSuccess(const std::string& account_key); 326 void ReturnOAuthUrlFetchSuccess(const std::string& account_key);
327 void ReturnOAuthUrlFetchFailure(const std::string& account_key); 327 void ReturnOAuthUrlFetchFailure(const std::string& account_key);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 EXPECT_TRUE(ids.email.empty()); 806 EXPECT_TRUE(ids.email.empty());
807 EXPECT_TRUE(ids.gaia.empty()); 807 EXPECT_TRUE(ids.gaia.empty());
808 808
809 ids = account_tracker()->FindAccountIdsByGaiaId("alpha@example.com"); 809 ids = account_tracker()->FindAccountIdsByGaiaId("alpha@example.com");
810 EXPECT_TRUE(ids.account_key.empty()); 810 EXPECT_TRUE(ids.account_key.empty());
811 EXPECT_TRUE(ids.email.empty()); 811 EXPECT_TRUE(ids.email.empty());
812 EXPECT_TRUE(ids.gaia.empty()); 812 EXPECT_TRUE(ids.gaia.empty());
813 } 813 }
814 814
815 } // namespace gaia 815 } // namespace gaia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698