summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup/setup_util_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer/setup/setup_util_unittest.cc')
-rw-r--r--chrome/installer/setup/setup_util_unittest.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
index 42cecdf..d163816 100644
--- a/chrome/installer/setup/setup_util_unittest.cc
+++ b/chrome/installer/setup/setup_util_unittest.cc
@@ -13,6 +13,7 @@
#include "base/process_util.h"
#include "base/string_util.h"
#include "chrome/installer/setup/setup_util.h"
+#include "chrome/installer/util/master_preferences.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -40,6 +41,74 @@ namespace {
};
};
+// Test that we are parsing master preferences correctly.
+TEST_F(SetupUtilTest, GetInstallPreferencesTest) {
+ // Create a temporary prefs file.
+ std::wstring prefs_file;
+ ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file));
+ const char text[] =
+ "{ \n"
+ " \"distribution\": { \n"
+ " \"skip_first_run_ui\": true,\n"
+ " \"create_all_shortcuts\": false,\n"
+ " \"do_not_launch_chrome\": true,\n"
+ " \"system_level\": true,\n"
+ " \"verbose_logging\": false\n"
+ " }\n"
+ "} \n";
+ EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text)));
+
+ // Make sure command line values override the values in master preferences.
+ std::wstring cmd_str(L"setup.exe --installerdata=\"" + prefs_file + L"\"");
+ cmd_str.append(L" --create-all-shortcuts");
+ cmd_str.append(L" --do-not-launch-chrome");
+ cmd_str.append(L" --alt-desktop-shortcut");
+ CommandLine cmd_line(L"");
+ cmd_line.ParseFromString(cmd_str);
+ scoped_ptr<DictionaryValue> prefs(
+ setup_util::GetInstallPreferences(cmd_line));
+ EXPECT_TRUE(prefs.get() != NULL);
+
+ // Check prefs that do not have any equivalent command line option.
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroSkipFirstRunPref));
+ EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroShowWelcomePage));
+
+ // Now check that prefs got merged correctly.
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kCreateAllShortcuts));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDoNotLaunchChrome));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kAltShortcutText));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kSystemLevel));
+ EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kVerboseLogging));
+
+ // Delete temporary prefs file.
+ EXPECT_TRUE(file_util::Delete(prefs_file, false));
+
+ // Check that if master prefs doesn't exist, we can still parse the common
+ // prefs.
+ cmd_str = L"setup.exe --create-all-shortcuts --do-not-launch-chrome"
+ L" --alt-desktop-shortcut";
+ cmd_line.ParseFromString(cmd_str);
+ prefs.reset(setup_util::GetInstallPreferences(cmd_line));
+ EXPECT_TRUE(prefs.get() != NULL);
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kCreateAllShortcuts));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDoNotLaunchChrome));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kAltShortcutText));
+ EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kSystemLevel));
+ EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kVerboseLogging));
+}
+
// Test that we are parsing Chrome version correctly.
TEST_F(SetupUtilTest, GetVersionFromDirTest) {
// Create a version dir