Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: components/sync_wifi/wifi_credential_unittest.cc

Issue 2463463004: [Sync] Rename wifi_sync to sync_wifi. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 5 #include "components/sync_wifi/wifi_credential.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/onc/onc_constants.h" 11 #include "components/onc/onc_constants.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace wifi_sync { 14 namespace sync_wifi {
15 15
16 namespace { 16 namespace {
17 17
18 const char kSsid[] = "fake-ssid"; 18 const char kSsid[] = "fake-ssid";
19 const char kSsidNonUtf8[] = "\xc0"; 19 const char kSsidNonUtf8[] = "\xc0";
20 const char kPassphraseWep[] = "abcde"; 20 const char kPassphraseWep[] = "abcde";
21 const char kPassphraseWepNonUtf8[] = "\xc0\xc0\xc0\xc0\xc0"; 21 const char kPassphraseWepNonUtf8[] = "\xc0\xc0\xc0\xc0\xc0";
22 const char kPassphrasePsk[] = "fake-psk-passphrase"; 22 const char kPassphrasePsk[] = "fake-psk-passphrase";
23 const char kPassphrase8021X[] = "fake-8021X-passphrase"; 23 const char kPassphrase8021X[] = "fake-8021X-passphrase";
24 24
25 WifiCredential MakeCredential(const std::string& ssid, 25 WifiCredential MakeCredential(const std::string& ssid,
26 WifiSecurityClass security_class, 26 WifiSecurityClass security_class,
27 const std::string& passphrase) { 27 const std::string& passphrase) {
28 std::unique_ptr<WifiCredential> credential = WifiCredential::Create( 28 std::unique_ptr<WifiCredential> credential = WifiCredential::Create(
29 WifiCredential::MakeSsidBytesForTest(ssid), security_class, passphrase); 29 WifiCredential::MakeSsidBytesForTest(ssid), security_class, passphrase);
30 CHECK(credential); 30 CHECK(credential);
31 return *credential; 31 return *credential;
32 } 32 }
33 33
34 bool TypeIsWifi(const base::DictionaryValue& onc_properties) { 34 bool TypeIsWifi(const base::DictionaryValue& onc_properties) {
35 std::string network_type; 35 std::string network_type;
36 EXPECT_TRUE(onc_properties.GetString( 36 EXPECT_TRUE(
37 onc::toplevel_config::kType, &network_type)); 37 onc_properties.GetString(onc::toplevel_config::kType, &network_type));
38 return network_type == onc::network_type::kWiFi; 38 return network_type == onc::network_type::kWiFi;
39 } 39 }
40 40
41 std::string GetSsid(const base::DictionaryValue& onc_properties) { 41 std::string GetSsid(const base::DictionaryValue& onc_properties) {
42 std::string ssid; 42 std::string ssid;
43 EXPECT_TRUE(onc_properties.GetString( 43 EXPECT_TRUE(onc_properties.GetString(
44 onc::network_config::WifiProperty(onc::wifi::kSSID), &ssid)); 44 onc::network_config::WifiProperty(onc::wifi::kSSID), &ssid));
45 return ssid; 45 return ssid;
46 } 46 }
47 47
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // TODO(quiche): Update this test, once ONC suports non-UTF-8 SSIDs. 124 // TODO(quiche): Update this test, once ONC suports non-UTF-8 SSIDs.
125 // crbug.com/432546. 125 // crbug.com/432546.
126 TEST(WifiCredentialTest, ToOncPropertiesSsidNonUtf8) { 126 TEST(WifiCredentialTest, ToOncPropertiesSsidNonUtf8) {
127 const WifiCredential credential( 127 const WifiCredential credential(
128 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, "")); 128 MakeCredential(kSsidNonUtf8, SECURITY_CLASS_NONE, ""));
129 std::unique_ptr<base::DictionaryValue> onc_properties = 129 std::unique_ptr<base::DictionaryValue> onc_properties =
130 credential.ToOncProperties(); 130 credential.ToOncProperties();
131 EXPECT_FALSE(onc_properties); 131 EXPECT_FALSE(onc_properties);
132 } 132 }
133 133
134 } // namespace wifi_sync 134 } // namespace sync_wifi
OLDNEW
« no previous file with comments | « components/sync_wifi/wifi_credential_syncable_service_unittest.cc ('k') | components/sync_wifi/wifi_security_class.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698