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/file_util.h" | 7 #include "base/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/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 " \"require_eula\": true,\n" | 61 " \"require_eula\": true,\n" |
62 " \"alternate_shortcut_text\": true,\n" | 62 " \"alternate_shortcut_text\": true,\n" |
63 " \"chrome_shortcut_icon_index\": 1,\n" | 63 " \"chrome_shortcut_icon_index\": 1,\n" |
64 " \"ping_delay\": 40\n" | 64 " \"ping_delay\": 40\n" |
65 " },\n" | 65 " },\n" |
66 " \"blah\": {\n" | 66 " \"blah\": {\n" |
67 " \"import_history\": false\n" | 67 " \"import_history\": false\n" |
68 " }\n" | 68 " }\n" |
69 "} \n"; | 69 "} \n"; |
70 | 70 |
71 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, sizeof(text))); | 71 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, strlen(text))); |
72 installer::MasterPreferences prefs(prefs_file()); | 72 installer::MasterPreferences prefs(prefs_file()); |
73 | 73 |
74 const char* expected_true[] = { | 74 const char* expected_true[] = { |
75 installer::master_preferences::kDistroSkipFirstRunPref, | 75 installer::master_preferences::kDistroSkipFirstRunPref, |
76 installer::master_preferences::kDistroShowWelcomePage, | 76 installer::master_preferences::kDistroShowWelcomePage, |
77 installer::master_preferences::kDistroImportSearchPref, | 77 installer::master_preferences::kDistroImportSearchPref, |
78 installer::master_preferences::kDistroImportHistoryPref, | 78 installer::master_preferences::kDistroImportHistoryPref, |
79 installer::master_preferences::kDistroImportBookmarksPref, | 79 installer::master_preferences::kDistroImportBookmarksPref, |
80 installer::master_preferences::kDistroImportHomePagePref, | 80 installer::master_preferences::kDistroImportHomePagePref, |
81 installer::master_preferences::kCreateAllShortcuts, | 81 installer::master_preferences::kCreateAllShortcuts, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 " \"skip_first_run_ui\": true,\n" | 118 " \"skip_first_run_ui\": true,\n" |
119 " \"import_search_engine\": true,\n" | 119 " \"import_search_engine\": true,\n" |
120 " \"import_bookmarks\": false,\n" | 120 " \"import_bookmarks\": false,\n" |
121 " \"import_bookmarks_from_file\": \"\",\n" | 121 " \"import_bookmarks_from_file\": \"\",\n" |
122 " \"create_all_shortcuts\": true,\n" | 122 " \"create_all_shortcuts\": true,\n" |
123 " \"do_not_launch_chrome\": true,\n" | 123 " \"do_not_launch_chrome\": true,\n" |
124 " \"chrome_shortcut_icon_index\": \"bac\"\n" | 124 " \"chrome_shortcut_icon_index\": \"bac\"\n" |
125 " }\n" | 125 " }\n" |
126 "} \n"; | 126 "} \n"; |
127 | 127 |
128 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, sizeof(text))); | 128 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, strlen(text))); |
129 installer::MasterPreferences prefs(prefs_file()); | 129 installer::MasterPreferences prefs(prefs_file()); |
130 | 130 |
131 ExpectedBooleans expected_bool[] = { | 131 ExpectedBooleans expected_bool[] = { |
132 { installer::master_preferences::kDistroSkipFirstRunPref, true }, | 132 { installer::master_preferences::kDistroSkipFirstRunPref, true }, |
133 { installer::master_preferences::kDistroImportSearchPref, true }, | 133 { installer::master_preferences::kDistroImportSearchPref, true }, |
134 { installer::master_preferences::kDistroImportBookmarksPref, false }, | 134 { installer::master_preferences::kDistroImportBookmarksPref, false }, |
135 { installer::master_preferences::kCreateAllShortcuts, true }, | 135 { installer::master_preferences::kCreateAllShortcuts, true }, |
136 { installer::master_preferences::kDoNotLaunchChrome, true }, | 136 { installer::master_preferences::kDoNotLaunchChrome, true }, |
137 }; | 137 }; |
138 | 138 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 " \"distribution\": { \n" | 178 " \"distribution\": { \n" |
179 " \"something here\": true\n" | 179 " \"something here\": true\n" |
180 " },\n" | 180 " },\n" |
181 " \"first_run_tabs\": [\n" | 181 " \"first_run_tabs\": [\n" |
182 " \"http://google.com/f1\",\n" | 182 " \"http://google.com/f1\",\n" |
183 " \"https://google.com/f2\",\n" | 183 " \"https://google.com/f2\",\n" |
184 " \"new_tab_page\"\n" | 184 " \"new_tab_page\"\n" |
185 " ]\n" | 185 " ]\n" |
186 "} \n"; | 186 "} \n"; |
187 | 187 |
188 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, sizeof(text))); | 188 EXPECT_TRUE(file_util::WriteFile(prefs_file(), text, strlen(text))); |
189 installer::MasterPreferences prefs(prefs_file()); | 189 installer::MasterPreferences prefs(prefs_file()); |
190 typedef std::vector<GURL> TabsVector; | 190 typedef std::vector<GURL> TabsVector; |
191 TabsVector tabs = prefs.GetFirstRunTabs(); | 191 TabsVector tabs = prefs.GetFirstRunTabs(); |
192 ASSERT_EQ(3, tabs.size()); | 192 ASSERT_EQ(3, tabs.size()); |
193 EXPECT_EQ(GURL("http://google.com/f1"), tabs[0]); | 193 EXPECT_EQ(GURL("http://google.com/f1"), tabs[0]); |
194 EXPECT_EQ(GURL("https://google.com/f2"), tabs[1]); | 194 EXPECT_EQ(GURL("https://google.com/f2"), tabs[1]); |
195 EXPECT_EQ(GURL("new_tab_page"), tabs[2]); | 195 EXPECT_EQ(GURL("new_tab_page"), tabs[2]); |
196 } | 196 } |
197 | 197 |
198 // In this test instead of using our synthetic json file, we use an | 198 // In this test instead of using our synthetic json file, we use an |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 const char text[] = | 236 const char text[] = |
237 "{ \n" | 237 "{ \n" |
238 " \"distribution\": { \n" | 238 " \"distribution\": { \n" |
239 " \"skip_first_run_ui\": true,\n" | 239 " \"skip_first_run_ui\": true,\n" |
240 " \"create_all_shortcuts\": false,\n" | 240 " \"create_all_shortcuts\": false,\n" |
241 " \"do_not_launch_chrome\": true,\n" | 241 " \"do_not_launch_chrome\": true,\n" |
242 " \"system_level\": true,\n" | 242 " \"system_level\": true,\n" |
243 " \"verbose_logging\": false\n" | 243 " \"verbose_logging\": false\n" |
244 " }\n" | 244 " }\n" |
245 "} \n"; | 245 "} \n"; |
246 EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text))); | 246 EXPECT_TRUE(file_util::WriteFile(prefs_file, text, strlen(text))); |
247 | 247 |
248 // Make sure command line values override the values in master preferences. | 248 // Make sure command line values override the values in master preferences. |
249 std::wstring cmd_str( | 249 std::wstring cmd_str( |
250 L"setup.exe --installerdata=\"" + prefs_file.value() + L"\""); | 250 L"setup.exe --installerdata=\"" + prefs_file.value() + L"\""); |
251 cmd_str.append(L" --create-all-shortcuts"); | 251 cmd_str.append(L" --create-all-shortcuts"); |
252 cmd_str.append(L" --do-not-launch-chrome"); | 252 cmd_str.append(L" --do-not-launch-chrome"); |
253 cmd_str.append(L" --alt-desktop-shortcut"); | 253 cmd_str.append(L" --alt-desktop-shortcut"); |
254 CommandLine cmd_line = CommandLine::FromString(cmd_str); | 254 CommandLine cmd_line = CommandLine::FromString(cmd_str); |
255 installer::MasterPreferences prefs(cmd_line); | 255 installer::MasterPreferences prefs(cmd_line); |
256 | 256 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 EXPECT_TRUE(pref_cf.is_multi_install()); | 344 EXPECT_TRUE(pref_cf.is_multi_install()); |
345 EXPECT_FALSE(pref_cf.install_chrome()); | 345 EXPECT_FALSE(pref_cf.install_chrome()); |
346 EXPECT_TRUE(pref_cf.install_chrome_frame()); | 346 EXPECT_TRUE(pref_cf.install_chrome_frame()); |
347 | 347 |
348 EXPECT_TRUE(pref_chrome_cf.is_multi_install()); | 348 EXPECT_TRUE(pref_chrome_cf.is_multi_install()); |
349 EXPECT_TRUE(pref_chrome_cf.install_chrome()); | 349 EXPECT_TRUE(pref_chrome_cf.install_chrome()); |
350 EXPECT_TRUE(pref_chrome_cf.install_chrome_frame()); | 350 EXPECT_TRUE(pref_chrome_cf.install_chrome_frame()); |
351 } | 351 } |
352 | 352 |
OLD | NEW |