| 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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 << expected_bool2[i].name; | 293 << expected_bool2[i].name; |
| 294 } | 294 } |
| 295 | 295 |
| 296 EXPECT_FALSE(prefs2.GetBool( | 296 EXPECT_FALSE(prefs2.GetBool( |
| 297 installer::master_preferences::kSystemLevel, &value)); | 297 installer::master_preferences::kSystemLevel, &value)); |
| 298 EXPECT_FALSE(prefs2.GetBool( | 298 EXPECT_FALSE(prefs2.GetBool( |
| 299 installer::master_preferences::kVerboseLogging, &value)); | 299 installer::master_preferences::kVerboseLogging, &value)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 TEST_F(MasterPreferencesTest, TestDefaultInstallConfig) { | 302 TEST_F(MasterPreferencesTest, TestDefaultInstallConfig) { |
| 303 std::wstringstream chrome_cmd; | 303 std::wstringstream chrome_cmd, cf_cmd; |
| 304 chrome_cmd << "setup.exe"; | 304 chrome_cmd << "setup.exe"; |
| 305 cf_cmd << "setup.exe --" << installer::switches::kChromeFrame; |
| 305 | 306 |
| 306 CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str())); | 307 CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str())); |
| 308 CommandLine cf_install(CommandLine::FromString(cf_cmd.str())); |
| 307 | 309 |
| 308 installer::MasterPreferences pref_chrome(chrome_install); | 310 installer::MasterPreferences pref_chrome(chrome_install); |
| 311 installer::MasterPreferences pref_cf(cf_install); |
| 309 | 312 |
| 310 EXPECT_FALSE(pref_chrome.is_multi_install()); | 313 EXPECT_FALSE(pref_chrome.is_multi_install()); |
| 311 EXPECT_TRUE(pref_chrome.install_chrome()); | 314 EXPECT_TRUE(pref_chrome.install_chrome()); |
| 315 EXPECT_FALSE(pref_chrome.install_chrome_frame()); |
| 316 |
| 317 EXPECT_FALSE(pref_cf.is_multi_install()); |
| 318 EXPECT_FALSE(pref_cf.install_chrome()); |
| 319 EXPECT_TRUE(pref_cf.install_chrome_frame()); |
| 312 } | 320 } |
| 313 | 321 |
| 314 TEST_F(MasterPreferencesTest, TestMultiInstallConfig) { | 322 TEST_F(MasterPreferencesTest, TestMultiInstallConfig) { |
| 315 using installer::switches::kMultiInstall; | 323 using installer::switches::kMultiInstall; |
| 316 using installer::switches::kChrome; | 324 using installer::switches::kChrome; |
| 325 using installer::switches::kChromeFrame; |
| 317 | 326 |
| 318 std::wstringstream chrome_cmd, cf_cmd, chrome_cf_cmd; | 327 std::wstringstream chrome_cmd, cf_cmd, chrome_cf_cmd; |
| 319 chrome_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome; | 328 chrome_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome; |
| 329 cf_cmd << "setup.exe --" << kMultiInstall << " --" << kChromeFrame; |
| 330 chrome_cf_cmd << "setup.exe --" << kMultiInstall << " --" << kChrome << |
| 331 " --" << kChromeFrame; |
| 320 | 332 |
| 321 CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str())); | 333 CommandLine chrome_install(CommandLine::FromString(chrome_cmd.str())); |
| 334 CommandLine cf_install(CommandLine::FromString(cf_cmd.str())); |
| 335 CommandLine chrome_cf_install(CommandLine::FromString(chrome_cf_cmd.str())); |
| 322 | 336 |
| 323 installer::MasterPreferences pref_chrome(chrome_install); | 337 installer::MasterPreferences pref_chrome(chrome_install); |
| 338 installer::MasterPreferences pref_cf(cf_install); |
| 339 installer::MasterPreferences pref_chrome_cf(chrome_cf_install); |
| 324 | 340 |
| 325 EXPECT_TRUE(pref_chrome.is_multi_install()); | 341 EXPECT_TRUE(pref_chrome.is_multi_install()); |
| 326 EXPECT_TRUE(pref_chrome.install_chrome()); | 342 EXPECT_TRUE(pref_chrome.install_chrome()); |
| 343 EXPECT_FALSE(pref_chrome.install_chrome_frame()); |
| 344 |
| 345 EXPECT_TRUE(pref_cf.is_multi_install()); |
| 346 EXPECT_FALSE(pref_cf.install_chrome()); |
| 347 EXPECT_TRUE(pref_cf.install_chrome_frame()); |
| 348 |
| 349 EXPECT_TRUE(pref_chrome_cf.is_multi_install()); |
| 350 EXPECT_TRUE(pref_chrome_cf.install_chrome()); |
| 351 EXPECT_TRUE(pref_chrome_cf.install_chrome_frame()); |
| 327 } | 352 } |
| 328 | 353 |
| 329 TEST_F(MasterPreferencesTest, EnforceLegacyCreateAllShortcutsFalse) { | 354 TEST_F(MasterPreferencesTest, EnforceLegacyCreateAllShortcutsFalse) { |
| 330 static const char kCreateAllShortcutsFalsePrefs[] = | 355 static const char kCreateAllShortcutsFalsePrefs[] = |
| 331 "{" | 356 "{" |
| 332 " \"distribution\": {" | 357 " \"distribution\": {" |
| 333 " \"create_all_shortcuts\": false" | 358 " \"create_all_shortcuts\": false" |
| 334 " }" | 359 " }" |
| 335 "}"; | 360 "}"; |
| 336 | 361 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // The MasterPreferences dictionary should also conjure up the new setting | 496 // The MasterPreferences dictionary should also conjure up the new setting |
| 472 // as per EnforceLegacyPreferences. | 497 // as per EnforceLegacyPreferences. |
| 473 const base::ListValue* new_startup_urls_list = NULL; | 498 const base::ListValue* new_startup_urls_list = NULL; |
| 474 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, | 499 EXPECT_TRUE(master_dictionary.GetList(prefs::kURLsToRestoreOnStartup, |
| 475 &new_startup_urls_list)); | 500 &new_startup_urls_list)); |
| 476 ASSERT_TRUE(new_startup_urls_list != NULL); | 501 ASSERT_TRUE(new_startup_urls_list != NULL); |
| 477 std::string new_url_value; | 502 std::string new_url_value; |
| 478 EXPECT_TRUE(new_startup_urls_list->GetString(0, &new_url_value)); | 503 EXPECT_TRUE(new_startup_urls_list->GetString(0, &new_url_value)); |
| 479 EXPECT_EQ("http://www.example.com", new_url_value); | 504 EXPECT_EQ("http://www.example.com", new_url_value); |
| 480 } | 505 } |
| OLD | NEW |