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