| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/network_settings/onc_test_utils.h" |
| 6 |
| 7 #include "base/file_path.h" |
| 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" |
| 11 #include "base/values.h" |
| 12 #include "chrome/common/chrome_paths.h" |
| 13 |
| 14 namespace chromeos { |
| 15 namespace onc { |
| 16 namespace test_utils { |
| 17 |
| 18 // Read a json dictionary from |filename| and return it as a |
| 19 // DictionaryValue. CHECKs if any error occurs. |
| 20 scoped_ptr<base::DictionaryValue> ReadTestDictionary( |
| 21 const std::string& filename) { |
| 22 FilePath path; |
| 23 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 24 path = path.AppendASCII("chromeos").AppendASCII("network_settings"). |
| 25 Append(filename); |
| 26 JSONFileValueSerializer serializer(path); |
| 27 serializer.set_allow_trailing_comma(true); |
| 28 |
| 29 std::string error_message; |
| 30 base::Value* content = serializer.Deserialize(NULL, &error_message); |
| 31 CHECK(content != NULL) << error_message; |
| 32 |
| 33 base::DictionaryValue* dict = NULL; |
| 34 CHECK(content->GetAsDictionary(&dict)) |
| 35 << "File '" << filename |
| 36 << "' does not contain a dictionary as expected, but type " |
| 37 << content->GetType(); |
| 38 return make_scoped_ptr(dict); |
| 39 } |
| 40 |
| 41 } // namespace test_utils |
| 42 } // namespace onc |
| 43 } // namespace chromeos |
| OLD | NEW |