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

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
6 6
7 #include <stdint.h>
8
7 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
11 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 13 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate. h" 15 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate. h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" 16 #include "chrome/browser/chromeos/settings/device_settings_service.h"
15 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
16 #include "chrome/browser/chromeos/settings/token_encryptor.h" 18 #include "chrome/browser/chromeos/settings/token_encryptor.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void SetUpDefaultValues() { 71 void SetUpDefaultValues() {
70 SetDeviceRefreshTokenInLocalState("device_refresh_token_4_test"); 72 SetDeviceRefreshTokenInLocalState("device_refresh_token_4_test");
71 SetRobotAccountId("service_acct@g.com"); 73 SetRobotAccountId("service_acct@g.com");
72 CreateService(); 74 CreateService();
73 AssertConsumerTokensAndErrors(0, 0); 75 AssertConsumerTokensAndErrors(0, 0);
74 76
75 base::RunLoop().RunUntilIdle(); 77 base::RunLoop().RunUntilIdle();
76 } 78 }
77 79
78 void SetUpWithPendingSalt() { 80 void SetUpWithPendingSalt() {
79 fake_cryptohome_client_->set_system_salt(std::vector<uint8>()); 81 fake_cryptohome_client_->set_system_salt(std::vector<uint8_t>());
80 fake_cryptohome_client_->SetServiceIsAvailable(false); 82 fake_cryptohome_client_->SetServiceIsAvailable(false);
81 SetUpDefaultValues(); 83 SetUpDefaultValues();
82 } 84 }
83 85
84 void SetRobotAccountId(const std::string& account_id) { 86 void SetRobotAccountId(const std::string& account_id) {
85 device_policy_.policy_data().set_service_account_identity(account_id); 87 device_policy_.policy_data().set_service_account_identity(account_id);
86 device_policy_.Build(); 88 device_policy_.Build();
87 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); 89 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
88 DeviceSettingsService::Get()->Load(); 90 DeviceSettingsService::Get()->Load();
89 device_settings_test_helper_.Flush(); 91 device_settings_test_helper_.Flush();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 SetUpDefaultValues(); 329 SetUpDefaultValues();
328 scoped_ptr<OAuth2TokenService::Request> request = StartTokenRequest(); 330 scoped_ptr<OAuth2TokenService::Request> request = StartTokenRequest();
329 request.reset(); 331 request.reset();
330 332
331 PerformURLFetches(); 333 PerformURLFetches();
332 334
333 // Test succeeds if this line is reached without a crash. 335 // Test succeeds if this line is reached without a crash.
334 } 336 }
335 337
336 TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_NoSalt) { 338 TEST_F(DeviceOAuth2TokenServiceTest, RefreshTokenValidation_NoSalt) {
337 fake_cryptohome_client_->set_system_salt(std::vector<uint8>()); 339 fake_cryptohome_client_->set_system_salt(std::vector<uint8_t>());
338 fake_cryptohome_client_->SetServiceIsAvailable(true); 340 fake_cryptohome_client_->SetServiceIsAvailable(true);
339 SetUpDefaultValues(); 341 SetUpDefaultValues();
340 342
341 EXPECT_FALSE(RefreshTokenIsAvailable()); 343 EXPECT_FALSE(RefreshTokenIsAvailable());
342 344
343 scoped_ptr<OAuth2TokenService::Request> request = StartTokenRequest(); 345 scoped_ptr<OAuth2TokenService::Request> request = StartTokenRequest();
344 base::RunLoop().RunUntilIdle(); 346 base::RunLoop().RunUntilIdle();
345 347
346 AssertConsumerTokensAndErrors(0, 1); 348 AssertConsumerTokensAndErrors(0, 1);
347 } 349 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // Also make the robot account ID available. Verify that the token is 472 // Also make the robot account ID available. Verify that the token is
471 // announced now. 473 // announced now.
472 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com")); 474 EXPECT_CALL(observer, OnRefreshTokenAvailable("robot@example.com"));
473 SetRobotAccountId("robot@example.com"); 475 SetRobotAccountId("robot@example.com");
474 testing::Mock::VerifyAndClearExpectations(&observer); 476 testing::Mock::VerifyAndClearExpectations(&observer);
475 477
476 oauth2_service_->RemoveObserver(&observer); 478 oauth2_service_->RemoveObserver(&observer);
477 } 479 }
478 480
479 } // namespace chromeos 481 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698