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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 prefs.GetBool( | 411 prefs.GetBool( |
412 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, | 412 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, |
413 &do_not_create_quick_launch_shortcut); | 413 &do_not_create_quick_launch_shortcut); |
414 prefs.GetBool( | 414 prefs.GetBool( |
415 installer::master_preferences::kDoNotCreateTaskbarShortcut, | 415 installer::master_preferences::kDoNotCreateTaskbarShortcut, |
416 &do_not_create_taskbar_shortcut); | 416 &do_not_create_taskbar_shortcut); |
417 EXPECT_FALSE(do_not_create_desktop_shortcut); | 417 EXPECT_FALSE(do_not_create_desktop_shortcut); |
418 EXPECT_FALSE(do_not_create_quick_launch_shortcut); | 418 EXPECT_FALSE(do_not_create_quick_launch_shortcut); |
419 EXPECT_FALSE(do_not_create_taskbar_shortcut); | 419 EXPECT_FALSE(do_not_create_taskbar_shortcut); |
420 } | 420 } |
421 | |
422 TEST_F(MasterPreferencesTest, MigrateOldStartupUrlsPref) { | |
423 static const char kOldMasterPrefs[] = | |
424 "{ \n" | |
425 " \"distribution\": { \n" | |
426 " \"show_welcome_page\": true,\n" | |
427 " \"import_search_engine\": true,\n" | |
428 " \"import_history\": true,\n" | |
429 " \"import_bookmarks\": true\n" | |
430 " },\n" | |
431 " \"session\": {\n" | |
432 " \"urls_to_restore_on_startup\": [\"http://www.google.com\"]\n" | |
433 " }\n" | |
434 "} \n"; | |
435 | |
436 const installer::MasterPreferences prefs(kOldMasterPrefs); | |
437 const base::DictionaryValue& master_dictionary = | |
438 prefs.master_dictionary(); | |
439 | |
440 const base::ListValue* old_startup_urls_list = NULL; | |
441 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartupOld, | |
442 &old_startup_urls_list)); | |
443 EXPECT_TRUE(old_startup_urls_list != NULL); | |
444 | |
445 // The MasterPreferences dictionary should also conjure up the new setting | |
446 // as per EnforceLegacyPreferences. | |
447 const base::ListValue* new_startup_urls_list = NULL; | |
448 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, | |
449 &new_startup_urls_list)); | |
450 EXPECT_TRUE(new_startup_urls_list != NULL); | |
451 } | |
452 | |
453 TEST_F(MasterPreferencesTest, DontMigrateOldStartupUrlsPrefWhenNewExists) { | |
454 static const char kOldAndNewMasterPrefs[] = | |
455 "{ \n" | |
456 " \"distribution\": { \n" | |
457 " \"show_welcome_page\": true,\n" | |
458 " \"import_search_engine\": true,\n" | |
459 " \"import_history\": true,\n" | |
460 " \"import_bookmarks\": true\n" | |
461 " },\n" | |
462 " \"session\": {\n" | |
463 " \"urls_to_restore_on_startup\": [\"http://www.google.com\"],\n" | |
464 " \"startup_urls\": [\"http://www.example.com\"]\n" | |
465 " }\n" | |
466 "} \n"; | |
467 | |
468 const installer::MasterPreferences prefs(kOldAndNewMasterPrefs); | |
469 const base::DictionaryValue& master_dictionary = | |
470 prefs.master_dictionary(); | |
471 | |
472 const base::ListValue* old_startup_urls_list = NULL; | |
473 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartupOld, | |
474 &old_startup_urls_list)); | |
475 ASSERT_TRUE(old_startup_urls_list != NULL); | |
476 std::string url_value; | |
477 EXPECT_TRUE(old_startup_urls_list->GetString(0, &url_value)); | |
478 EXPECT_EQ("http://www.google.com", url_value); | |
479 | |
480 // The MasterPreferences dictionary should also conjure up the new setting | |
481 // as per EnforceLegacyPreferences. | |
482 const base::ListValue* new_startup_urls_list = NULL; | |
483 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, | |
484 &new_startup_urls_list)); | |
485 ASSERT_TRUE(new_startup_urls_list != NULL); | |
486 std::string new_url_value; | |
487 EXPECT_TRUE(new_startup_urls_list->GetString(0, &new_url_value)); | |
488 EXPECT_EQ("http://www.example.com", new_url_value); | |
489 } | |
OLD | NEW |