OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Unit tests for master preferences related methods. | 5 // Unit tests for master preferences related methods. |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 TEST_F(MasterPreferencesTest, ParseDistroParams) { | 50 TEST_F(MasterPreferencesTest, ParseDistroParams) { |
51 const char text[] = | 51 const char text[] = |
52 "{ \n" | 52 "{ \n" |
53 " \"distribution\": { \n" | 53 " \"distribution\": { \n" |
54 " \"show_welcome_page\": true,\n" | 54 " \"show_welcome_page\": true,\n" |
55 " \"import_search_engine\": true,\n" | 55 " \"import_search_engine\": true,\n" |
56 " \"import_history\": true,\n" | 56 " \"import_history\": true,\n" |
57 " \"import_bookmarks\": true,\n" | 57 " \"import_bookmarks\": true,\n" |
58 " \"import_bookmarks_from_file\": \"c:\\\\foo\",\n" | 58 " \"import_bookmarks_from_file\": \"c:\\\\foo\",\n" |
59 " \"import_home_page\": true,\n" | 59 " \"import_home_page\": true,\n" |
| 60 " \"welcome_page_on_os_upgrade_enabled\": true,\n" |
60 " \"do_not_create_any_shortcuts\": true,\n" | 61 " \"do_not_create_any_shortcuts\": true,\n" |
61 " \"do_not_create_desktop_shortcut\": true,\n" | 62 " \"do_not_create_desktop_shortcut\": true,\n" |
62 " \"do_not_create_quick_launch_shortcut\": true,\n" | 63 " \"do_not_create_quick_launch_shortcut\": true,\n" |
63 " \"do_not_create_taskbar_shortcut\": true,\n" | 64 " \"do_not_create_taskbar_shortcut\": true,\n" |
64 " \"do_not_launch_chrome\": true,\n" | 65 " \"do_not_launch_chrome\": true,\n" |
65 " \"make_chrome_default\": true,\n" | 66 " \"make_chrome_default\": true,\n" |
66 " \"make_chrome_default_for_user\": true,\n" | 67 " \"make_chrome_default_for_user\": true,\n" |
67 " \"system_level\": true,\n" | 68 " \"system_level\": true,\n" |
68 " \"verbose_logging\": true,\n" | 69 " \"verbose_logging\": true,\n" |
69 " \"require_eula\": true,\n" | 70 " \"require_eula\": true,\n" |
70 " \"alternate_shortcut_text\": true,\n" | 71 " \"alternate_shortcut_text\": true,\n" |
71 " \"chrome_shortcut_icon_index\": 1,\n" | 72 " \"chrome_shortcut_icon_index\": 1,\n" |
72 " \"ping_delay\": 40\n" | 73 " \"ping_delay\": 40\n" |
73 " },\n" | 74 " },\n" |
74 " \"blah\": {\n" | 75 " \"blah\": {\n" |
75 " \"import_history\": false\n" | 76 " \"import_history\": false\n" |
76 " }\n" | 77 " }\n" |
77 "} \n"; | 78 "} \n"; |
78 | 79 |
79 EXPECT_TRUE(base::WriteFile(prefs_file(), text, | 80 EXPECT_TRUE(base::WriteFile(prefs_file(), text, |
80 static_cast<int>(strlen(text)))); | 81 static_cast<int>(strlen(text)))); |
81 installer::MasterPreferences prefs(prefs_file()); | 82 installer::MasterPreferences prefs(prefs_file()); |
82 EXPECT_TRUE(prefs.read_from_file()); | 83 EXPECT_TRUE(prefs.read_from_file()); |
83 | 84 |
84 const char* const expected_true[] = { | 85 const char* const expected_true[] = { |
85 installer::master_preferences::kDistroImportSearchPref, | 86 installer::master_preferences::kDistroImportSearchPref, |
86 installer::master_preferences::kDistroImportHistoryPref, | 87 installer::master_preferences::kDistroImportHistoryPref, |
87 installer::master_preferences::kDistroImportBookmarksPref, | 88 installer::master_preferences::kDistroImportBookmarksPref, |
88 installer::master_preferences::kDistroImportHomePagePref, | 89 installer::master_preferences::kDistroImportHomePagePref, |
| 90 installer::master_preferences::kDistroWelcomePageOnOSUpgradeEnabled, |
89 installer::master_preferences::kDoNotCreateAnyShortcuts, | 91 installer::master_preferences::kDoNotCreateAnyShortcuts, |
90 installer::master_preferences::kDoNotCreateDesktopShortcut, | 92 installer::master_preferences::kDoNotCreateDesktopShortcut, |
91 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, | 93 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, |
92 installer::master_preferences::kDoNotCreateTaskbarShortcut, | 94 installer::master_preferences::kDoNotCreateTaskbarShortcut, |
93 installer::master_preferences::kDoNotLaunchChrome, | 95 installer::master_preferences::kDoNotLaunchChrome, |
94 installer::master_preferences::kMakeChromeDefault, | 96 installer::master_preferences::kMakeChromeDefault, |
95 installer::master_preferences::kMakeChromeDefaultForUser, | 97 installer::master_preferences::kMakeChromeDefaultForUser, |
96 installer::master_preferences::kSystemLevel, | 98 installer::master_preferences::kSystemLevel, |
97 installer::master_preferences::kVerboseLogging, | 99 installer::master_preferences::kVerboseLogging, |
98 installer::master_preferences::kRequireEula, | 100 installer::master_preferences::kRequireEula, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 }; | 152 }; |
151 | 153 |
152 bool value = false; | 154 bool value = false; |
153 for (int i = 0; i < arraysize(expected_bool); ++i) { | 155 for (int i = 0; i < arraysize(expected_bool); ++i) { |
154 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value)); | 156 EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value)); |
155 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name; | 157 EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name; |
156 } | 158 } |
157 | 159 |
158 const char* const missing_bools[] = { | 160 const char* const missing_bools[] = { |
159 installer::master_preferences::kDistroImportHomePagePref, | 161 installer::master_preferences::kDistroImportHomePagePref, |
| 162 installer::master_preferences::kDistroWelcomePageOnOSUpgradeEnabled, |
160 installer::master_preferences::kDoNotRegisterForUpdateLaunch, | 163 installer::master_preferences::kDoNotRegisterForUpdateLaunch, |
161 installer::master_preferences::kMakeChromeDefault, | 164 installer::master_preferences::kMakeChromeDefault, |
162 installer::master_preferences::kMakeChromeDefaultForUser, | 165 installer::master_preferences::kMakeChromeDefaultForUser, |
163 }; | 166 }; |
164 | 167 |
165 for (int i = 0; i < arraysize(missing_bools); ++i) { | 168 for (int i = 0; i < arraysize(missing_bools); ++i) { |
166 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i]; | 169 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i]; |
167 } | 170 } |
168 | 171 |
169 std::string str_value; | 172 std::string str_value; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // The MasterPreferences dictionary should also conjure up the new setting | 480 // The MasterPreferences dictionary should also conjure up the new setting |
478 // as per EnforceLegacyPreferences. | 481 // as per EnforceLegacyPreferences. |
479 const base::ListValue* new_startup_urls_list = NULL; | 482 const base::ListValue* new_startup_urls_list = NULL; |
480 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, | 483 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, |
481 &new_startup_urls_list)); | 484 &new_startup_urls_list)); |
482 ASSERT_TRUE(new_startup_urls_list != NULL); | 485 ASSERT_TRUE(new_startup_urls_list != NULL); |
483 std::string new_url_value; | 486 std::string new_url_value; |
484 EXPECT_TRUE(new_startup_urls_list->GetString(0, &new_url_value)); | 487 EXPECT_TRUE(new_startup_urls_list->GetString(0, &new_url_value)); |
485 EXPECT_EQ("http://www.example.com", new_url_value); | 488 EXPECT_EQ("http://www.example.com", new_url_value); |
486 } | 489 } |
OLD | NEW |