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

Side by Side Diff: chrome/installer/setup/install_unittest.cc

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 #include <objbase.h> 5 #include <objbase.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 installer::INSTALL_SHORTCUT_CREATE_ALL); 311 installer::INSTALL_SHORTCUT_CREATE_ALL);
312 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 312 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
313 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); 313 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_));
314 base::win::ValidateShortcut(user_start_menu_shortcut_, 314 base::win::ValidateShortcut(user_start_menu_shortcut_,
315 expected_start_menu_properties_); 315 expected_start_menu_properties_);
316 } 316 }
317 317
318 TEST_F(InstallShortcutTest, ReplaceAll) { 318 TEST_F(InstallShortcutTest, ReplaceAll) {
319 base::win::ShortcutProperties dummy_properties; 319 base::win::ShortcutProperties dummy_properties;
320 base::FilePath dummy_target; 320 base::FilePath dummy_target;
321 ASSERT_TRUE( 321 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
322 file_util::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
323 dummy_properties.set_target(dummy_target); 322 dummy_properties.set_target(dummy_target);
324 dummy_properties.set_working_dir(fake_user_desktop_.path()); 323 dummy_properties.set_working_dir(fake_user_desktop_.path());
325 dummy_properties.set_arguments(L"--dummy --args"); 324 dummy_properties.set_arguments(L"--dummy --args");
326 dummy_properties.set_app_id(L"El.Dummiest"); 325 dummy_properties.set_app_id(L"El.Dummiest");
327 326
328 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 327 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
329 user_desktop_shortcut_, dummy_properties, 328 user_desktop_shortcut_, dummy_properties,
330 base::win::SHORTCUT_CREATE_ALWAYS)); 329 base::win::SHORTCUT_CREATE_ALWAYS));
331 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 330 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
332 user_quick_launch_shortcut_, dummy_properties, 331 user_quick_launch_shortcut_, dummy_properties,
333 base::win::SHORTCUT_CREATE_ALWAYS)); 332 base::win::SHORTCUT_CREATE_ALWAYS));
334 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName())); 333 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName()));
335 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 334 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
336 user_start_menu_shortcut_, dummy_properties, 335 user_start_menu_shortcut_, dummy_properties,
337 base::win::SHORTCUT_CREATE_ALWAYS)); 336 base::win::SHORTCUT_CREATE_ALWAYS));
338 337
339 installer::CreateOrUpdateShortcuts( 338 installer::CreateOrUpdateShortcuts(
340 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 339 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
341 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); 340 installer::INSTALL_SHORTCUT_REPLACE_EXISTING);
342 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 341 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
343 base::win::ValidateShortcut(user_quick_launch_shortcut_, 342 base::win::ValidateShortcut(user_quick_launch_shortcut_,
344 expected_properties_); 343 expected_properties_);
345 base::win::ValidateShortcut(user_start_menu_shortcut_, 344 base::win::ValidateShortcut(user_start_menu_shortcut_,
346 expected_start_menu_properties_); 345 expected_start_menu_properties_);
347 } 346 }
348 347
349 TEST_F(InstallShortcutTest, ReplaceExisting) { 348 TEST_F(InstallShortcutTest, ReplaceExisting) {
350 base::win::ShortcutProperties dummy_properties; 349 base::win::ShortcutProperties dummy_properties;
351 base::FilePath dummy_target; 350 base::FilePath dummy_target;
352 ASSERT_TRUE( 351 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
353 file_util::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
354 dummy_properties.set_target(dummy_target); 352 dummy_properties.set_target(dummy_target);
355 dummy_properties.set_working_dir(fake_user_desktop_.path()); 353 dummy_properties.set_working_dir(fake_user_desktop_.path());
356 dummy_properties.set_arguments(L"--dummy --args"); 354 dummy_properties.set_arguments(L"--dummy --args");
357 dummy_properties.set_app_id(L"El.Dummiest"); 355 dummy_properties.set_app_id(L"El.Dummiest");
358 356
359 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 357 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
360 user_desktop_shortcut_, dummy_properties, 358 user_desktop_shortcut_, dummy_properties,
361 base::win::SHORTCUT_CREATE_ALWAYS)); 359 base::win::SHORTCUT_CREATE_ALWAYS));
362 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName())); 360 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName()));
363 361
364 installer::CreateOrUpdateShortcuts( 362 installer::CreateOrUpdateShortcuts(
365 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 363 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
366 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); 364 installer::INSTALL_SHORTCUT_REPLACE_EXISTING);
367 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 365 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
368 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); 366 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_));
369 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); 367 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_));
370 } 368 }
371 369
372 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { 370 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) {
373 base::win::ShortcutProperties dummy_properties; 371 base::win::ShortcutProperties dummy_properties;
374 base::FilePath dummy_target; 372 base::FilePath dummy_target;
375 ASSERT_TRUE( 373 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
376 file_util::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
377 dummy_properties.set_target(dummy_target); 374 dummy_properties.set_target(dummy_target);
378 375
379 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 376 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
380 system_desktop_shortcut_, dummy_properties, 377 system_desktop_shortcut_, dummy_properties,
381 base::win::SHORTCUT_CREATE_ALWAYS)); 378 base::win::SHORTCUT_CREATE_ALWAYS));
382 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 379 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
383 system_quick_launch_shortcut_, dummy_properties, 380 system_quick_launch_shortcut_, dummy_properties,
384 base::win::SHORTCUT_CREATE_ALWAYS)); 381 base::win::SHORTCUT_CREATE_ALWAYS));
385 ASSERT_TRUE(file_util::CreateDirectory( 382 ASSERT_TRUE(file_util::CreateDirectory(
386 system_start_menu_shortcut_.DirName())); 383 system_start_menu_shortcut_.DirName()));
(...skipping 16 matching lines...) Expand all
403 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 400 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
404 base::win::ValidateShortcut(user_quick_launch_shortcut_, 401 base::win::ValidateShortcut(user_quick_launch_shortcut_,
405 expected_properties_); 402 expected_properties_);
406 base::win::ValidateShortcut(user_start_menu_shortcut_, 403 base::win::ValidateShortcut(user_start_menu_shortcut_,
407 expected_start_menu_properties_); 404 expected_start_menu_properties_);
408 } 405 }
409 406
410 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelSomeSystemShortcutsExist) { 407 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelSomeSystemShortcutsExist) {
411 base::win::ShortcutProperties dummy_properties; 408 base::win::ShortcutProperties dummy_properties;
412 base::FilePath dummy_target; 409 base::FilePath dummy_target;
413 ASSERT_TRUE( 410 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
414 file_util::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
415 dummy_properties.set_target(dummy_target); 411 dummy_properties.set_target(dummy_target);
416 412
417 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 413 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
418 system_desktop_shortcut_, dummy_properties, 414 system_desktop_shortcut_, dummy_properties,
419 base::win::SHORTCUT_CREATE_ALWAYS)); 415 base::win::SHORTCUT_CREATE_ALWAYS));
420 416
421 installer::CreateOrUpdateShortcuts( 417 installer::CreateOrUpdateShortcuts(
422 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 418 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
423 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); 419 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL);
424 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_)); 420 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_));
(...skipping 10 matching lines...) Expand all
435 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 431 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
436 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 432 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
437 } 433 }
438 434
439 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { 435 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
440 string16 val(L"Google Chrome"); 436 string16 val(L"Google Chrome");
441 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; 437 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
442 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 438 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
443 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 439 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
444 } 440 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698