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_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
13 #include "base/test/test_shortcut_win.h" | 13 #include "base/test/test_shortcut_win.h" |
14 #include "base/win/scoped_com_initializer.h" | 14 #include "base/win/scoped_com_initializer.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 static const char kFileContents[] = "This is a target."; | 19 static const char kFileContents[] = "This is a target."; |
20 static const char kFileContents2[] = "This is another target."; | 20 static const char kFileContents2[] = "This is another target."; |
21 | 21 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 link_properties_2_.set_working_dir(temp_dir_2_.path()); | 55 link_properties_2_.set_working_dir(temp_dir_2_.path()); |
56 link_properties_2_.set_arguments(L"--super --crazy"); | 56 link_properties_2_.set_arguments(L"--super --crazy"); |
57 link_properties_2_.set_description(L"The best in the west."); | 57 link_properties_2_.set_description(L"The best in the west."); |
58 link_properties_2_.set_icon(icon_path_2, 0); | 58 link_properties_2_.set_icon(icon_path_2, 0); |
59 link_properties_2_.set_app_id(L"Chrome.UserLevelCrazySuffix"); | 59 link_properties_2_.set_app_id(L"Chrome.UserLevelCrazySuffix"); |
60 link_properties_2_.set_dual_mode(true); | 60 link_properties_2_.set_dual_mode(true); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 base::win::ScopedCOMInitializer com_initializer_; | 64 base::win::ScopedCOMInitializer com_initializer_; |
65 ScopedTempDir temp_dir_; | 65 base::ScopedTempDir temp_dir_; |
66 ScopedTempDir temp_dir_2_; | 66 base::ScopedTempDir temp_dir_2_; |
67 | 67 |
68 // The link file to be created/updated in the shortcut tests below. | 68 // The link file to be created/updated in the shortcut tests below. |
69 FilePath link_file_; | 69 FilePath link_file_; |
70 | 70 |
71 // Properties for the created shortcut. | 71 // Properties for the created shortcut. |
72 base::win::ShortcutProperties link_properties_; | 72 base::win::ShortcutProperties link_properties_; |
73 | 73 |
74 // Properties for the updated shortcut. | 74 // Properties for the updated shortcut. |
75 base::win::ShortcutProperties link_properties_2_; | 75 base::win::ShortcutProperties link_properties_2_; |
76 }; | 76 }; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 expected_properties.set_app_id(string16()); | 241 expected_properties.set_app_id(string16()); |
242 expected_properties.set_dual_mode(false); | 242 expected_properties.set_dual_mode(false); |
243 base::win::ValidateShortcut(link_file_, expected_properties); | 243 base::win::ValidateShortcut(link_file_, expected_properties); |
244 } | 244 } |
245 | 245 |
246 TEST_F(ShortcutTest, FailTruncateShortcutThatDoesNotExist) { | 246 TEST_F(ShortcutTest, FailTruncateShortcutThatDoesNotExist) { |
247 ASSERT_FALSE(base::win::CreateOrUpdateShortcutLink( | 247 ASSERT_FALSE(base::win::CreateOrUpdateShortcutLink( |
248 link_file_, link_properties_, base::win::SHORTCUT_REPLACE_EXISTING)); | 248 link_file_, link_properties_, base::win::SHORTCUT_REPLACE_EXISTING)); |
249 ASSERT_FALSE(file_util::PathExists(link_file_)); | 249 ASSERT_FALSE(file_util::PathExists(link_file_)); |
250 } | 250 } |
OLD | NEW |