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

Side by Side Diff: chrome/installer/util/google_chrome_distribution_unittest.cc

Issue 165382: Merge 22284 - Refactoring of master preferences parsing before adding a new p... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/chrome/installer/util/google_chrome_distribution_unittest.cc:r69-2775
Merged /trunk/src/chrome/installer/util/google_chrome_distribution_unittest.cc:r22284
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 GoogleChromeDistribution class. 5 // Unit tests for GoogleChromeDistribution class.
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/registry.h" 9 #include "base/registry.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 std::wstring normal_name; 249 std::wstring normal_name;
250 std::wstring alternate_name; 250 std::wstring alternate_name;
251 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(&normal_name, false)); 251 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(&normal_name, false));
252 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(&alternate_name, true)); 252 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(&alternate_name, true));
253 EXPECT_NE(normal_name, alternate_name); 253 EXPECT_NE(normal_name, alternate_name);
254 EXPECT_FALSE(normal_name.empty()); 254 EXPECT_FALSE(normal_name.empty());
255 EXPECT_FALSE(alternate_name.empty()); 255 EXPECT_FALSE(alternate_name.empty());
256 } 256 }
257 257
258 TEST(MasterPreferences, ParseDistroParams) { 258 TEST(MasterPreferences, ParseDistroParams) {
259 std::wstring prefs; 259 std::wstring prefs_file;
260 ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs)); 260 ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file));
261 const char text[] = 261 const char text[] =
262 "{ \n" 262 "{ \n"
263 " \"distribution\": { \n" 263 " \"distribution\": { \n"
264 " \"skip_first_run_ui\": true,\n" 264 " \"skip_first_run_ui\": true,\n"
265 " \"show_welcome_page\": true,\n" 265 " \"show_welcome_page\": true,\n"
266 " \"import_search_engine\": true,\n" 266 " \"import_search_engine\": true,\n"
267 " \"import_history\": true,\n" 267 " \"import_history\": true,\n"
268 " \"import_bookmarks\": true,\n" 268 " \"import_bookmarks\": true,\n"
269 " \"import_home_page\": true,\n" 269 " \"import_home_page\": true,\n"
270 " \"create_all_shortcuts\": true,\n" 270 " \"create_all_shortcuts\": true,\n"
271 " \"do_not_launch_chrome\": true,\n" 271 " \"do_not_launch_chrome\": true,\n"
272 " \"make_chrome_default\": true,\n" 272 " \"make_chrome_default\": true,\n"
273 " \"make_chrome_default_for_user\": true,\n" 273 " \"make_chrome_default_for_user\": true,\n"
274 " \"system_level\": true,\n" 274 " \"system_level\": true,\n"
275 " \"verbose_logging\": true,\n" 275 " \"verbose_logging\": true,\n"
276 " \"require_eula\": true,\n" 276 " \"require_eula\": true,\n"
277 " \"alternate_shortcut_text\": true\n" 277 " \"alternate_shortcut_text\": true\n"
278 "},\n" 278 "},\n"
279 " \"blah\": {\n" 279 " \"blah\": {\n"
280 " \"import_history\": false\n" 280 " \"import_history\": false\n"
281 " }\n" 281 " }\n"
282 "} \n"; 282 "} \n";
283 283
284 EXPECT_TRUE(file_util::WriteFile(prefs, text, sizeof(text))); 284 EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text)));
285 int result = installer_util::ParseDistributionPreferences(prefs); 285 scoped_ptr<DictionaryValue> prefs(
286 EXPECT_FALSE(result & installer_util::MASTER_PROFILE_NOT_FOUND); 286 installer_util::ParseDistributionPreferences(
287 EXPECT_FALSE(result & installer_util::MASTER_PROFILE_ERROR); 287 FilePath::FromWStringHack(prefs_file)));
288 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_NO_FIRST_RUN_UI); 288 EXPECT_TRUE(prefs.get() != NULL);
289 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SHOW_WELCOME); 289 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
290 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_SEARCH_ENGINE); 290 installer_util::master_preferences::kDistroSkipFirstRunPref));
291 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_HISTORY); 291 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
292 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_BOOKMARKS); 292 installer_util::master_preferences::kDistroShowWelcomePage));
293 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_HOME_PAGE); 293
294 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS); 294 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
295 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME); 295 installer_util::master_preferences::kDistroImportSearchPref));
296 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT); 296 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
297 EXPECT_TRUE(result & 297 installer_util::master_preferences::kDistroImportHistoryPref));
298 installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER); 298 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
299 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SYSTEM_LEVEL); 299 installer_util::master_preferences::kDistroImportBookmarksPref));
300 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_VERBOSE_LOGGING); 300 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
301 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_REQUIRE_EULA); 301 installer_util::master_preferences::kDistroImportHomePagePref));
302 EXPECT_TRUE(result & installer_util::MASTER_PROFILE_ALT_SHORTCUT_TXT); 302
303 EXPECT_TRUE(file_util::Delete(prefs, false)); 303 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
304 installer_util::master_preferences::kCreateAllShortcuts));
305 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
306 installer_util::master_preferences::kDoNotLaunchChrome));
307 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
308 installer_util::master_preferences::kMakeChromeDefault));
309 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
310 installer_util::master_preferences::kMakeChromeDefaultForUser));
311
312 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
313 installer_util::master_preferences::kSystemLevel));
314 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
315 installer_util::master_preferences::kVerboseLogging));
316 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
317 installer_util::master_preferences::kRequireEula));
318 EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
319 installer_util::master_preferences::kAltShortcutText));
320
321 EXPECT_TRUE(file_util::Delete(prefs_file, false));
304 } 322 }
305 323
306 TEST(MasterPreferences, FirstRunTabs) { 324 TEST(MasterPreferences, FirstRunTabs) {
307 std::wstring prefs; 325 std::wstring prefs_file;
308 ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs)); 326 ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file));
309 const char text[] = 327 const char text[] =
310 "{ \n" 328 "{ \n"
311 " \"distribution\": { \n" 329 " \"distribution\": { \n"
312 " \"something here\": true\n" 330 " \"something here\": true\n"
313 " },\n" 331 " },\n"
314 " \"first_run_tabs\": [\n" 332 " \"first_run_tabs\": [\n"
315 " \"http://google.com/f1\",\n" 333 " \"http://google.com/f1\",\n"
316 " \"https://google.com/f2\",\n" 334 " \"https://google.com/f2\",\n"
317 " \"new_tab_page\"\n" 335 " \"new_tab_page\"\n"
318 " ]\n" 336 " ]\n"
319 "} \n"; 337 "} \n";
320 338
321 EXPECT_TRUE(file_util::WriteFile(prefs, text, sizeof(text))); 339 EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text)));
340 scoped_ptr<DictionaryValue> prefs(
341 installer_util::ParseDistributionPreferences(
342 FilePath::FromWStringHack(prefs_file)));
343 EXPECT_TRUE(prefs.get() != NULL);
344
322 typedef std::vector<std::wstring> TabsVector; 345 typedef std::vector<std::wstring> TabsVector;
323 TabsVector tabs = installer_util::ParseFirstRunTabs(prefs); 346 TabsVector tabs = installer_util::GetFirstRunTabs(prefs.get());
324 ASSERT_EQ(3, tabs.size()); 347 ASSERT_EQ(3, tabs.size());
325 EXPECT_EQ(L"http://google.com/f1", tabs[0]); 348 EXPECT_EQ(L"http://google.com/f1", tabs[0]);
326 EXPECT_EQ(L"https://google.com/f2", tabs[1]); 349 EXPECT_EQ(L"https://google.com/f2", tabs[1]);
327 EXPECT_EQ(L"new_tab_page", tabs[2]); 350 EXPECT_EQ(L"new_tab_page", tabs[2]);
328 EXPECT_TRUE(file_util::Delete(prefs, false)); 351 EXPECT_TRUE(file_util::Delete(prefs_file, false));
329 } 352 }
OLDNEW
« no previous file with comments | « chrome/installer/util/google_chrome_distribution.cc ('k') | chrome/installer/util/master_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698