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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
7 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
8 #include "chrome/browser/sync/test/integration/wifi_credentials_helper.h" | 9 #include "chrome/browser/sync/test/integration/wifi_credentials_helper.h" |
9 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "components/wifi_sync/wifi_credential.h" |
| 12 #include "components/wifi_sync/wifi_security_class.h" |
| 13 |
| 14 using wifi_sync::WifiCredential; |
| 15 using SsidBytes = wifi_sync::WifiCredential::SsidBytes; |
10 | 16 |
11 class TwoClientWifiCredentialsSyncTest : public SyncTest { | 17 class TwoClientWifiCredentialsSyncTest : public SyncTest { |
12 public: | 18 public: |
13 TwoClientWifiCredentialsSyncTest() : SyncTest(TWO_CLIENT) {} | 19 TwoClientWifiCredentialsSyncTest() : SyncTest(TWO_CLIENT) {} |
14 ~TwoClientWifiCredentialsSyncTest() override {} | 20 ~TwoClientWifiCredentialsSyncTest() override {} |
15 | 21 |
| 22 void SetUp() override { |
| 23 wifi_credentials_helper::SetUp(); |
| 24 SyncTest::SetUp(); |
| 25 } |
| 26 |
16 void SetUpCommandLine(base::CommandLine* command_line) override { | 27 void SetUpCommandLine(base::CommandLine* command_line) override { |
17 SyncTest::SetUpCommandLine(command_line); | 28 SyncTest::SetUpCommandLine(command_line); |
18 command_line->AppendSwitch(switches::kEnableWifiCredentialSync); | 29 command_line->AppendSwitch(switches::kEnableWifiCredentialSync); |
19 } | 30 } |
20 | 31 |
| 32 bool SetupClients() override { |
| 33 return SyncTest::SetupClients() && |
| 34 wifi_credentials_helper::SetupClients(); |
| 35 } |
| 36 |
21 private: | 37 private: |
22 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); | 38 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); |
23 }; | 39 }; |
24 | 40 |
25 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { | 41 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { |
26 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
27 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); | 43 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); |
28 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); | 44 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); |
29 } | 45 } |
| 46 |
| 47 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, SingleCredential) { |
| 48 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 49 const size_t kProfileAIndex = 0; |
| 50 const size_t kProfileBIndex = 1; |
| 51 wifi_credentials_helper::AddWifiCredential( |
| 52 kProfileAIndex, |
| 53 "fake_id", |
| 54 WifiCredential( |
| 55 WifiCredential::MakeSsidBytes("fake-ssid"), |
| 56 wifi_sync::SECURITY_CLASS_NONE, |
| 57 "fake_passphrase")); |
| 58 ASSERT_TRUE(GetClient(kProfileAIndex)->AwaitMutualSyncCycleCompletion( |
| 59 GetClient(kProfileBIndex))); |
| 60 ASSERT_FALSE(wifi_credentials_helper::VerifierIsEmpty()); |
| 61 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); |
| 62 } |
OLD | NEW |