| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "components/sync_driver/local_device_info_provider_impl.h" | 8 #include "components/sync_driver/local_device_info_provider_impl.h" |
| 9 #include "components/version_info/version_info.h" | 9 #include "components/version_info/version_info.h" |
| 10 #include "sync/util/get_session_name.h" | 10 #include "sync/util/get_session_name.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 protected: | 37 protected: |
| 38 void InitializeProvider() { | 38 void InitializeProvider() { |
| 39 // Start initialization. | 39 // Start initialization. |
| 40 provider_->Initialize(kLocalDeviceGuid, | 40 provider_->Initialize(kLocalDeviceGuid, |
| 41 kSigninScopedDeviceId, | 41 kSigninScopedDeviceId, |
| 42 message_loop_.task_runner()); | 42 message_loop_.task_runner()); |
| 43 | 43 |
| 44 // Subscribe to the notification and wait until the callback | 44 // Subscribe to the notification and wait until the callback |
| 45 // is called. The callback will quit the loop. | 45 // is called. The callback will quit the loop. |
| 46 base::RunLoop run_loop; | 46 base::RunLoop run_loop; |
| 47 scoped_ptr<LocalDeviceInfoProvider::Subscription> subscription( | 47 std::unique_ptr<LocalDeviceInfoProvider::Subscription> subscription( |
| 48 provider_->RegisterOnInitializedCallback( | 48 provider_->RegisterOnInitializedCallback( |
| 49 base::Bind(&SyncLocalDeviceInfoProviderTest::QuitLoopOnInitialized, | 49 base::Bind(&SyncLocalDeviceInfoProviderTest::QuitLoopOnInitialized, |
| 50 base::Unretained(this), &run_loop))); | 50 base::Unretained(this), &run_loop))); |
| 51 run_loop.Run(); | 51 run_loop.Run(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void QuitLoopOnInitialized(base::RunLoop* loop) { | 54 void QuitLoopOnInitialized(base::RunLoop* loop) { |
| 55 called_back_ = true; | 55 called_back_ = true; |
| 56 loop->Quit(); | 56 loop->Quit(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 scoped_ptr<LocalDeviceInfoProviderImpl> provider_; | 59 std::unique_ptr<LocalDeviceInfoProviderImpl> provider_; |
| 60 | 60 |
| 61 bool called_back_; | 61 bool called_back_; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 base::MessageLoop message_loop_; | 64 base::MessageLoop message_loop_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 TEST_F(SyncLocalDeviceInfoProviderTest, OnInitializedCallback) { | 67 TEST_F(SyncLocalDeviceInfoProviderTest, OnInitializedCallback) { |
| 68 ASSERT_FALSE(called_back_); | 68 ASSERT_FALSE(called_back_); |
| 69 | 69 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 TEST_F(SyncLocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) { | 91 TEST_F(SyncLocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) { |
| 92 ASSERT_EQ(std::string(), provider_->GetLocalSyncCacheGUID()); | 92 ASSERT_EQ(std::string(), provider_->GetLocalSyncCacheGUID()); |
| 93 | 93 |
| 94 InitializeProvider(); | 94 InitializeProvider(); |
| 95 | 95 |
| 96 EXPECT_EQ(std::string(kLocalDeviceGuid), provider_->GetLocalSyncCacheGUID()); | 96 EXPECT_EQ(std::string(kLocalDeviceGuid), provider_->GetLocalSyncCacheGUID()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace browser_sync | 99 } // namespace browser_sync |
| OLD | NEW |