| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" |
| 5 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 6 #include "chrome/browser/chromeos/cros/network_library.h" | 7 #include "chrome/browser/chromeos/cros/network_library.h" |
| 7 #include "chrome/browser/chromeos/cros/network_ui_data.h" | 8 #include "chrome/browser/chromeos/cros/network_ui_data.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 namespace chromeos { | 11 namespace chromeos { |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 // A mock network for testing. We really only need the ui_data() member. | 15 // A mock network for testing. We really only need the ui_data() member. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 40 dict->Set(base::StringPrintf("%s.%s", | 41 dict->Set(base::StringPrintf("%s.%s", |
| 41 NetworkUIData::kKeyProperties, | 42 NetworkUIData::kKeyProperties, |
| 42 property_key), | 43 property_key), |
| 43 property_dict); | 44 property_dict); |
| 44 } | 45 } |
| 45 | 46 |
| 46 static void CheckProperty(const DictionaryValue* dict, | 47 static void CheckProperty(const DictionaryValue* dict, |
| 47 const char* property_key, | 48 const char* property_key, |
| 48 const char* controller, | 49 const char* controller, |
| 49 base::Value* default_value) { | 50 base::Value* default_value) { |
| 51 scoped_ptr<base::Value> scoped_default_value(default_value); |
| 50 DictionaryValue* property_dict; | 52 DictionaryValue* property_dict; |
| 51 std::string key = base::StringPrintf("%s.%s", | 53 std::string key = base::StringPrintf("%s.%s", |
| 52 NetworkUIData::kKeyProperties, | 54 NetworkUIData::kKeyProperties, |
| 53 property_key); | 55 property_key); |
| 54 EXPECT_TRUE(dict->GetDictionary(key, &property_dict)); | 56 EXPECT_TRUE(dict->GetDictionary(key, &property_dict)); |
| 55 ASSERT_TRUE(property_dict); | 57 ASSERT_TRUE(property_dict); |
| 56 std::string actual_controller; | 58 std::string actual_controller; |
| 57 EXPECT_TRUE(property_dict->GetString(NetworkPropertyUIData::kKeyController, | 59 EXPECT_TRUE(property_dict->GetString(NetworkPropertyUIData::kKeyController, |
| 58 &actual_controller)); | 60 &actual_controller)); |
| 59 EXPECT_EQ(controller, actual_controller); | 61 EXPECT_EQ(controller, actual_controller); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 EXPECT_EQ("user_policy", onc_source); | 156 EXPECT_EQ("user_policy", onc_source); |
| 155 CheckProperty(&dict, NetworkUIData::kPropertyAutoConnect, | 157 CheckProperty(&dict, NetworkUIData::kPropertyAutoConnect, |
| 156 "user", base::Value::CreateBooleanValue(true)); | 158 "user", base::Value::CreateBooleanValue(true)); |
| 157 CheckProperty(&dict, NetworkUIData::kPropertyPreferred, | 159 CheckProperty(&dict, NetworkUIData::kPropertyPreferred, |
| 158 "policy", base::Value::CreateBooleanValue(42)); | 160 "policy", base::Value::CreateBooleanValue(42)); |
| 159 CheckProperty(&dict, NetworkUIData::kPropertyPassphrase, | 161 CheckProperty(&dict, NetworkUIData::kPropertyPassphrase, |
| 160 "user", NULL); | 162 "user", NULL); |
| 161 } | 163 } |
| 162 | 164 |
| 163 } // namespace chromeos | 165 } // namespace chromeos |
| OLD | NEW |