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..604d11d6dca83de06a3142cd0230b7aff8434e37 |
--- /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/json/json_writer.h" |
+#include "base/logging.h" |
+#include "base/path_service.h" |
+#include "base/values.h" |
+#include "chrome/common/chrome_paths.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace policy { |
+namespace preg_parser { |
+ |
+TEST(PRegParserWinTest, 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; |
+ dict.SetInteger("DeleteValuesTest1", 1); |
+ dict.SetString("DeleteValuesTest2", "2"); |
+ dict.SetInteger("DeleteKeysTest1", 1); |
+ dict.SetString("DeleteKeysTest2", "2"); |
+ dict.SetInteger("DelTest", 1); |
+ base::DictionaryValue* subdict = new base::DictionaryValue(); |
+ subdict->SetInteger("DelValsTest1", 1); |
+ subdict->SetString("DelValsTest2", "2"); |
+ subdict->Set("DelValsTest3", new base::DictionaryValue()); |
+ dict.Set("DelValsTest", subdict); |
+ |
+ // Run the parser. |
+ base::FilePath test_file(test_data_dir.AppendASCII("policy/registry.pol")); |
+ ASSERT_TRUE(preg_parser::ReadFile( |
+ test_file, L"SOFTWARE\\Policies\\Chromium", &dict)); |
+ |
+ // Build the expected output dictionary. |
+ base::DictionaryValue expected; |
+ base::DictionaryValue* del_vals_dict = new base::DictionaryValue(); |
+ del_vals_dict->Set("DelValsTest3", new base::DictionaryValue()); |
+ expected.Set("DelValsTest", del_vals_dict); |
+ expected.SetInteger("HomepageIsNewTabPage", 1); |
+ expected.SetString("HomepageLocation", "http://www.example.com"); |
+ expected.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.Set("RestoreOnStartupURLs", startup_urls); |
+ expected.SetInteger("ShowHomeButton", 1); |
+ expected.SetString("Snowman", "\xE2\x98\x83"); |
+ |
+ EXPECT_TRUE(base::Value::Equals(&expected, &dict)); |
+} |
+ |
+} // namespace policy |
+} // namespace preg_parser |