OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 DISALLOW_COPY_AND_ASSIGN(NetworkStateTest); | 73 DISALLOW_COPY_AND_ASSIGN(NetworkStateTest); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 // Seting kNameProperty should set network name after call to | 78 // Seting kNameProperty should set network name after call to |
79 // InitialPropertiesReceived() in SetStringProperty(). | 79 // InitialPropertiesReceived() in SetStringProperty(). |
80 TEST_F(NetworkStateTest, SsidAscii) { | 80 TEST_F(NetworkStateTest, SsidAscii) { |
81 std::string wifi_setname = "SSID TEST"; | 81 std::string wifi_setname = "SSID TEST"; |
82 std::string wifi_setname_result = "SSID TEST"; | 82 std::string wifi_setname_result = "SSID TEST"; |
83 EXPECT_TRUE(SetStringProperty(flimflam::kNameProperty, wifi_setname)); | 83 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname)); |
84 EXPECT_EQ(network_state_.name(), wifi_setname_result); | 84 EXPECT_EQ(network_state_.name(), wifi_setname_result); |
85 } | 85 } |
86 | 86 |
87 TEST_F(NetworkStateTest, SsidAsciiWithNull) { | 87 TEST_F(NetworkStateTest, SsidAsciiWithNull) { |
88 std::string wifi_setname = "SSID TEST\x00xxx"; | 88 std::string wifi_setname = "SSID TEST\x00xxx"; |
89 std::string wifi_setname_result = "SSID TEST"; | 89 std::string wifi_setname_result = "SSID TEST"; |
90 EXPECT_TRUE(SetStringProperty(flimflam::kNameProperty, wifi_setname)); | 90 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname)); |
91 EXPECT_EQ(network_state_.name(), wifi_setname_result); | 91 EXPECT_EQ(network_state_.name(), wifi_setname_result); |
92 } | 92 } |
93 | 93 |
94 // UTF8 SSID | 94 // UTF8 SSID |
95 TEST_F(NetworkStateTest, SsidUtf8) { | 95 TEST_F(NetworkStateTest, SsidUtf8) { |
96 std::string wifi_utf8 = "UTF-8 \u3042\u3044\u3046"; | 96 std::string wifi_utf8 = "UTF-8 \u3042\u3044\u3046"; |
97 std::string wifi_utf8_result = "UTF-8 \xE3\x81\x82\xE3\x81\x84\xE3\x81\x86"; | 97 std::string wifi_utf8_result = "UTF-8 \xE3\x81\x82\xE3\x81\x84\xE3\x81\x86"; |
98 EXPECT_TRUE(SetStringProperty(flimflam::kNameProperty, wifi_utf8)); | 98 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_utf8)); |
99 EXPECT_EQ(network_state_.name(), wifi_utf8_result); | 99 EXPECT_EQ(network_state_.name(), wifi_utf8_result); |
100 } | 100 } |
101 | 101 |
102 // Truncates invalid UTF-8 | 102 // Truncates invalid UTF-8 |
103 TEST_F(NetworkStateTest, SsidTruncateInvalid) { | 103 TEST_F(NetworkStateTest, SsidTruncateInvalid) { |
104 std::string wifi_setname2 = "SSID TEST \x01\xff!"; | 104 std::string wifi_setname2 = "SSID TEST \x01\xff!"; |
105 std::string wifi_setname2_result = "SSID TEST \xEF\xBF\xBD\xEF\xBF\xBD!"; | 105 std::string wifi_setname2_result = "SSID TEST \xEF\xBF\xBD\xEF\xBF\xBD!"; |
106 EXPECT_TRUE(SetStringProperty(flimflam::kNameProperty, wifi_setname2)); | 106 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, wifi_setname2)); |
107 EXPECT_TRUE(SignalInitialPropertiesReceived()); | 107 EXPECT_TRUE(SignalInitialPropertiesReceived()); |
108 EXPECT_EQ(network_state_.name(), wifi_setname2_result); | 108 EXPECT_EQ(network_state_.name(), wifi_setname2_result); |
109 } | 109 } |
110 | 110 |
111 // latin1 SSID -> UTF8 SSID (Hex) | 111 // latin1 SSID -> UTF8 SSID (Hex) |
112 TEST_F(NetworkStateTest, SsidLatin) { | 112 TEST_F(NetworkStateTest, SsidLatin) { |
113 std::string wifi_latin1 = "latin-1 \xc0\xcb\xcc\xd6\xfb"; | 113 std::string wifi_latin1 = "latin-1 \xc0\xcb\xcc\xd6\xfb"; |
114 std::string wifi_latin1_hex = | 114 std::string wifi_latin1_hex = |
115 base::HexEncode(wifi_latin1.c_str(), wifi_latin1.length()); | 115 base::HexEncode(wifi_latin1.c_str(), wifi_latin1.length()); |
116 std::string wifi_latin1_result = "latin-1 \u00c0\u00cb\u00cc\u00d6\u00fb"; | 116 std::string wifi_latin1_result = "latin-1 \u00c0\u00cb\u00cc\u00d6\u00fb"; |
117 EXPECT_FALSE(SetStringProperty(flimflam::kWifiHexSsid, wifi_latin1_hex)); | 117 EXPECT_FALSE(SetStringProperty(shill::kWifiHexSsid, wifi_latin1_hex)); |
118 EXPECT_TRUE(SignalInitialPropertiesReceived()); | 118 EXPECT_TRUE(SignalInitialPropertiesReceived()); |
119 EXPECT_EQ(network_state_.name(), wifi_latin1_result); | 119 EXPECT_EQ(network_state_.name(), wifi_latin1_result); |
120 } | 120 } |
121 | 121 |
122 // Hex SSID | 122 // Hex SSID |
123 TEST_F(NetworkStateTest, SsidHex) { | 123 TEST_F(NetworkStateTest, SsidHex) { |
124 std::string wifi_hex = "5468697320697320484558205353494421"; | 124 std::string wifi_hex = "5468697320697320484558205353494421"; |
125 std::string wifi_hex_result = "This is HEX SSID!"; | 125 std::string wifi_hex_result = "This is HEX SSID!"; |
126 EXPECT_FALSE(SetStringProperty(flimflam::kWifiHexSsid, wifi_hex)); | 126 EXPECT_FALSE(SetStringProperty(shill::kWifiHexSsid, wifi_hex)); |
127 EXPECT_TRUE(SignalInitialPropertiesReceived()); | 127 EXPECT_TRUE(SignalInitialPropertiesReceived()); |
128 EXPECT_EQ(network_state_.name(), wifi_hex_result); | 128 EXPECT_EQ(network_state_.name(), wifi_hex_result); |
129 } | 129 } |
130 | 130 |
131 } // namespace chromeos | 131 } // namespace chromeos |
OLD | NEW |