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

Side by Side 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: Address comments. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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/policy/preg_parser_win.h"
6
7 #include "base/files/file_path.h"
8 #include "base/json/json_writer.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 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace policy {
16 namespace preg_parser {
17
18 TEST(PRegParserWinTest, TestParseFile) {
19 base::FilePath test_data_dir;
20 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
21
22 // Prepare the test dictionary with some data so the test can check that the
23 // PReg action triggers work, i.e. remove these items.
24 base::DictionaryValue dict;
25 base::DictionaryValue* policy_dict = new base::DictionaryValue();
26 policy_dict->SetInteger("DeleteValuesTest1", 1);
27 policy_dict->SetString("DeleteValuesTest2", "2");
28 policy_dict->SetInteger("DeleteKeysTest1", 1);
29 policy_dict->SetString("DeleteKeysTest2", "2");
30 policy_dict->SetInteger("DelTest", 1);
31 base::DictionaryValue* subdict = new base::DictionaryValue();
32 subdict->SetInteger("DelValsTest1", 1);
33 subdict->SetString("DelValsTest2", "2");
34 subdict->Set("DelValsTest3", new base::DictionaryValue());
35 policy_dict->Set("DelValsTest", subdict);
36 dict.Set("Software.Policies.Chromium", policy_dict);
37
38 // Run the parser.
39 base::FilePath test_file(test_data_dir.AppendASCII("policy/registry.pol"));
40 ASSERT_TRUE(preg_parser::ReadFile(
41 test_file, L"Software\\Policies\\Chromium", &dict));
42
43 // Build the expected output dictionary.
44 base::DictionaryValue expected;
45 base::DictionaryValue* expected_policy_dict = new base::DictionaryValue();
46 base::DictionaryValue* del_vals_dict = new base::DictionaryValue();
47 del_vals_dict->Set("DelValsTest3", new base::DictionaryValue());
48 expected_policy_dict->Set("DelValsTest", del_vals_dict);
49 expected_policy_dict->SetInteger("HomepageIsNewTabPage", 1);
50 expected_policy_dict->SetString("HomepageLocation", "http://www.example.com");
51 expected_policy_dict->SetInteger("RestoreOnStartup", 4);
52 base::DictionaryValue* startup_urls = new DictionaryValue();
53 startup_urls->SetString("1", "http://www.chromium.org");
54 startup_urls->SetString("2", "http://www.example.com");
55 expected_policy_dict->Set("RestoreOnStartupURLs", startup_urls);
56 expected_policy_dict->SetInteger("ShowHomeButton", 1);
57 expected_policy_dict->SetString("Snowman", "\xE2\x98\x83");
58 expected.Set("Software.Policies.Chromium", expected_policy_dict);
59
60 EXPECT_TRUE(base::Value::Equals(&expected, &dict));
61 }
62
63 } // namespace policy
64 } // namespace preg_parser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698