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 | |
mukesh agrawal
2015/02/02 20:36:40
Removed stale using.
| |
16 using WifiCredentialSet = wifi_sync::WifiCredential::CredentialSet; | |
10 | 17 |
11 class TwoClientWifiCredentialsSyncTest : public SyncTest { | 18 class TwoClientWifiCredentialsSyncTest : public SyncTest { |
12 public: | 19 public: |
13 TwoClientWifiCredentialsSyncTest() : SyncTest(TWO_CLIENT) {} | 20 TwoClientWifiCredentialsSyncTest() : SyncTest(TWO_CLIENT) {} |
14 ~TwoClientWifiCredentialsSyncTest() override {} | 21 ~TwoClientWifiCredentialsSyncTest() override {} |
15 | 22 |
23 // SyncTest implementation. | |
24 void SetUp() override { | |
25 wifi_credentials_helper::SetUp(); | |
26 SyncTest::SetUp(); | |
27 } | |
28 | |
16 void SetUpCommandLine(base::CommandLine* command_line) override { | 29 void SetUpCommandLine(base::CommandLine* command_line) override { |
17 SyncTest::SetUpCommandLine(command_line); | 30 SyncTest::SetUpCommandLine(command_line); |
18 command_line->AppendSwitch(switches::kEnableWifiCredentialSync); | 31 command_line->AppendSwitch(switches::kEnableWifiCredentialSync); |
19 } | 32 } |
20 | 33 |
34 bool SetupClients() override { | |
35 if (!SyncTest::SetupClients()) | |
36 return false; | |
37 wifi_credentials_helper::SetupClients(); | |
38 return true; | |
39 } | |
40 | |
21 private: | 41 private: |
22 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); | 42 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); |
23 }; | 43 }; |
24 | 44 |
25 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { | 45 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { |
26 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 46 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
27 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); | 47 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); |
28 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); | 48 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); |
29 } | 49 } |
50 | |
51 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, SingleCredential) { | |
52 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
53 | |
54 const char ssid[] = "fake-ssid"; | |
55 scoped_ptr<WifiCredential> credential = | |
56 wifi_credentials_helper::MakeWifiCredential( | |
57 ssid, wifi_sync::SECURITY_CLASS_PSK, "fake_passphrase"); | |
58 ASSERT_TRUE(credential); | |
59 | |
60 const size_t profile_a_index = 0; | |
61 wifi_credentials_helper::AddWifiCredential( | |
62 profile_a_index, "fake_id", *credential); | |
63 | |
64 const WifiCredentialSet verifier_credentials = | |
65 wifi_credentials_helper::GetWifiCredentialsForProfile(verifier()); | |
66 EXPECT_EQ(1U, verifier_credentials.size()); | |
67 EXPECT_EQ(WifiCredential::MakeSsidBytesForTest(ssid), | |
68 verifier_credentials.begin()->ssid()); | |
69 | |
70 const size_t profile_b_index = 1; | |
71 ASSERT_TRUE(GetClient(profile_a_index)->AwaitMutualSyncCycleCompletion( | |
72 GetClient(profile_b_index))); | |
73 EXPECT_FALSE(wifi_credentials_helper::VerifierIsEmpty()); | |
74 EXPECT_TRUE(wifi_credentials_helper::AllProfilesMatch()); | |
75 } | |
OLD | NEW |