| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/cryptauth/cryptauth_device_manager.h" | 5 #include "components/cryptauth/cryptauth_device_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/base64url.h" | 11 #include "base/base64url.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/test/simple_test_clock.h" | 17 #include "base/test/simple_test_clock.h" |
| 18 #include "components/cryptauth/fake_cryptauth_gcm_manager.h" | 18 #include "components/cryptauth/fake_cryptauth_gcm_manager.h" |
| 19 #include "components/cryptauth/mock_cryptauth_client.h" | 19 #include "components/cryptauth/mock_cryptauth_client.h" |
| 20 #include "components/cryptauth/mock_sync_scheduler.h" | 20 #include "components/cryptauth/mock_sync_scheduler.h" |
| 21 #include "components/cryptauth/pref_names.h" | 21 #include "components/cryptauth/pref_names.h" |
| 22 #include "components/prefs/scoped_user_pref_update.h" | 22 #include "components/prefs/scoped_user_pref_update.h" |
| 23 #include "components/prefs/testing_pref_service.h" | 23 #include "components/prefs/testing_pref_service.h" |
| 24 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 using ::testing::_; | 28 using ::testing::_; |
| 28 using ::testing::DoAll; | 29 using ::testing::DoAll; |
| 29 using ::testing::NiceMock; | 30 using ::testing::NiceMock; |
| 30 using ::testing::Return; | 31 using ::testing::Return; |
| 31 using ::testing::SaveArg; | 32 using ::testing::SaveArg; |
| 32 | 33 |
| 33 namespace cryptauth { | 34 namespace cryptauth { |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 463 |
| 463 // The allow_stale_read flag is set if the sync was not forced. | 464 // The allow_stale_read flag is set if the sync was not forced. |
| 464 bool allow_stale_read = | 465 bool allow_stale_read = |
| 465 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) != | 466 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) != |
| 466 INVOCATION_REASON_UNKNOWN; | 467 INVOCATION_REASON_UNKNOWN; |
| 467 EXPECT_EQ(allow_stale_read, get_my_devices_request_.allow_stale_read()); | 468 EXPECT_EQ(allow_stale_read, get_my_devices_request_.allow_stale_read()); |
| 468 } | 469 } |
| 469 | 470 |
| 470 // MockCryptAuthClientFactory::Observer: | 471 // MockCryptAuthClientFactory::Observer: |
| 471 void OnCryptAuthClientCreated(MockCryptAuthClient* client) override { | 472 void OnCryptAuthClientCreated(MockCryptAuthClient* client) override { |
| 472 EXPECT_CALL(*client, GetMyDevices(_, _, _)) | 473 EXPECT_CALL(*client, GetMyDevices(_, _, _, _)) |
| 473 .WillOnce(DoAll(SaveArg<0>(&get_my_devices_request_), | 474 .WillOnce(DoAll(SaveArg<0>(&get_my_devices_request_), |
| 474 SaveArg<1>(&success_callback_), | 475 SaveArg<1>(&success_callback_), |
| 475 SaveArg<2>(&error_callback_))); | 476 SaveArg<2>(&error_callback_))); |
| 476 } | 477 } |
| 477 | 478 |
| 478 MockSyncScheduler* sync_scheduler() { | 479 MockSyncScheduler* sync_scheduler() { |
| 479 return device_manager_->GetSyncScheduler().get(); | 480 return device_manager_->GetSyncScheduler().get(); |
| 480 } | 481 } |
| 481 | 482 |
| 482 // Owned by |device_manager_|. | 483 // Owned by |device_manager_|. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), | 897 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), |
| 897 device_manager_->GetUnlockKeys()); | 898 device_manager_->GetUnlockKeys()); |
| 898 | 899 |
| 899 // Only tether hosts. | 900 // Only tether hosts. |
| 900 ExpectSyncedDevicesAreEqual( | 901 ExpectSyncedDevicesAreEqual( |
| 901 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), | 902 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), |
| 902 device_manager_->GetTetherHosts()); | 903 device_manager_->GetTetherHosts()); |
| 903 } | 904 } |
| 904 | 905 |
| 905 } // namespace cryptauth | 906 } // namespace cryptauth |
| OLD | NEW |