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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 466 |
466 // The allow_stale_read flag is set if the sync was not forced. | 467 // The allow_stale_read flag is set if the sync was not forced. |
467 bool allow_stale_read = | 468 bool allow_stale_read = |
468 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) != | 469 pref_service_.GetInteger(prefs::kCryptAuthDeviceSyncReason) != |
469 INVOCATION_REASON_UNKNOWN; | 470 INVOCATION_REASON_UNKNOWN; |
470 EXPECT_EQ(allow_stale_read, get_my_devices_request_.allow_stale_read()); | 471 EXPECT_EQ(allow_stale_read, get_my_devices_request_.allow_stale_read()); |
471 } | 472 } |
472 | 473 |
473 // MockCryptAuthClientFactory::Observer: | 474 // MockCryptAuthClientFactory::Observer: |
474 void OnCryptAuthClientCreated(MockCryptAuthClient* client) override { | 475 void OnCryptAuthClientCreated(MockCryptAuthClient* client) override { |
475 EXPECT_CALL(*client, GetMyDevices(_, _, _)) | 476 EXPECT_CALL(*client, GetMyDevices(_, _, _, _)) |
476 .WillOnce(DoAll(SaveArg<0>(&get_my_devices_request_), | 477 .WillOnce(DoAll(SaveArg<0>(&get_my_devices_request_), |
477 SaveArg<1>(&success_callback_), | 478 SaveArg<1>(&success_callback_), |
478 SaveArg<2>(&error_callback_))); | 479 SaveArg<2>(&error_callback_))); |
479 } | 480 } |
480 | 481 |
481 MockSyncScheduler* sync_scheduler() { | 482 MockSyncScheduler* sync_scheduler() { |
482 return device_manager_->GetSyncScheduler().get(); | 483 return device_manager_->GetSyncScheduler().get(); |
483 } | 484 } |
484 | 485 |
485 // Owned by |device_manager_|. | 486 // Owned by |device_manager_|. |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), | 900 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), |
900 device_manager_->GetUnlockKeys()); | 901 device_manager_->GetUnlockKeys()); |
901 | 902 |
902 // Only tether hosts. | 903 // Only tether hosts. |
903 ExpectSyncedDevicesAreEqual( | 904 ExpectSyncedDevicesAreEqual( |
904 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), | 905 std::vector<ExternalDeviceInfo>(1, devices_in_response_[0]), |
905 device_manager_->GetTetherHosts()); | 906 device_manager_->GetTetherHosts()); |
906 } | 907 } |
907 | 908 |
908 } // namespace cryptauth | 909 } // namespace cryptauth |
OLD | NEW |