| 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/test/test_shortcut_win.h" | 5 #include "base/test/test_shortcut_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int read_icon_index = 0; | 60 int read_icon_index = 0; |
| 61 | 61 |
| 62 HRESULT hr; | 62 HRESULT hr; |
| 63 | 63 |
| 64 // Initialize the shell interfaces. | 64 // Initialize the shell interfaces. |
| 65 EXPECT_TRUE(SUCCEEDED(hr = i_shell_link.CreateInstance( | 65 EXPECT_TRUE(SUCCEEDED(hr = i_shell_link.CreateInstance( |
| 66 CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER))); | 66 CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER))); |
| 67 if (FAILED(hr)) | 67 if (FAILED(hr)) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 EXPECT_TRUE(SUCCEEDED(hr = i_persist_file.QueryFrom(i_shell_link.Get()))); | 70 EXPECT_TRUE( |
| 71 SUCCEEDED(hr = i_shell_link.CopyTo(i_persist_file.GetAddressOf()))); |
| 71 if (FAILED(hr)) | 72 if (FAILED(hr)) |
| 72 return; | 73 return; |
| 73 | 74 |
| 74 // Load the shortcut. | 75 // Load the shortcut. |
| 75 EXPECT_TRUE(SUCCEEDED(hr = i_persist_file->Load( | 76 EXPECT_TRUE(SUCCEEDED(hr = i_persist_file->Load( |
| 76 shortcut_path.value().c_str(), 0))) << "Failed to load shortcut at " | 77 shortcut_path.value().c_str(), 0))) << "Failed to load shortcut at " |
| 77 << shortcut_path.value(); | 78 << shortcut_path.value(); |
| 78 if (FAILED(hr)) | 79 if (FAILED(hr)) |
| 79 return; | 80 return; |
| 80 | 81 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 105 | 106 |
| 106 if (properties.options & ShortcutProperties::PROPERTIES_ICON) { | 107 if (properties.options & ShortcutProperties::PROPERTIES_ICON) { |
| 107 EXPECT_TRUE(SUCCEEDED( | 108 EXPECT_TRUE(SUCCEEDED( |
| 108 i_shell_link->GetIconLocation(read_icon, MAX_PATH, &read_icon_index))); | 109 i_shell_link->GetIconLocation(read_icon, MAX_PATH, &read_icon_index))); |
| 109 ValidatePathsAreEqual(properties.icon, base::FilePath(read_icon)); | 110 ValidatePathsAreEqual(properties.icon, base::FilePath(read_icon)); |
| 110 EXPECT_EQ(properties.icon_index, read_icon_index); | 111 EXPECT_EQ(properties.icon_index, read_icon_index); |
| 111 } | 112 } |
| 112 | 113 |
| 113 if (GetVersion() >= VERSION_WIN7) { | 114 if (GetVersion() >= VERSION_WIN7) { |
| 114 ScopedComPtr<IPropertyStore> property_store; | 115 ScopedComPtr<IPropertyStore> property_store; |
| 115 EXPECT_TRUE(SUCCEEDED(hr = property_store.QueryFrom(i_shell_link.Get()))); | 116 EXPECT_TRUE( |
| 117 SUCCEEDED(hr = i_shell_link.CopyTo(property_store.GetAddressOf()))); |
| 116 if (FAILED(hr)) | 118 if (FAILED(hr)) |
| 117 return; | 119 return; |
| 118 | 120 |
| 119 if (properties.options & ShortcutProperties::PROPERTIES_APP_ID) { | 121 if (properties.options & ShortcutProperties::PROPERTIES_APP_ID) { |
| 120 ScopedPropVariant pv_app_id; | 122 ScopedPropVariant pv_app_id; |
| 121 EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_ID, | 123 EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_ID, |
| 122 pv_app_id.Receive())); | 124 pv_app_id.Receive())); |
| 123 switch (pv_app_id.get().vt) { | 125 switch (pv_app_id.get().vt) { |
| 124 case VT_EMPTY: | 126 case VT_EMPTY: |
| 125 EXPECT_TRUE(properties.app_id.empty()); | 127 EXPECT_TRUE(properties.app_id.empty()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 146 break; | 148 break; |
| 147 default: | 149 default: |
| 148 ADD_FAILURE() << "Unexpected variant type: " << pv_dual_mode.get().vt; | 150 ADD_FAILURE() << "Unexpected variant type: " << pv_dual_mode.get().vt; |
| 149 } | 151 } |
| 150 } | 152 } |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace win | 156 } // namespace win |
| 155 } // namespace base | 157 } // namespace base |
| OLD | NEW |