| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <shellapi.h> | 6 #include <shellapi.h> |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 | 8 |
| 9 #include <fstream> | 9 #include <fstream> |
| 10 | 10 |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_comptr_win.h" | |
| 14 #include "base/memory/scoped_temp_dir.h" | 13 #include "base/memory/scoped_temp_dir.h" |
| 14 #include "base/win/scoped_comptr.h" |
| 15 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
| 16 #include "chrome/installer/util/master_preferences.h" | 16 #include "chrome/installer/util/master_preferences.h" |
| 17 #include "chrome/installer/util/shell_util.h" | 17 #include "chrome/installer/util/shell_util.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 bool VerifyChromeShortcut(const std::wstring& exe_path, | 21 bool VerifyChromeShortcut(const std::wstring& exe_path, |
| 22 const std::wstring& shortcut, | 22 const std::wstring& shortcut, |
| 23 const std::wstring& description, | 23 const std::wstring& description, |
| 24 int icon_index) { | 24 int icon_index) { |
| 25 ScopedComPtr<IShellLink> i_shell_link; | 25 base::win::ScopedComPtr<IShellLink> i_shell_link; |
| 26 ScopedComPtr<IPersistFile> i_persist_file; | 26 base::win::ScopedComPtr<IPersistFile> i_persist_file; |
| 27 | 27 |
| 28 // Get pointer to the IShellLink interface | 28 // Get pointer to the IShellLink interface |
| 29 bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | 29 bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
| 30 CLSCTX_INPROC_SERVER)); | 30 CLSCTX_INPROC_SERVER)); |
| 31 EXPECT_FALSE(failed) << "Failed to get IShellLink"; | 31 EXPECT_FALSE(failed) << "Failed to get IShellLink"; |
| 32 if (failed) | 32 if (failed) |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 // Query IShellLink for the IPersistFile interface | 35 // Query IShellLink for the IPersistFile interface |
| 36 failed = FAILED(i_persist_file.QueryFrom(i_shell_link)); | 36 failed = FAILED(i_persist_file.QueryFrom(i_shell_link)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Now change only description to update shortcut and make sure icon index | 139 // Now change only description to update shortcut and make sure icon index |
| 140 // doesn't change. | 140 // doesn't change. |
| 141 const std::wstring description2(L"dummy description 2"); | 141 const std::wstring description2(L"dummy description 2"); |
| 142 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, exe_path.value(), | 142 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, exe_path.value(), |
| 143 shortcut_path.value(), | 143 shortcut_path.value(), |
| 144 description2, false)); | 144 description2, false)); |
| 145 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 145 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 146 shortcut_path.value(), | 146 shortcut_path.value(), |
| 147 description2, 1)); | 147 description2, 1)); |
| 148 } | 148 } |
| OLD | NEW |