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

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

Issue 100573002: Move directory creation 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
« no previous file with comments | « chrome/common/net/url_fixer_upper_unittest.cc ('k') | chrome/installer/setup/setup_main.cc » ('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 (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 23 matching lines...) Expand all
34 34
35 class CreateVisualElementsManifestTest : public testing::Test { 35 class CreateVisualElementsManifestTest : public testing::Test {
36 protected: 36 protected:
37 virtual void SetUp() OVERRIDE { 37 virtual void SetUp() OVERRIDE {
38 // Create a temp directory for testing. 38 // Create a temp directory for testing.
39 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 39 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
40 40
41 version_ = Version("0.0.0.0"); 41 version_ = Version("0.0.0.0");
42 42
43 version_dir_ = test_dir_.path().AppendASCII(version_.GetString()); 43 version_dir_ = test_dir_.path().AppendASCII(version_.GetString());
44 ASSERT_TRUE(file_util::CreateDirectory(version_dir_)); 44 ASSERT_TRUE(base::CreateDirectory(version_dir_));
45 45
46 manifest_path_ = 46 manifest_path_ =
47 test_dir_.path().Append(installer::kVisualElementsManifest); 47 test_dir_.path().Append(installer::kVisualElementsManifest);
48 } 48 }
49 49
50 virtual void TearDown() OVERRIDE { 50 virtual void TearDown() OVERRIDE {
51 // Clean up test directory manually so we can fail if it leaks. 51 // Clean up test directory manually so we can fail if it leaks.
52 ASSERT_TRUE(test_dir_.Delete()); 52 ASSERT_TRUE(test_dir_.Delete());
53 } 53 }
54 54
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // not present. 221 // not present.
222 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { 222 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) {
223 ASSERT_TRUE( 223 ASSERT_TRUE(
224 installer::CreateVisualElementsManifest(test_dir_.path(), version_)); 224 installer::CreateVisualElementsManifest(test_dir_.path(), version_));
225 ASSERT_FALSE(base::PathExists(manifest_path_)); 225 ASSERT_FALSE(base::PathExists(manifest_path_));
226 } 226 }
227 227
228 // Test that VisualElementsManifest.xml is created with the correct content when 228 // Test that VisualElementsManifest.xml is created with the correct content when
229 // VisualElements are present. 229 // VisualElements are present.
230 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestCreated) { 230 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestCreated) {
231 ASSERT_TRUE(file_util::CreateDirectory( 231 ASSERT_TRUE(base::CreateDirectory(
232 version_dir_.Append(installer::kVisualElements))); 232 version_dir_.Append(installer::kVisualElements)));
233 ASSERT_TRUE( 233 ASSERT_TRUE(
234 installer::CreateVisualElementsManifest(test_dir_.path(), version_)); 234 installer::CreateVisualElementsManifest(test_dir_.path(), version_));
235 ASSERT_TRUE(base::PathExists(manifest_path_)); 235 ASSERT_TRUE(base::PathExists(manifest_path_));
236 236
237 std::string read_manifest; 237 std::string read_manifest;
238 ASSERT_TRUE(base::ReadFileToString(manifest_path_, &read_manifest)); 238 ASSERT_TRUE(base::ReadFileToString(manifest_path_, &read_manifest));
239 239
240 static const char kExpectedManifest[] = 240 static const char kExpectedManifest[] =
241 "<Application>\r\n" 241 "<Application>\r\n"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 dummy_properties.set_working_dir(fake_user_desktop_.path()); 323 dummy_properties.set_working_dir(fake_user_desktop_.path());
324 dummy_properties.set_arguments(L"--dummy --args"); 324 dummy_properties.set_arguments(L"--dummy --args");
325 dummy_properties.set_app_id(L"El.Dummiest"); 325 dummy_properties.set_app_id(L"El.Dummiest");
326 326
327 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 327 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
328 user_desktop_shortcut_, dummy_properties, 328 user_desktop_shortcut_, dummy_properties,
329 base::win::SHORTCUT_CREATE_ALWAYS)); 329 base::win::SHORTCUT_CREATE_ALWAYS));
330 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 330 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
331 user_quick_launch_shortcut_, dummy_properties, 331 user_quick_launch_shortcut_, dummy_properties,
332 base::win::SHORTCUT_CREATE_ALWAYS)); 332 base::win::SHORTCUT_CREATE_ALWAYS));
333 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName())); 333 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName()));
334 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 334 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
335 user_start_menu_shortcut_, dummy_properties, 335 user_start_menu_shortcut_, dummy_properties,
336 base::win::SHORTCUT_CREATE_ALWAYS)); 336 base::win::SHORTCUT_CREATE_ALWAYS));
337 337
338 installer::CreateOrUpdateShortcuts( 338 installer::CreateOrUpdateShortcuts(
339 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 339 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
340 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); 340 installer::INSTALL_SHORTCUT_REPLACE_EXISTING);
341 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 341 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
342 base::win::ValidateShortcut(user_quick_launch_shortcut_, 342 base::win::ValidateShortcut(user_quick_launch_shortcut_,
343 expected_properties_); 343 expected_properties_);
344 base::win::ValidateShortcut(user_start_menu_shortcut_, 344 base::win::ValidateShortcut(user_start_menu_shortcut_,
345 expected_start_menu_properties_); 345 expected_start_menu_properties_);
346 } 346 }
347 347
348 TEST_F(InstallShortcutTest, ReplaceExisting) { 348 TEST_F(InstallShortcutTest, ReplaceExisting) {
349 base::win::ShortcutProperties dummy_properties; 349 base::win::ShortcutProperties dummy_properties;
350 base::FilePath dummy_target; 350 base::FilePath dummy_target;
351 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); 351 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
352 dummy_properties.set_target(dummy_target); 352 dummy_properties.set_target(dummy_target);
353 dummy_properties.set_working_dir(fake_user_desktop_.path()); 353 dummy_properties.set_working_dir(fake_user_desktop_.path());
354 dummy_properties.set_arguments(L"--dummy --args"); 354 dummy_properties.set_arguments(L"--dummy --args");
355 dummy_properties.set_app_id(L"El.Dummiest"); 355 dummy_properties.set_app_id(L"El.Dummiest");
356 356
357 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 357 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
358 user_desktop_shortcut_, dummy_properties, 358 user_desktop_shortcut_, dummy_properties,
359 base::win::SHORTCUT_CREATE_ALWAYS)); 359 base::win::SHORTCUT_CREATE_ALWAYS));
360 ASSERT_TRUE(file_util::CreateDirectory(user_start_menu_shortcut_.DirName())); 360 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName()));
361 361
362 installer::CreateOrUpdateShortcuts( 362 installer::CreateOrUpdateShortcuts(
363 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 363 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
364 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); 364 installer::INSTALL_SHORTCUT_REPLACE_EXISTING);
365 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 365 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
366 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); 366 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_));
367 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); 367 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_));
368 } 368 }
369 369
370 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { 370 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) {
371 base::win::ShortcutProperties dummy_properties; 371 base::win::ShortcutProperties dummy_properties;
372 base::FilePath dummy_target; 372 base::FilePath dummy_target;
373 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); 373 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
374 dummy_properties.set_target(dummy_target); 374 dummy_properties.set_target(dummy_target);
375 375
376 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 376 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
377 system_desktop_shortcut_, dummy_properties, 377 system_desktop_shortcut_, dummy_properties,
378 base::win::SHORTCUT_CREATE_ALWAYS)); 378 base::win::SHORTCUT_CREATE_ALWAYS));
379 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 379 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
380 system_quick_launch_shortcut_, dummy_properties, 380 system_quick_launch_shortcut_, dummy_properties,
381 base::win::SHORTCUT_CREATE_ALWAYS)); 381 base::win::SHORTCUT_CREATE_ALWAYS));
382 ASSERT_TRUE(file_util::CreateDirectory( 382 ASSERT_TRUE(base::CreateDirectory(
383 system_start_menu_shortcut_.DirName())); 383 system_start_menu_shortcut_.DirName()));
384 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 384 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
385 system_start_menu_shortcut_, dummy_properties, 385 system_start_menu_shortcut_, dummy_properties,
386 base::win::SHORTCUT_CREATE_ALWAYS)); 386 base::win::SHORTCUT_CREATE_ALWAYS));
387 387
388 installer::CreateOrUpdateShortcuts( 388 installer::CreateOrUpdateShortcuts(
389 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 389 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
390 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); 390 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL);
391 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_)); 391 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_));
392 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); 392 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 431 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
432 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 432 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
433 } 433 }
434 434
435 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { 435 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
436 string16 val(L"Google Chrome"); 436 string16 val(L"Google Chrome");
437 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; 437 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
438 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 438 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
439 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 439 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
440 } 440 }
OLDNEW
« no previous file with comments | « chrome/common/net/url_fixer_upper_unittest.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698