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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 " \"do_not_create_any_shortcuts\": true,\n" | 61 " \"do_not_create_any_shortcuts\": true,\n" |
62 " \"do_not_create_desktop_shortcut\": true,\n" | 62 " \"do_not_create_desktop_shortcut\": true,\n" |
63 " \"do_not_create_quick_launch_shortcut\": true,\n" | 63 " \"do_not_create_quick_launch_shortcut\": true,\n" |
64 " \"do_not_create_taskbar_shortcut\": true,\n" | 64 " \"do_not_create_taskbar_shortcut\": true,\n" |
65 " \"do_not_launch_chrome\": true,\n" | 65 " \"do_not_launch_chrome\": true,\n" |
66 " \"make_chrome_default\": true,\n" | 66 " \"make_chrome_default\": true,\n" |
67 " \"make_chrome_default_for_user\": true,\n" | 67 " \"make_chrome_default_for_user\": true,\n" |
68 " \"system_level\": true,\n" | 68 " \"system_level\": true,\n" |
69 " \"verbose_logging\": true,\n" | 69 " \"verbose_logging\": true,\n" |
70 " \"require_eula\": true,\n" | 70 " \"require_eula\": true,\n" |
71 " \"chrome_shortcut_icon_index\": 1,\n" | |
72 " \"ping_delay\": 40\n" | 71 " \"ping_delay\": 40\n" |
73 " },\n" | 72 " },\n" |
74 " \"blah\": {\n" | 73 " \"blah\": {\n" |
75 " \"import_history\": false\n" | 74 " \"import_history\": false\n" |
76 " }\n" | 75 " }\n" |
77 "} \n"; | 76 "} \n"; |
78 | 77 |
79 EXPECT_TRUE(base::WriteFile(prefs_file(), text, | 78 EXPECT_TRUE(base::WriteFile(prefs_file(), text, |
80 static_cast<int>(strlen(text)))); | 79 static_cast<int>(strlen(text)))); |
81 installer::MasterPreferences prefs(prefs_file()); | 80 installer::MasterPreferences prefs(prefs_file()); |
(...skipping 22 matching lines...) Expand all Loading... |
104 EXPECT_TRUE(prefs.GetBool(expected_true[i], &value)); | 103 EXPECT_TRUE(prefs.GetBool(expected_true[i], &value)); |
105 EXPECT_TRUE(value) << expected_true[i]; | 104 EXPECT_TRUE(value) << expected_true[i]; |
106 } | 105 } |
107 | 106 |
108 std::string str_value; | 107 std::string str_value; |
109 EXPECT_TRUE(prefs.GetString( | 108 EXPECT_TRUE(prefs.GetString( |
110 installer::master_preferences::kDistroImportBookmarksFromFilePref, | 109 installer::master_preferences::kDistroImportBookmarksFromFilePref, |
111 &str_value)); | 110 &str_value)); |
112 EXPECT_STREQ("c:\\foo", str_value.c_str()); | 111 EXPECT_STREQ("c:\\foo", str_value.c_str()); |
113 | 112 |
114 int icon_index = 0; | |
115 EXPECT_TRUE(prefs.GetInt( | |
116 installer::master_preferences::kChromeShortcutIconIndex, | |
117 &icon_index)); | |
118 EXPECT_EQ(icon_index, 1); | |
119 int ping_delay = 90; | 113 int ping_delay = 90; |
120 EXPECT_TRUE(prefs.GetInt(installer::master_preferences::kDistroPingDelay, | 114 EXPECT_TRUE(prefs.GetInt(installer::master_preferences::kDistroPingDelay, |
121 &ping_delay)); | 115 &ping_delay)); |
122 EXPECT_EQ(ping_delay, 40); | 116 EXPECT_EQ(ping_delay, 40); |
123 } | 117 } |
124 | 118 |
125 TEST_F(MasterPreferencesTest, ParseMissingDistroParams) { | 119 TEST_F(MasterPreferencesTest, ParseMissingDistroParams) { |
126 const char text[] = | 120 const char text[] = |
127 "{ \n" | 121 "{ \n" |
128 " \"distribution\": { \n" | 122 " \"distribution\": { \n" |
129 " \"import_search_engine\": true,\n" | 123 " \"import_search_engine\": true,\n" |
130 " \"import_bookmarks\": false,\n" | 124 " \"import_bookmarks\": false,\n" |
131 " \"import_bookmarks_from_file\": \"\",\n" | 125 " \"import_bookmarks_from_file\": \"\",\n" |
132 " \"do_not_create_desktop_shortcut\": true,\n" | 126 " \"do_not_create_desktop_shortcut\": true,\n" |
133 " \"do_not_create_quick_launch_shortcut\": true,\n" | 127 " \"do_not_create_quick_launch_shortcut\": true,\n" |
134 " \"do_not_launch_chrome\": true,\n" | 128 " \"do_not_launch_chrome\": true\n" |
135 " \"chrome_shortcut_icon_index\": \"bac\"\n" | |
136 " }\n" | 129 " }\n" |
137 "} \n"; | 130 "} \n"; |
138 | 131 |
139 EXPECT_TRUE(base::WriteFile(prefs_file(), text, | 132 EXPECT_TRUE(base::WriteFile(prefs_file(), text, |
140 static_cast<int>(strlen(text)))); | 133 static_cast<int>(strlen(text)))); |
141 installer::MasterPreferences prefs(prefs_file()); | 134 installer::MasterPreferences prefs(prefs_file()); |
142 EXPECT_TRUE(prefs.read_from_file()); | 135 EXPECT_TRUE(prefs.read_from_file()); |
143 | 136 |
144 ExpectedBooleans expected_bool[] = { | 137 ExpectedBooleans expected_bool[] = { |
145 { installer::master_preferences::kDistroImportSearchPref, true }, | 138 { installer::master_preferences::kDistroImportSearchPref, true }, |
(...skipping 19 matching lines...) Expand all Loading... |
165 | 158 |
166 for (size_t i = 0; i < arraysize(missing_bools); ++i) { | 159 for (size_t i = 0; i < arraysize(missing_bools); ++i) { |
167 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i]; | 160 EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i]; |
168 } | 161 } |
169 | 162 |
170 std::string str_value; | 163 std::string str_value; |
171 EXPECT_FALSE(prefs.GetString( | 164 EXPECT_FALSE(prefs.GetString( |
172 installer::master_preferences::kDistroImportBookmarksFromFilePref, | 165 installer::master_preferences::kDistroImportBookmarksFromFilePref, |
173 &str_value)); | 166 &str_value)); |
174 | 167 |
175 int icon_index = 0; | |
176 EXPECT_FALSE(prefs.GetInt( | |
177 installer::master_preferences::kChromeShortcutIconIndex, | |
178 &icon_index)); | |
179 EXPECT_EQ(icon_index, 0); | |
180 | |
181 int ping_delay = 90; | 168 int ping_delay = 90; |
182 EXPECT_FALSE(prefs.GetInt( | 169 EXPECT_FALSE(prefs.GetInt( |
183 installer::master_preferences::kDistroPingDelay, &ping_delay)); | 170 installer::master_preferences::kDistroPingDelay, &ping_delay)); |
184 EXPECT_EQ(ping_delay, 90); | 171 EXPECT_EQ(ping_delay, 90); |
185 } | 172 } |
186 | 173 |
187 TEST_F(MasterPreferencesTest, FirstRunTabs) { | 174 TEST_F(MasterPreferencesTest, FirstRunTabs) { |
188 const char text[] = | 175 const char text[] = |
189 "{ \n" | 176 "{ \n" |
190 " \"distribution\": { \n" | 177 " \"distribution\": { \n" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 prefs.GetBool( | 396 prefs.GetBool( |
410 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, | 397 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, |
411 &do_not_create_quick_launch_shortcut); | 398 &do_not_create_quick_launch_shortcut); |
412 prefs.GetBool( | 399 prefs.GetBool( |
413 installer::master_preferences::kDoNotCreateTaskbarShortcut, | 400 installer::master_preferences::kDoNotCreateTaskbarShortcut, |
414 &do_not_create_taskbar_shortcut); | 401 &do_not_create_taskbar_shortcut); |
415 EXPECT_FALSE(do_not_create_desktop_shortcut); | 402 EXPECT_FALSE(do_not_create_desktop_shortcut); |
416 EXPECT_FALSE(do_not_create_quick_launch_shortcut); | 403 EXPECT_FALSE(do_not_create_quick_launch_shortcut); |
417 EXPECT_FALSE(do_not_create_taskbar_shortcut); | 404 EXPECT_FALSE(do_not_create_taskbar_shortcut); |
418 } | 405 } |
OLD | NEW |