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 // SyncTest implementation. | |
23 void SetUp() override { | |
24 wifi_credentials_helper::SetUp(); | |
25 SyncTest::SetUp(); | |
26 } | |
stevenjb
2015/01/28 23:02:50
WS
mukesh agrawal
2015/01/30 22:28:14
Done.
| |
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 } |
31 bool SetupClients() override { | |
32 return SyncTest::SetupClients() && | |
33 wifi_credentials_helper::SetupClients(); | |
34 } | |
20 | 35 |
21 private: | 36 private: |
22 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); | 37 DISALLOW_COPY_AND_ASSIGN(TwoClientWifiCredentialsSyncTest); |
23 }; | 38 }; |
24 | 39 |
25 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { | 40 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, NoCredentials) { |
26 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
27 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); | 42 ASSERT_TRUE(wifi_credentials_helper::VerifierIsEmpty()); |
28 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); | 43 ASSERT_TRUE(wifi_credentials_helper::AllProfilesMatch()); |
29 } | 44 } |
45 | |
46 IN_PROC_BROWSER_TEST_F(TwoClientWifiCredentialsSyncTest, SingleCredential) { | |
47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
48 | |
49 scoped_ptr<WifiCredential> credential = | |
50 wifi_credentials_helper::MakeWifiCredential( | |
51 "fake-ssid", wifi_sync::SECURITY_CLASS_PSK, "fake_passphrase"); | |
52 ASSERT_TRUE(credential); | |
53 | |
54 const size_t profile_a_index = 0; | |
55 const size_t profile_b_index = 1; | |
56 wifi_credentials_helper::AddWifiCredential( | |
57 profile_a_index, "fake_id", *credential); | |
58 ASSERT_TRUE(GetClient(profile_a_index)->AwaitMutualSyncCycleCompletion( | |
59 GetClient(profile_b_index))); | |
60 EXPECT_FALSE(wifi_credentials_helper::VerifierIsEmpty()); | |
61 EXPECT_TRUE(wifi_credentials_helper::AllProfilesMatch()); | |
62 } | |
OLD | NEW |