Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/shell_integration_linux_unittest.cc

Issue 320503004: Refactored the ShortcutLocations.hidden flag on linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/web_applications/web_app.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/shell_integration_linux.h" 5 #include "chrome/browser/shell_integration_linux.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <map> 9 #include <map>
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // No existing shortcuts. 168 // No existing shortcuts.
169 { 169 {
170 MockEnvironment env; 170 MockEnvironment env;
171 web_app::ShortcutLocations result = 171 web_app::ShortcutLocations result =
172 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId); 172 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
173 EXPECT_FALSE(result.on_desktop); 173 EXPECT_FALSE(result.on_desktop);
174 EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE, 174 EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE,
175 result.applications_menu_location); 175 result.applications_menu_location);
176 176
177 EXPECT_FALSE(result.in_quick_launch_bar); 177 EXPECT_FALSE(result.in_quick_launch_bar);
178 EXPECT_FALSE(result.hidden);
179 } 178 }
180 179
181 // Shortcut on desktop. 180 // Shortcut on desktop.
182 { 181 {
183 base::ScopedTempDir temp_dir; 182 base::ScopedTempDir temp_dir;
184 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 183 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
185 base::FilePath desktop_path = temp_dir.path(); 184 base::FilePath desktop_path = temp_dir.path();
186 185
187 MockEnvironment env; 186 MockEnvironment env;
188 ASSERT_TRUE(base::CreateDirectory(desktop_path)); 187 ASSERT_TRUE(base::CreateDirectory(desktop_path));
189 ASSERT_FALSE(base::WriteFile( 188 ASSERT_FALSE(base::WriteFile(
190 desktop_path.AppendASCII(kTemplateFilename), 189 desktop_path.AppendASCII(kTemplateFilename),
191 "", 0)); 190 "", 0));
192 web_app::ShortcutLocations result = GetExistingShortcutLocations( 191 web_app::ShortcutLocations result = GetExistingShortcutLocations(
193 &env, kProfilePath, kExtensionId, desktop_path); 192 &env, kProfilePath, kExtensionId, desktop_path);
194 EXPECT_TRUE(result.on_desktop); 193 EXPECT_TRUE(result.on_desktop);
195 EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE, 194 EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE,
196 result.applications_menu_location); 195 result.applications_menu_location);
197 196
198 EXPECT_FALSE(result.in_quick_launch_bar); 197 EXPECT_FALSE(result.in_quick_launch_bar);
199 EXPECT_FALSE(result.hidden);
200 } 198 }
201 199
202 // Shortcut in applications directory. 200 // Shortcut in applications directory.
203 { 201 {
204 base::ScopedTempDir temp_dir; 202 base::ScopedTempDir temp_dir;
205 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 203 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
206 base::FilePath apps_path = temp_dir.path().AppendASCII("applications"); 204 base::FilePath apps_path = temp_dir.path().AppendASCII("applications");
207 205
208 MockEnvironment env; 206 MockEnvironment env;
209 env.Set("XDG_DATA_HOME", temp_dir.path().value()); 207 env.Set("XDG_DATA_HOME", temp_dir.path().value());
210 ASSERT_TRUE(base::CreateDirectory(apps_path)); 208 ASSERT_TRUE(base::CreateDirectory(apps_path));
211 ASSERT_FALSE(base::WriteFile( 209 ASSERT_FALSE(base::WriteFile(
212 apps_path.AppendASCII(kTemplateFilename), 210 apps_path.AppendASCII(kTemplateFilename),
213 "", 0)); 211 "", 0));
214 web_app::ShortcutLocations result = 212 web_app::ShortcutLocations result =
215 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId); 213 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
216 EXPECT_FALSE(result.on_desktop); 214 EXPECT_FALSE(result.on_desktop);
217 EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS, 215 EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS,
218 result.applications_menu_location); 216 result.applications_menu_location);
219 217
220 EXPECT_FALSE(result.in_quick_launch_bar); 218 EXPECT_FALSE(result.in_quick_launch_bar);
221 EXPECT_FALSE(result.hidden);
222 } 219 }
223 220
224 // Shortcut in applications directory with NoDisplay=true. 221 // Shortcut in applications directory with NoDisplay=true.
225 { 222 {
226 base::ScopedTempDir temp_dir; 223 base::ScopedTempDir temp_dir;
227 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 224 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
228 base::FilePath apps_path = temp_dir.path().AppendASCII("applications"); 225 base::FilePath apps_path = temp_dir.path().AppendASCII("applications");
229 226
230 MockEnvironment env; 227 MockEnvironment env;
231 env.Set("XDG_DATA_HOME", temp_dir.path().value()); 228 env.Set("XDG_DATA_HOME", temp_dir.path().value());
232 ASSERT_TRUE(base::CreateDirectory(apps_path)); 229 ASSERT_TRUE(base::CreateDirectory(apps_path));
233 ASSERT_TRUE(base::WriteFile( 230 ASSERT_TRUE(base::WriteFile(
234 apps_path.AppendASCII(kTemplateFilename), 231 apps_path.AppendASCII(kTemplateFilename),
235 kNoDisplayDesktopFile, strlen(kNoDisplayDesktopFile))); 232 kNoDisplayDesktopFile, strlen(kNoDisplayDesktopFile)));
236 web_app::ShortcutLocations result = 233 web_app::ShortcutLocations result =
237 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId); 234 GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
238 // Doesn't count as being in applications menu. 235 // Doesn't count as being in applications menu.
239 EXPECT_FALSE(result.on_desktop); 236 EXPECT_FALSE(result.on_desktop);
240 EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE, 237 EXPECT_EQ(web_app::APP_MENU_LOCATION_HIDDEN,
241 result.applications_menu_location); 238 result.applications_menu_location);
242 EXPECT_FALSE(result.in_quick_launch_bar); 239 EXPECT_FALSE(result.in_quick_launch_bar);
243 EXPECT_TRUE(result.hidden);
244 } 240 }
245 241
246 // Shortcut on desktop and in applications directory. 242 // Shortcut on desktop and in applications directory.
247 { 243 {
248 base::ScopedTempDir temp_dir1; 244 base::ScopedTempDir temp_dir1;
249 ASSERT_TRUE(temp_dir1.CreateUniqueTempDir()); 245 ASSERT_TRUE(temp_dir1.CreateUniqueTempDir());
250 base::FilePath desktop_path = temp_dir1.path(); 246 base::FilePath desktop_path = temp_dir1.path();
251 247
252 base::ScopedTempDir temp_dir2; 248 base::ScopedTempDir temp_dir2;
253 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir()); 249 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
254 base::FilePath apps_path = temp_dir2.path().AppendASCII("applications"); 250 base::FilePath apps_path = temp_dir2.path().AppendASCII("applications");
255 251
256 MockEnvironment env; 252 MockEnvironment env;
257 ASSERT_TRUE(base::CreateDirectory(desktop_path)); 253 ASSERT_TRUE(base::CreateDirectory(desktop_path));
258 ASSERT_FALSE(base::WriteFile( 254 ASSERT_FALSE(base::WriteFile(
259 desktop_path.AppendASCII(kTemplateFilename), 255 desktop_path.AppendASCII(kTemplateFilename),
260 "", 0)); 256 "", 0));
261 env.Set("XDG_DATA_HOME", temp_dir2.path().value()); 257 env.Set("XDG_DATA_HOME", temp_dir2.path().value());
262 ASSERT_TRUE(base::CreateDirectory(apps_path)); 258 ASSERT_TRUE(base::CreateDirectory(apps_path));
263 ASSERT_FALSE(base::WriteFile( 259 ASSERT_FALSE(base::WriteFile(
264 apps_path.AppendASCII(kTemplateFilename), 260 apps_path.AppendASCII(kTemplateFilename),
265 "", 0)); 261 "", 0));
266 web_app::ShortcutLocations result = GetExistingShortcutLocations( 262 web_app::ShortcutLocations result = GetExistingShortcutLocations(
267 &env, kProfilePath, kExtensionId, desktop_path); 263 &env, kProfilePath, kExtensionId, desktop_path);
268 EXPECT_TRUE(result.on_desktop); 264 EXPECT_TRUE(result.on_desktop);
269 EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS, 265 EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS,
270 result.applications_menu_location); 266 result.applications_menu_location);
271 EXPECT_FALSE(result.in_quick_launch_bar); 267 EXPECT_FALSE(result.in_quick_launch_bar);
272 EXPECT_FALSE(result.hidden);
273 } 268 }
274 } 269 }
275 270
276 TEST(ShellIntegrationTest, GetExistingShortcutContents) { 271 TEST(ShellIntegrationTest, GetExistingShortcutContents) {
277 const char kTemplateFilename[] = "shortcut-test.desktop"; 272 const char kTemplateFilename[] = "shortcut-test.desktop";
278 base::FilePath kTemplateFilepath(kTemplateFilename); 273 base::FilePath kTemplateFilepath(kTemplateFilename);
279 const char kTestData1[] = "a magical testing string"; 274 const char kTestData1[] = "a magical testing string";
280 const char kTestData2[] = "a different testing string"; 275 const char kTestData2[] = "a different testing string";
281 276
282 base::MessageLoop message_loop; 277 base::MessageLoop message_loop;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 633
639 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { 634 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) {
640 SCOPED_TRACE(i); 635 SCOPED_TRACE(i);
641 EXPECT_EQ(test_cases[i].expected_output, 636 EXPECT_EQ(test_cases[i].expected_output,
642 GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title), 637 GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title),
643 test_cases[i].icon_name)); 638 test_cases[i].icon_name));
644 } 639 }
645 } 640 }
646 641
647 } // namespace shell_integration_linux 642 } // namespace shell_integration_linux
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/web_applications/web_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698