| 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/wifi_sync/wifi_credential_syncable_service.h" | 5 #include "components/sync_wifi/wifi_credential_syncable_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
| 18 #include "components/sync/model/attachments/attachment_id.h" | 18 #include "components/sync/model/attachments/attachment_id.h" |
| 19 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" | 19 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" |
| 20 #include "components/sync/model/fake_sync_change_processor.h" | 20 #include "components/sync/model/fake_sync_change_processor.h" |
| 21 #include "components/sync/model/sync_change.h" | 21 #include "components/sync/model/sync_change.h" |
| 22 #include "components/sync/model/sync_data.h" | 22 #include "components/sync/model/sync_data.h" |
| 23 #include "components/sync/model/sync_error.h" | 23 #include "components/sync/model/sync_error.h" |
| 24 #include "components/sync/model/sync_error_factory_mock.h" | 24 #include "components/sync/model/sync_error_factory_mock.h" |
| 25 #include "components/sync/protocol/sync.pb.h" | 25 #include "components/sync/protocol/sync.pb.h" |
| 26 #include "components/wifi_sync/wifi_config_delegate.h" | 26 #include "components/sync_wifi/wifi_config_delegate.h" |
| 27 #include "components/wifi_sync/wifi_credential.h" | 27 #include "components/sync_wifi/wifi_credential.h" |
| 28 #include "components/wifi_sync/wifi_security_class.h" | 28 #include "components/sync_wifi/wifi_security_class.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 30 |
| 31 namespace wifi_sync { | 31 namespace sync_wifi { |
| 32 | 32 |
| 33 using syncer::FakeSyncChangeProcessor; | 33 using syncer::FakeSyncChangeProcessor; |
| 34 using syncer::SyncErrorFactoryMock; | 34 using syncer::SyncErrorFactoryMock; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 const char kSsid[] = "fake-ssid"; | 38 const char kSsid[] = "fake-ssid"; |
| 39 const char kSsidNonUtf8[] = "\xc0"; | 39 const char kSsidNonUtf8[] = "\xc0"; |
| 40 | 40 |
| 41 // Fake implementation of WifiConfigDelegate, which provides the | 41 // Fake implementation of WifiConfigDelegate, which provides the |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); | 287 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); |
| 288 EXPECT_EQ(1, change_processor_changes_size()); | 288 EXPECT_EQ(1, change_processor_changes_size()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 TEST_F(WifiCredentialSyncableServiceTest, | 291 TEST_F(WifiCredentialSyncableServiceTest, |
| 292 AddToSyncedNetworksDifferentSecurityClassesSuccess) { | 292 AddToSyncedNetworksDifferentSecurityClassesSuccess) { |
| 293 StartSyncing(); | 293 StartSyncing(); |
| 294 EXPECT_TRUE(AddToSyncedNetworks( | 294 EXPECT_TRUE(AddToSyncedNetworks( |
| 295 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); | 295 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); |
| 296 EXPECT_TRUE(AddToSyncedNetworks( | 296 EXPECT_TRUE(AddToSyncedNetworks( |
| 297 "fake-item-id-2", | 297 "fake-item-id-2", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_WEP, ""))); |
| 298 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_WEP, ""))); | |
| 299 EXPECT_EQ(2, change_processor_changes_size()); | 298 EXPECT_EQ(2, change_processor_changes_size()); |
| 300 } | 299 } |
| 301 | 300 |
| 302 TEST_F(WifiCredentialSyncableServiceTest, | 301 TEST_F(WifiCredentialSyncableServiceTest, |
| 303 AddToSyncedNetworksDifferentSsidsSuccess) { | 302 AddToSyncedNetworksDifferentSsidsSuccess) { |
| 304 StartSyncing(); | 303 StartSyncing(); |
| 305 EXPECT_TRUE(AddToSyncedNetworks( | 304 EXPECT_TRUE(AddToSyncedNetworks( |
| 306 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); | 305 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); |
| 307 EXPECT_TRUE(AddToSyncedNetworks( | 306 EXPECT_TRUE(AddToSyncedNetworks( |
| 308 "fake-item-id-2", MakeCredential(kSsid, SECURITY_CLASS_NONE, ""))); | 307 "fake-item-id-2", MakeCredential(kSsid, SECURITY_CLASS_NONE, ""))); |
| 309 EXPECT_EQ(2, change_processor_changes_size()); | 308 EXPECT_EQ(2, change_processor_changes_size()); |
| 310 } | 309 } |
| 311 | 310 |
| 312 TEST_F(WifiCredentialSyncableServiceTest, | 311 TEST_F(WifiCredentialSyncableServiceTest, |
| 313 AddToSyncedNetworksDuplicateAddPskNetwork) { | 312 AddToSyncedNetworksDuplicateAddPskNetwork) { |
| 314 const std::string passphrase("psk-passphrase"); | 313 const std::string passphrase("psk-passphrase"); |
| 315 StartSyncing(); | 314 StartSyncing(); |
| 316 EXPECT_TRUE( | 315 EXPECT_TRUE(AddToSyncedNetworks( |
| 317 AddToSyncedNetworks( | 316 "fake-item-id", |
| 318 "fake-item-id", | 317 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_PSK, passphrase))); |
| 319 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_PSK, passphrase))); | |
| 320 EXPECT_EQ(1, change_processor_changes_size()); | 318 EXPECT_EQ(1, change_processor_changes_size()); |
| 321 EXPECT_FALSE( | 319 EXPECT_FALSE(AddToSyncedNetworks( |
| 322 AddToSyncedNetworks( | 320 "fake-item-id", |
| 323 "fake-item-id", | 321 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_PSK, passphrase))); |
| 324 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_PSK, passphrase))); | |
| 325 EXPECT_EQ(1, change_processor_changes_size()); | 322 EXPECT_EQ(1, change_processor_changes_size()); |
| 326 } | 323 } |
| 327 | 324 |
| 328 TEST_F(WifiCredentialSyncableServiceTest, | 325 TEST_F(WifiCredentialSyncableServiceTest, |
| 329 AddToSyncedNetworksDuplicateAddOpenNetwork) { | 326 AddToSyncedNetworksDuplicateAddOpenNetwork) { |
| 330 StartSyncing(); | 327 StartSyncing(); |
| 331 EXPECT_TRUE( | 328 EXPECT_TRUE(AddToSyncedNetworks( |
| 332 AddToSyncedNetworks( | 329 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); |
| 333 "fake-item-id", | |
| 334 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); | |
| 335 EXPECT_EQ(1, change_processor_changes_size()); | 330 EXPECT_EQ(1, change_processor_changes_size()); |
| 336 EXPECT_FALSE( | 331 EXPECT_FALSE(AddToSyncedNetworks( |
| 337 AddToSyncedNetworks( | 332 "fake-item-id", MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); |
| 338 "fake-item-id", | |
| 339 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""))); | |
| 340 EXPECT_EQ(1, change_processor_changes_size()); | 333 EXPECT_EQ(1, change_processor_changes_size()); |
| 341 } | 334 } |
| 342 | 335 |
| 343 } // namespace wifi_sync | 336 } // namespace sync_wifi |
| OLD | NEW |