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

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: 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/path_service.h"
9 #include "base/values.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 #include "base/json/json_writer.h"
14 #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.
15
16 namespace policy {
17 namespace preg_parser {
18
19 TEST(PRegParserTest, TestParseFile) {
20 base::FilePath test_data_dir;
21 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
22
23 // Prepare the test dictionary with some data so the test can check that the
24 // PReg action triggers work, i.e. remove these items.
25 base::DictionaryValue dict;
26 base::DictionaryValue* policy_dict = new base::DictionaryValue();
27 policy_dict->SetInteger("DeleteValuesTest1", 1);
28 policy_dict->SetString("DeleteValuesTest2", "2");
29 policy_dict->SetInteger("DeleteKeysTest1", 1);
30 policy_dict->SetString("DeleteKeysTest2", "2");
31 policy_dict->SetInteger("DelTest", 1);
32 base::DictionaryValue* subdict = new base::DictionaryValue();
33 subdict->SetInteger("DelValsTest1", 1);
34 subdict->SetString("DelValsTest2", "2");
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(test_file, &dict));
41
42 // Build the expected output dictionary.
43 base::DictionaryValue expected;
44 base::DictionaryValue* expected_policy_dict = new base::DictionaryValue();
45 expected_policy_dict->Set("DelValsTest", new base::DictionaryValue());
46 expected_policy_dict->SetInteger("HomepageIsNewTabPage", 1);
47 expected_policy_dict->SetString("HomepageLocation", "http://www.example.com");
48 expected_policy_dict->SetInteger("RestoreOnStartup", 4);
49 base::DictionaryValue* startup_urls = new DictionaryValue();
50 startup_urls->SetString("1", "http://www.chromium.org");
51 startup_urls->SetString("2", "http://www.example.com");
52 expected_policy_dict->Set("RestoreOnStartupURLs", startup_urls);
53 expected_policy_dict->SetInteger("ShowHomeButton", 1);
54 expected.Set("Software.Policies.Chromium", expected_policy_dict);
55
56 EXPECT_TRUE(base::Value::Equals(&expected, &dict));
57 }
58
59 } // namespace policy
60 } // namespace preg_parser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698