| 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 #include "base/win/shortcut.h" | 5 #include "base/win/shortcut.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 16 matching lines...) Expand all Loading... |
| 27 protected: | 27 protected: |
| 28 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() OVERRIDE { |
| 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 30 ASSERT_TRUE(temp_dir_2_.CreateUniqueTempDir()); | 30 ASSERT_TRUE(temp_dir_2_.CreateUniqueTempDir()); |
| 31 | 31 |
| 32 link_file_ = temp_dir_.path().Append(L"My Link.lnk"); | 32 link_file_ = temp_dir_.path().Append(L"My Link.lnk"); |
| 33 | 33 |
| 34 // Shortcut 1's properties | 34 // Shortcut 1's properties |
| 35 { | 35 { |
| 36 const FilePath target_file(temp_dir_.path().Append(L"Target 1.txt")); | 36 const FilePath target_file(temp_dir_.path().Append(L"Target 1.txt")); |
| 37 file_util::WriteFile(target_file, kFileContents, | 37 WriteFile(target_file, kFileContents, arraysize(kFileContents)); |
| 38 arraysize(kFileContents)); | |
| 39 | 38 |
| 40 link_properties_.set_target(target_file); | 39 link_properties_.set_target(target_file); |
| 41 link_properties_.set_working_dir(temp_dir_.path()); | 40 link_properties_.set_working_dir(temp_dir_.path()); |
| 42 link_properties_.set_arguments(L"--magic --awesome"); | 41 link_properties_.set_arguments(L"--magic --awesome"); |
| 43 link_properties_.set_description(L"Chrome is awesome."); | 42 link_properties_.set_description(L"Chrome is awesome."); |
| 44 link_properties_.set_icon(link_properties_.target, 4); | 43 link_properties_.set_icon(link_properties_.target, 4); |
| 45 link_properties_.set_app_id(L"Chrome"); | 44 link_properties_.set_app_id(L"Chrome"); |
| 46 link_properties_.set_dual_mode(false); | 45 link_properties_.set_dual_mode(false); |
| 47 } | 46 } |
| 48 | 47 |
| 49 // Shortcut 2's properties (all different from properties of shortcut 1). | 48 // Shortcut 2's properties (all different from properties of shortcut 1). |
| 50 { | 49 { |
| 51 const FilePath target_file_2(temp_dir_.path().Append(L"Target 2.txt")); | 50 const FilePath target_file_2(temp_dir_.path().Append(L"Target 2.txt")); |
| 52 file_util::WriteFile(target_file_2, kFileContents2, | 51 WriteFile(target_file_2, kFileContents2, arraysize(kFileContents2)); |
| 53 arraysize(kFileContents2)); | |
| 54 | 52 |
| 55 FilePath icon_path_2; | 53 FilePath icon_path_2; |
| 56 base::CreateTemporaryFileInDir(temp_dir_.path(), &icon_path_2); | 54 CreateTemporaryFileInDir(temp_dir_.path(), &icon_path_2); |
| 57 | 55 |
| 58 link_properties_2_.set_target(target_file_2); | 56 link_properties_2_.set_target(target_file_2); |
| 59 link_properties_2_.set_working_dir(temp_dir_2_.path()); | 57 link_properties_2_.set_working_dir(temp_dir_2_.path()); |
| 60 link_properties_2_.set_arguments(L"--super --crazy"); | 58 link_properties_2_.set_arguments(L"--super --crazy"); |
| 61 link_properties_2_.set_description(L"The best in the west."); | 59 link_properties_2_.set_description(L"The best in the west."); |
| 62 link_properties_2_.set_icon(icon_path_2, 0); | 60 link_properties_2_.set_icon(icon_path_2, 0); |
| 63 link_properties_2_.set_app_id(L"Chrome.UserLevelCrazySuffix"); | 61 link_properties_2_.set_app_id(L"Chrome.UserLevelCrazySuffix"); |
| 64 link_properties_2_.set_dual_mode(true); | 62 link_properties_2_.set_dual_mode(true); |
| 65 } | 63 } |
| 66 } | 64 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 313 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| 316 link_file_, link_properties_2_, SHORTCUT_REPLACE_EXISTING)); | 314 link_file_, link_properties_2_, SHORTCUT_REPLACE_EXISTING)); |
| 317 | 315 |
| 318 ShortcutProperties expected_properties(link_properties_2_); | 316 ShortcutProperties expected_properties(link_properties_2_); |
| 319 expected_properties.set_arguments(link_properties_.arguments); | 317 expected_properties.set_arguments(link_properties_.arguments); |
| 320 ValidateShortcut(link_file_, expected_properties); | 318 ValidateShortcut(link_file_, expected_properties); |
| 321 } | 319 } |
| 322 | 320 |
| 323 } // namespace win | 321 } // namespace win |
| 324 } // namespace base | 322 } // namespace base |
| OLD | NEW |