Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5013)

Unified Diff: chrome/installer/util/shell_util_unittest.cc

Issue 10826188: Sharing shell_util_unittest code to verify shortcuts (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/installer/util/shell_util.cc ('K') | « chrome/installer/util/shell_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/shell_util_unittest.cc
===================================================================
--- chrome/installer/util/shell_util_unittest.cc (revision 149222)
+++ chrome/installer/util/shell_util_unittest.cc (working copy)
@@ -24,72 +24,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
gab 2012/08/07 19:18:25 nit: Please add a blank line here (as per the Chro
Halli 2012/08/07 20:52:16 Done.
-bool VerifyChromeShortcut(const std::wstring& exe_path,
- const std::wstring& shortcut,
- const std::wstring& description,
- int icon_index) {
- base::win::ScopedComPtr<IShellLink> i_shell_link;
- base::win::ScopedComPtr<IPersistFile> i_persist_file;
-
- // Get pointer to the IShellLink interface
- bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL,
- CLSCTX_INPROC_SERVER));
- EXPECT_FALSE(failed) << "Failed to get IShellLink";
- if (failed)
- return false;
-
- // Query IShellLink for the IPersistFile interface
- failed = FAILED(i_persist_file.QueryFrom(i_shell_link));
- EXPECT_FALSE(failed) << "Failed to get IPersistFile";
- if (failed)
- return false;
-
- failed = FAILED(i_persist_file->Load(shortcut.c_str(), 0));
- EXPECT_FALSE(failed) << "Failed to load shortcut " << shortcut.c_str();
- if (failed)
- return false;
-
- wchar_t long_path[MAX_PATH] = {0};
- wchar_t short_path[MAX_PATH] = {0};
- failed = ((::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0) ||
- (::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0));
- EXPECT_FALSE(failed) << "Failed to get long and short path names for "
- << exe_path;
- if (failed)
- return false;
-
- wchar_t file_path[MAX_PATH] = {0};
- failed = ((FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL,
- SLGP_UNCPRIORITY))) ||
- ((FilePath(file_path) != FilePath(long_path)) &&
- (FilePath(file_path) != FilePath(short_path))));
- EXPECT_FALSE(failed) << "File path " << file_path << " did not match with "
- << exe_path;
- if (failed)
- return false;
-
- wchar_t desc[MAX_PATH] = {0};
- failed = ((FAILED(i_shell_link->GetDescription(desc, MAX_PATH))) ||
- (std::wstring(desc) != std::wstring(description)));
- EXPECT_FALSE(failed) << "Description " << desc << " did not match with "
- << description;
- if (failed)
- return false;
-
- wchar_t icon_path[MAX_PATH] = {0};
- int index = 0;
- failed = ((FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH,
- &index))) ||
- ((FilePath(file_path) != FilePath(long_path)) &&
- (FilePath(file_path) != FilePath(short_path))) ||
- (index != icon_index));
- EXPECT_FALSE(failed);
- if (failed)
- return false;
-
- return true;
-}
-
class ShellUtilTestWithDirAndDist : public testing::Test {
protected:
virtual void SetUp() {
@@ -102,7 +36,7 @@
ScopedTempDir temp_dir_;
};
gab 2012/08/07 19:18:25 nit: Blank line here as well.
Halli 2012/08/07 20:52:16 Done.
-};
+}
// Test that we can open archives successfully.
TEST_F(ShellUtilTestWithDirAndDist, UpdateChromeShortcutTest) {
@@ -125,7 +59,7 @@
exe_path.value(),
dist_->GetIconIndex(),
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
description, 0));
@@ -152,7 +86,7 @@
exe_path.value(),
dist_->GetIconIndex(),
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
gab 2012/08/07 19:18:25 ident variable to same level as the one above it (
Halli 2012/08/07 20:52:16 Done.
description, 1));
@@ -167,7 +101,7 @@
exe_path.value(),
dist_->GetIconIndex(),
ShellUtil::SHORTCUT_NO_OPTIONS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
description2, 1));
}
@@ -228,7 +162,7 @@
dist_->GetIconIndex(),
ShellUtil::CURRENT_USER,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
user_shortcut_path.value(),
description,
0));
@@ -248,7 +182,7 @@
dist_->GetIconIndex(),
ShellUtil::SYSTEM_LEVEL,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
system_shortcut_path.value(),
description,
0));
@@ -279,7 +213,7 @@
dist_->GetIconIndex(),
ShellUtil::CURRENT_USER,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
system_shortcut_path.value(),
description,
0));
@@ -311,11 +245,11 @@
dist_->GetIconIndex(),
ShellUtil::SYSTEM_LEVEL,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
user_shortcut_path.value(),
description,
0));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
system_shortcut_path.value(),
description,
0));
@@ -340,7 +274,7 @@
dist_->GetIconIndex(),
ShellUtil::CURRENT_USER,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
default_profile_shortcut_path.value(),
description,
0));
@@ -354,7 +288,7 @@
dist_->GetIconIndex(),
ShellUtil::CURRENT_USER,
ShellUtil::SHORTCUT_CREATE_ALWAYS));
- EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
+ EXPECT_TRUE(ShellUtil::VerifyChromeShortcut(exe_path.value(),
second_profile_shortcut_path.value(),
description,
0));
« chrome/installer/util/shell_util.cc ('K') | « chrome/installer/util/shell_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698