| 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/base/get_session_name.h" | 8 #include "components/sync/base/get_session_name.h" |
| 9 #include "components/sync/device_info/local_device_info_provider_impl.h" | 9 #include "components/sync/device_info/local_device_info_provider_impl.h" |
| 10 #include "components/version_info/version_info.h" | 10 #include "components/version_info/version_info.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 using sync_driver::DeviceInfo; |
| 14 using sync_driver::LocalDeviceInfoProvider; |
| 15 |
| 16 namespace browser_sync { |
| 14 | 17 |
| 15 const char kLocalDeviceGuid[] = "foo"; | 18 const char kLocalDeviceGuid[] = "foo"; |
| 16 const char kSigninScopedDeviceId[] = "device_id"; | 19 const char kSigninScopedDeviceId[] = "device_id"; |
| 17 | 20 |
| 18 class LocalDeviceInfoProviderTest : public testing::Test { | 21 class LocalDeviceInfoProviderTest : public testing::Test { |
| 19 public: | 22 public: |
| 20 LocalDeviceInfoProviderTest() : called_back_(false) {} | 23 LocalDeviceInfoProviderTest() : called_back_(false) {} |
| 21 ~LocalDeviceInfoProviderTest() override {} | 24 ~LocalDeviceInfoProviderTest() override {} |
| 22 | 25 |
| 23 void SetUp() override { | 26 void SetUp() override { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); | 83 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); |
| 81 StartInitializeProvider(); | 84 StartInitializeProvider(); |
| 82 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); | 85 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); |
| 83 FinishInitializeProvider(); | 86 FinishInitializeProvider(); |
| 84 | 87 |
| 85 const DeviceInfo* local_device_info = provider_->GetLocalDeviceInfo(); | 88 const DeviceInfo* local_device_info = provider_->GetLocalDeviceInfo(); |
| 86 ASSERT_NE(nullptr, local_device_info); | 89 ASSERT_NE(nullptr, local_device_info); |
| 87 EXPECT_EQ(std::string(kLocalDeviceGuid), local_device_info->guid()); | 90 EXPECT_EQ(std::string(kLocalDeviceGuid), local_device_info->guid()); |
| 88 EXPECT_EQ(std::string(kSigninScopedDeviceId), | 91 EXPECT_EQ(std::string(kSigninScopedDeviceId), |
| 89 local_device_info->signin_scoped_device_id()); | 92 local_device_info->signin_scoped_device_id()); |
| 90 EXPECT_EQ(GetSessionNameSynchronouslyForTesting(), | 93 EXPECT_EQ(syncer::GetSessionNameSynchronouslyForTesting(), |
| 91 local_device_info->client_name()); | 94 local_device_info->client_name()); |
| 92 | 95 |
| 93 EXPECT_EQ(provider_->GetSyncUserAgent(), | 96 EXPECT_EQ(provider_->GetSyncUserAgent(), |
| 94 local_device_info->sync_user_agent()); | 97 local_device_info->sync_user_agent()); |
| 95 | 98 |
| 96 provider_->Clear(); | 99 provider_->Clear(); |
| 97 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); | 100 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); |
| 98 } | 101 } |
| 99 | 102 |
| 100 TEST_F(LocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) { | 103 TEST_F(LocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); | 136 ASSERT_EQ(nullptr, provider_->GetLocalDeviceInfo()); |
| 134 EXPECT_EQ(guid2, provider_->GetLocalSyncCacheGUID()); | 137 EXPECT_EQ(guid2, provider_->GetLocalSyncCacheGUID()); |
| 135 | 138 |
| 136 FinishInitializeProvider(); | 139 FinishInitializeProvider(); |
| 137 const DeviceInfo* local_device_info = provider_->GetLocalDeviceInfo(); | 140 const DeviceInfo* local_device_info = provider_->GetLocalDeviceInfo(); |
| 138 ASSERT_NE(nullptr, local_device_info); | 141 ASSERT_NE(nullptr, local_device_info); |
| 139 EXPECT_EQ(guid2, local_device_info->guid()); | 142 EXPECT_EQ(guid2, local_device_info->guid()); |
| 140 EXPECT_EQ(guid2, provider_->GetLocalSyncCacheGUID()); | 143 EXPECT_EQ(guid2, provider_->GetLocalSyncCacheGUID()); |
| 141 } | 144 } |
| 142 | 145 |
| 143 } // namespace syncer | 146 } // namespace browser_sync |
| OLD | NEW |