| OLD | NEW |
| 1 // Copyright (c) 2009 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" | 13 #include "base/win/scoped_comptr.h" |
| 14 #include "chrome/installer/util/browser_distribution.h" | 14 #include "chrome/installer/util/browser_distribution.h" |
| 15 #include "chrome/installer/util/master_preferences.h" | 15 #include "chrome/installer/util/master_preferences.h" |
| 16 #include "chrome/installer/util/shell_util.h" | 16 #include "chrome/installer/util/shell_util.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 bool VerifyChromeShortcut(const std::wstring& exe_path, | 20 bool VerifyChromeShortcut(const std::wstring& exe_path, |
| 21 const std::wstring& shortcut, | 21 const std::wstring& shortcut, |
| 22 const std::wstring& description, | 22 const std::wstring& description, |
| 23 int icon_index) { | 23 int icon_index) { |
| 24 ScopedComPtr<IShellLink> i_shell_link; | 24 base::win::ScopedComPtr<IShellLink> i_shell_link; |
| 25 ScopedComPtr<IPersistFile> i_persist_file; | 25 base::win::ScopedComPtr<IPersistFile> i_persist_file; |
| 26 | 26 |
| 27 // Get pointer to the IShellLink interface | 27 // Get pointer to the IShellLink interface |
| 28 bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | 28 bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
| 29 CLSCTX_INPROC_SERVER)); | 29 CLSCTX_INPROC_SERVER)); |
| 30 EXPECT_FALSE(failed) << "Failed to get IShellLink"; | 30 EXPECT_FALSE(failed) << "Failed to get IShellLink"; |
| 31 if (failed) | 31 if (failed) |
| 32 return false; | 32 return false; |
| 33 | 33 |
| 34 // Query IShellLink for the IPersistFile interface | 34 // Query IShellLink for the IPersistFile interface |
| 35 failed = FAILED(i_persist_file.QueryFrom(i_shell_link)); | 35 failed = FAILED(i_persist_file.QueryFrom(i_shell_link)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Now change only description to update shortcut and make sure icon index | 152 // Now change only description to update shortcut and make sure icon index |
| 153 // doesn't change. | 153 // doesn't change. |
| 154 const std::wstring description2(L"dummy description 2"); | 154 const std::wstring description2(L"dummy description 2"); |
| 155 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, exe_path.value(), | 155 EXPECT_TRUE(ShellUtil::UpdateChromeShortcut(dist, exe_path.value(), |
| 156 shortcut_path.value(), | 156 shortcut_path.value(), |
| 157 description2, false)); | 157 description2, false)); |
| 158 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 158 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 159 shortcut_path.value(), | 159 shortcut_path.value(), |
| 160 description2, 1)); | 160 description2, 1)); |
| 161 } | 161 } |
| OLD | NEW |