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

Unified Diff: chromeos/network/network_state_unittest.cc

Issue 21030006: NetworkState cleanup, pass properties to InitialPropertiesReceived (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_state_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_state_unittest.cc
diff --git a/chromeos/network/network_state_unittest.cc b/chromeos/network/network_state_unittest.cc
index 0ccdd198dbd1f0c7f944bf282109e68ee9d3490d..4bb2facc14afc8d78c2872b33dc36c2c8e5404bd 100644
--- a/chromeos/network/network_state_unittest.cc
+++ b/chromeos/network/network_state_unittest.cc
@@ -15,6 +15,7 @@ namespace chromeos {
namespace {
+// StringValue that skips the DCHECK in the constructor for valid UTF8.
class TestStringValue : public base::Value {
public:
explicit TestStringValue(const std::string& in_value)
@@ -54,15 +55,21 @@ class NetworkStateTest : public testing::Test {
protected:
bool SetStringProperty(const std::string& key, const std::string& value) {
- if (!network_state_.PropertyChanged(key, TestStringValue(value)))
- return false;
- network_state_.InitialPropertiesReceived();
- return true;
+ TestStringValue* string_value = new TestStringValue(value);
+ bool res = network_state_.PropertyChanged(key, *string_value);
+ properties_.SetWithoutPathExpansion(key, string_value);
+ return res;
+ }
+
+ bool SignalInitialPropertiesReceived() {
+ return network_state_.InitialPropertiesReceived(properties_);
}
NetworkState network_state_;
private:
+ base::DictionaryValue properties_;
+
DISALLOW_COPY_AND_ASSIGN(NetworkStateTest);
};
@@ -97,6 +104,7 @@ TEST_F(NetworkStateTest, SsidTruncateInvalid) {
std::string wifi_setname2 = "SSID TEST \x01\xff!";
std::string wifi_setname2_result = "SSID TEST \xEF\xBF\xBD\xEF\xBF\xBD!";
EXPECT_TRUE(SetStringProperty(flimflam::kNameProperty, wifi_setname2));
+ EXPECT_TRUE(SignalInitialPropertiesReceived());
EXPECT_EQ(network_state_.name(), wifi_setname2_result);
}
@@ -106,7 +114,8 @@ TEST_F(NetworkStateTest, SsidLatin) {
std::string wifi_latin1_hex =
base::HexEncode(wifi_latin1.c_str(), wifi_latin1.length());
std::string wifi_latin1_result = "latin-1 \u00c0\u00cb\u00cc\u00d6\u00fb";
- EXPECT_TRUE(SetStringProperty(flimflam::kWifiHexSsid, wifi_latin1_hex));
+ EXPECT_FALSE(SetStringProperty(flimflam::kWifiHexSsid, wifi_latin1_hex));
+ EXPECT_TRUE(SignalInitialPropertiesReceived());
EXPECT_EQ(network_state_.name(), wifi_latin1_result);
}
@@ -114,7 +123,8 @@ TEST_F(NetworkStateTest, SsidLatin) {
TEST_F(NetworkStateTest, SsidHex) {
std::string wifi_hex = "5468697320697320484558205353494421";
std::string wifi_hex_result = "This is HEX SSID!";
- SetStringProperty(flimflam::kWifiHexSsid, wifi_hex);
+ EXPECT_FALSE(SetStringProperty(flimflam::kWifiHexSsid, wifi_hex));
+ EXPECT_TRUE(SignalInitialPropertiesReceived());
EXPECT_EQ(network_state_.name(), wifi_hex_result);
}
« no previous file with comments | « chromeos/network/network_state_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698