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

Unified Diff: chrome/browser/policy/preg_parser_win_unittest.cc

Issue 13441008: Add parser for PReg files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
Index: chrome/browser/policy/preg_parser_win_unittest.cc
diff --git a/chrome/browser/policy/preg_parser_win_unittest.cc b/chrome/browser/policy/preg_parser_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..44de650ea1973b39e1db3fbccd6e6999f7cdbac3
--- /dev/null
+++ b/chrome/browser/policy/preg_parser_win_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 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/policy/preg_parser_win.h"
+
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/values.h"
+#include "chrome/common/chrome_paths.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "base/json/json_writer.h"
+#include "base/logging.h"
Joao da Silva 2013/04/05 12:51:33 List all the #includes together?
Mattias Nissler (ping if slow) 2013/04/05 18:12:50 Done.
+
+namespace policy {
+namespace preg_parser {
+
+TEST(PRegParserTest, TestParseFile) {
+ base::FilePath test_data_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
+
+ // Prepare the test dictionary with some data so the test can check that the
+ // PReg action triggers work, i.e. remove these items.
+ base::DictionaryValue dict;
+ base::DictionaryValue* policy_dict = new base::DictionaryValue();
+ policy_dict->SetInteger("DeleteValuesTest1", 1);
+ policy_dict->SetString("DeleteValuesTest2", "2");
+ policy_dict->SetInteger("DeleteKeysTest1", 1);
+ policy_dict->SetString("DeleteKeysTest2", "2");
+ policy_dict->SetInteger("DelTest", 1);
+ base::DictionaryValue* subdict = new base::DictionaryValue();
+ subdict->SetInteger("DelValsTest1", 1);
+ subdict->SetString("DelValsTest2", "2");
+ policy_dict->Set("DelValsTest", subdict);
+ dict.Set("Software.Policies.Chromium", policy_dict);
+
+ // Run the parser.
+ base::FilePath test_file(test_data_dir.AppendASCII("policy/registry.pol"));
+ ASSERT_TRUE(preg_parser::ReadFile(test_file, &dict));
+
+ // Build the expected output dictionary.
+ base::DictionaryValue expected;
+ base::DictionaryValue* expected_policy_dict = new base::DictionaryValue();
+ expected_policy_dict->Set("DelValsTest", new base::DictionaryValue());
+ expected_policy_dict->SetInteger("HomepageIsNewTabPage", 1);
+ expected_policy_dict->SetString("HomepageLocation", "http://www.example.com");
+ expected_policy_dict->SetInteger("RestoreOnStartup", 4);
+ base::DictionaryValue* startup_urls = new DictionaryValue();
+ startup_urls->SetString("1", "http://www.chromium.org");
+ startup_urls->SetString("2", "http://www.example.com");
+ expected_policy_dict->Set("RestoreOnStartupURLs", startup_urls);
+ expected_policy_dict->SetInteger("ShowHomeButton", 1);
+ expected.Set("Software.Policies.Chromium", expected_policy_dict);
+
+ EXPECT_TRUE(base::Value::Equals(&expected, &dict));
+}
+
+} // namespace policy
+} // namespace preg_parser

Powered by Google App Engine
This is Rietveld 408576698