| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ShortcutProperties only_target_properties; | 84 ShortcutProperties only_target_properties; |
| 85 only_target_properties.set_target(link_properties_.target); | 85 only_target_properties.set_target(link_properties_.target); |
| 86 | 86 |
| 87 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 87 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| 88 link_file_, only_target_properties, SHORTCUT_CREATE_ALWAYS)); | 88 link_file_, only_target_properties, SHORTCUT_CREATE_ALWAYS)); |
| 89 | 89 |
| 90 FilePath resolved_name; | 90 FilePath resolved_name; |
| 91 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); | 91 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); |
| 92 | 92 |
| 93 char read_contents[arraysize(kFileContents)]; | 93 char read_contents[arraysize(kFileContents)]; |
| 94 file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); | 94 base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); |
| 95 EXPECT_STREQ(kFileContents, read_contents); | 95 EXPECT_STREQ(kFileContents, read_contents); |
| 96 } | 96 } |
| 97 | 97 |
| 98 TEST_F(ShortcutTest, ResolveShortcutWithArgs) { | 98 TEST_F(ShortcutTest, ResolveShortcutWithArgs) { |
| 99 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 99 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| 100 link_file_, link_properties_, SHORTCUT_CREATE_ALWAYS)); | 100 link_file_, link_properties_, SHORTCUT_CREATE_ALWAYS)); |
| 101 | 101 |
| 102 FilePath resolved_name; | 102 FilePath resolved_name; |
| 103 string16 args; | 103 string16 args; |
| 104 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, &args)); | 104 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, &args)); |
| 105 | 105 |
| 106 char read_contents[arraysize(kFileContents)]; | 106 char read_contents[arraysize(kFileContents)]; |
| 107 file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); | 107 base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); |
| 108 EXPECT_STREQ(kFileContents, read_contents); | 108 EXPECT_STREQ(kFileContents, read_contents); |
| 109 EXPECT_EQ(link_properties_.arguments, args); | 109 EXPECT_EQ(link_properties_.arguments, args); |
| 110 } | 110 } |
| 111 | 111 |
| 112 TEST_F(ShortcutTest, CreateShortcutWithOnlySomeProperties) { | 112 TEST_F(ShortcutTest, CreateShortcutWithOnlySomeProperties) { |
| 113 ShortcutProperties target_and_args_properties; | 113 ShortcutProperties target_and_args_properties; |
| 114 target_and_args_properties.set_target(link_properties_.target); | 114 target_and_args_properties.set_target(link_properties_.target); |
| 115 target_and_args_properties.set_arguments(link_properties_.arguments); | 115 target_and_args_properties.set_arguments(link_properties_.arguments); |
| 116 | 116 |
| 117 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 117 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 SHORTCUT_UPDATE_EXISTING)); | 150 SHORTCUT_UPDATE_EXISTING)); |
| 151 | 151 |
| 152 ShortcutProperties expected_properties = link_properties_; | 152 ShortcutProperties expected_properties = link_properties_; |
| 153 expected_properties.set_target(link_properties_2_.target); | 153 expected_properties.set_target(link_properties_2_.target); |
| 154 ValidateShortcut(link_file_, expected_properties); | 154 ValidateShortcut(link_file_, expected_properties); |
| 155 | 155 |
| 156 FilePath resolved_name; | 156 FilePath resolved_name; |
| 157 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); | 157 EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); |
| 158 | 158 |
| 159 char read_contents[arraysize(kFileContents2)]; | 159 char read_contents[arraysize(kFileContents2)]; |
| 160 file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); | 160 base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); |
| 161 EXPECT_STREQ(kFileContents2, read_contents); | 161 EXPECT_STREQ(kFileContents2, read_contents); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_F(ShortcutTest, UpdateShortcutMakeDualMode) { | 164 TEST_F(ShortcutTest, UpdateShortcutMakeDualMode) { |
| 165 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 165 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| 166 link_file_, link_properties_, SHORTCUT_CREATE_ALWAYS)); | 166 link_file_, link_properties_, SHORTCUT_CREATE_ALWAYS)); |
| 167 | 167 |
| 168 ShortcutProperties make_dual_mode_properties; | 168 ShortcutProperties make_dual_mode_properties; |
| 169 make_dual_mode_properties.set_dual_mode(true); | 169 make_dual_mode_properties.set_dual_mode(true); |
| 170 | 170 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 ASSERT_TRUE(CreateOrUpdateShortcutLink( | 264 ASSERT_TRUE(CreateOrUpdateShortcutLink( |
| 265 link_file_, link_properties_2_, SHORTCUT_REPLACE_EXISTING)); | 265 link_file_, link_properties_2_, SHORTCUT_REPLACE_EXISTING)); |
| 266 | 266 |
| 267 ShortcutProperties expected_properties(link_properties_2_); | 267 ShortcutProperties expected_properties(link_properties_2_); |
| 268 expected_properties.set_arguments(link_properties_.arguments); | 268 expected_properties.set_arguments(link_properties_.arguments); |
| 269 ValidateShortcut(link_file_, expected_properties); | 269 ValidateShortcut(link_file_, expected_properties); |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace win | 272 } // namespace win |
| 273 } // namespace base | 273 } // namespace base |
| OLD | NEW |