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