Chromium Code Reviews| Index: base/test/test_shortcut_win.cc |
| diff --git a/base/test/test_shortcut_win.cc b/base/test/test_shortcut_win.cc |
| index f84c0d06412df8fd35c01612b651dfdeeb069da6..647d7d97f61b78fc218b239fd5e7b6cab344e58d 100644 |
| --- a/base/test/test_shortcut_win.cc |
| +++ b/base/test/test_shortcut_win.cc |
| @@ -7,7 +7,6 @@ |
| #include <windows.h> |
| #include <shlobj.h> |
| #include <propkey.h> |
| -#include <propvarutil.h> |
| #include "base/file_path.h" |
| #include "base/string16.h" |
| @@ -16,9 +15,6 @@ |
| #include "base/win/windows_version.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -// propsys.lib is required for PropvariantTo*(). |
| -#pragma comment(lib, "propsys.lib") |
| - |
| namespace base { |
| namespace win { |
| @@ -120,34 +116,42 @@ void ValidateShortcut(const FilePath& shortcut_path, |
| if (GetVersion() >= VERSION_WIN7) { |
| ScopedComPtr<IPropertyStore> property_store; |
| - // Note that, as mentioned on MSDN at http://goo.gl/M8h9g, if a property is |
| - // not set, GetValue will return S_OK and the PROPVARIANT will be set to |
| - // VT_EMPTY. |
| - PROPVARIANT pv_app_id, pv_dual_mode; |
| EXPECT_TRUE(SUCCEEDED(hr = property_store.QueryFrom(i_shell_link))); |
| if (FAILED(hr)) |
| return; |
| - EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_ID, &pv_app_id)); |
| - EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_IsDualMode, |
| - &pv_dual_mode)); |
| - |
| - // Note, as mentioned on MSDN at |
| - // http://msdn.microsoft.com/library/windows/desktop/bb776559.aspx, if |
| - // |pv_app_id| is a VT_EMPTY it is successfully converted to the empty |
| - // string as desired. |
| - wchar_t read_app_id[MAX_PATH] = {0}; |
| - PropVariantToString(pv_app_id, read_app_id, MAX_PATH); |
| - if (properties.options & ShortcutProperties::PROPERTIES_APP_ID) |
| - EXPECT_EQ(properties.app_id, read_app_id); |
| - |
| - // Note, as mentioned on MSDN at |
| - // http://msdn.microsoft.com/library/windows/desktop/bb776531.aspx, if |
| - // |pv_dual_mode| is a VT_EMPTY it is successfully converted to false as |
| - // desired. |
| - BOOL read_dual_mode; |
| - PropVariantToBoolean(pv_dual_mode, &read_dual_mode); |
| - if (properties.options & ShortcutProperties::PROPERTIES_DUAL_MODE) |
| - EXPECT_EQ(properties.dual_mode, static_cast<bool>(read_dual_mode)); |
| + |
| + if (properties.options & ShortcutProperties::PROPERTIES_APP_ID) { |
| + PROPVARIANT pv_app_id; |
|
grt (UTC plus 2)
2013/01/08 04:21:45
Init+Clear this as in the impl to avoid memory lea
gab
2013/01/08 22:33:23
Done.
|
| + EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_ID, |
| + &pv_app_id)); |
| + switch (pv_app_id.vt) { |
| + case VT_EMPTY: |
| + EXPECT_TRUE(properties.app_id.empty()); |
| + break; |
| + case VT_LPWSTR: |
| + EXPECT_EQ(properties.app_id, pv_app_id.pwszVal); |
| + break; |
| + default: |
| + ADD_FAILURE() << "Unexpected variant type: " << pv_app_id.vt; |
| + } |
| + } |
| + |
| + if (properties.options & ShortcutProperties::PROPERTIES_DUAL_MODE) { |
| + PROPVARIANT pv_dual_mode; |
| + EXPECT_EQ(S_OK, property_store->GetValue(PKEY_AppUserModel_IsDualMode, |
| + &pv_dual_mode)); |
| + switch (pv_dual_mode.vt) { |
| + case VT_EMPTY: |
| + EXPECT_FALSE(properties.dual_mode); |
| + break; |
| + case VT_BOOL: |
| + EXPECT_EQ(properties.dual_mode, |
| + static_cast<bool>(pv_dual_mode.boolVal)); |
| + break; |
| + default: |
| + ADD_FAILURE() << "Unexpected variant type: " << pv_dual_mode.vt; |
| + } |
| + } |
| } |
| } |