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

Unified Diff: base/file_util_unittest.cc

Issue 10914109: Refactoring and tests for the highly undertested file_util::CreateOrUpdateShortcutLink() method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespace s/Win/win Created 8 years, 3 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
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_unittest.cc
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 5a999839e79612fb5b3aca59c9be3149a6ad2e36..04de367ec0f6433b5f80b655819a21013b992e59 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1592,75 +1592,6 @@ TEST_F(ReadOnlyFileUtilTest, TextContentsEqual) {
// We don't need equivalent functionality outside of Windows.
#if defined(OS_WIN)
-TEST_F(FileUtilTest, ResolveShortcutTest) {
- FilePath target_file = temp_dir_.path().Append(L"Target.txt");
- CreateTextFile(target_file, L"This is the target.");
-
- FilePath link_file = temp_dir_.path().Append(L"Link.lnk");
-
- HRESULT result;
- IShellLink* shell = NULL;
- IPersistFile* persist = NULL;
-
- CoInitialize(NULL);
- // Temporarily create a shortcut for test
- result = CoCreateInstance(CLSID_ShellLink, NULL,
- CLSCTX_INPROC_SERVER, IID_IShellLink,
- reinterpret_cast<LPVOID*>(&shell));
- EXPECT_TRUE(SUCCEEDED(result));
- result = shell->QueryInterface(IID_IPersistFile,
- reinterpret_cast<LPVOID*>(&persist));
- EXPECT_TRUE(SUCCEEDED(result));
- result = shell->SetPath(target_file.value().c_str());
- EXPECT_TRUE(SUCCEEDED(result));
- result = shell->SetDescription(L"ResolveShortcutTest");
- EXPECT_TRUE(SUCCEEDED(result));
- result = shell->SetArguments(L"--args");
- EXPECT_TRUE(SUCCEEDED(result));
- result = persist->Save(link_file.value().c_str(), TRUE);
- EXPECT_TRUE(SUCCEEDED(result));
- if (persist)
- persist->Release();
- if (shell)
- shell->Release();
-
- bool is_solved;
- std::wstring args;
- is_solved = file_util::ResolveShortcut(link_file, &link_file, &args);
- EXPECT_TRUE(is_solved);
- EXPECT_EQ(L"--args", args);
- std::wstring contents;
- contents = ReadTextFile(link_file);
- EXPECT_EQ(L"This is the target.", contents);
-
- // Cleaning
- DeleteFile(target_file.value().c_str());
- DeleteFile(link_file.value().c_str());
- CoUninitialize();
-}
-
-TEST_F(FileUtilTest, CreateShortcutTest) {
- const wchar_t* file_contents = L"This is another target.";
- FilePath target_file = temp_dir_.path().Append(L"Target1.txt");
- CreateTextFile(target_file, file_contents);
-
- FilePath link_file = temp_dir_.path().Append(L"Link1.lnk");
-
- CoInitialize(NULL);
- EXPECT_TRUE(file_util::CreateOrUpdateShortcutLink(
- target_file.value().c_str(), link_file.value().c_str(), NULL,
- NULL, NULL, NULL, 0, NULL,
- file_util::SHORTCUT_CREATE_ALWAYS));
- FilePath resolved_name;
- EXPECT_TRUE(file_util::ResolveShortcut(link_file, &resolved_name, NULL));
- std::wstring read_contents = ReadTextFile(resolved_name);
- EXPECT_EQ(file_contents, read_contents);
-
- DeleteFile(target_file.value().c_str());
- DeleteFile(link_file.value().c_str());
- CoUninitialize();
-}
-
TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) {
// Create a directory
FilePath dir_name_from =
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698