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

Unified Diff: chrome/browser/chromeos/network_settings/onc_test_utils.cc

Issue 10944009: Implementation of ONC signature, validator and normalizer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@gperffix
Patch Set: Addressed remaining nits. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/network_settings/onc_test_utils.cc
diff --git a/chrome/browser/chromeos/network_settings/onc_test_utils.cc b/chrome/browser/chromeos/network_settings/onc_test_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d76fbfa9d5ddf07fafe521194209ddc4480634a5
--- /dev/null
+++ b/chrome/browser/chromeos/network_settings/onc_test_utils.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/network_settings/onc_test_utils.h"
+
+#include "base/file_path.h"
+#include "base/json/json_file_value_serializer.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/values.h"
+#include "chrome/common/chrome_paths.h"
+
+namespace chromeos {
+namespace onc {
+namespace test_utils {
+
+scoped_ptr<base::DictionaryValue> ReadTestDictionary(
+ const std::string& filename) {
+ FilePath path;
+ PathService::Get(chrome::DIR_TEST_DATA, &path);
+ path = path.AppendASCII("chromeos").AppendASCII("network_settings").
+ Append(filename);
+ JSONFileValueSerializer serializer(path);
+ serializer.set_allow_trailing_comma(true);
+
+ std::string error_message;
+ base::Value* content = serializer.Deserialize(NULL, &error_message);
+ CHECK(content != NULL) << "Couldn't json-deserialize file '"
+ << filename << "': " << error_message;
+
+ base::DictionaryValue* dict = NULL;
+ CHECK(content->GetAsDictionary(&dict))
+ << "File '" << filename
+ << "' does not contain a dictionary as expected, but type "
+ << content->GetType();
+ return make_scoped_ptr(dict);
+}
+
+::testing::AssertionResult Equals(const base::DictionaryValue* expected,
+ const base::DictionaryValue* actual) {
+ CHECK(expected != NULL);
+ if (actual == NULL)
+ return ::testing::AssertionFailure() << "Actual dictionary pointer is NULL";
+
+ if (expected->Equals(actual))
+ return ::testing::AssertionSuccess() << "Dictionaries are equal";
+
+ return ::testing::AssertionFailure() << "Dictionaries are unequal.\n"
+ << "Expected dictionary:\n" << *expected
+ << "Actual dictionary:\n" << *actual;
+}
+
+} // namespace test_utils
+} // namespace onc
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/network_settings/onc_test_utils.h ('k') | chrome/browser/chromeos/network_settings/onc_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698